Partition representations: Difference between revisions

Jump to navigation Jump to search
→‎Mesh representation: Conversion from index-based to mesh
(→‎Target indices: Add BQN link)
(→‎Mesh representation: Conversion from index-based to mesh)
Line 145: Line 145:
</source>
</source>
In the above functions, the only difference in code is exchanging 0 and 1, and the only difference in output is an extra trailing 0 when computed from the division lengths. The mesh representation makes the partition representation duality especially clear, as the dual representation can be obtained simply by [[Not|negating]] the mesh vector.
In the above functions, the only difference in code is exchanging 0 and 1, and the only difference in output is an extra trailing 0 when computed from the division lengths. The mesh representation makes the partition representation duality especially clear, as the dual representation can be obtained simply by [[Not|negating]] the mesh vector.
Conversion from index-based representations is less obvious but more efficient, and also easily invertible. These representations index into either elements or dividers, but can be converted to index into the mesh vector, which combines both, by adding one for each previous index. These adjusted indices give the locations of all ones, or all zeros, in the mesh vector, depending on the initial representation.
<source lang=apl>
      ⍸⍣¯1{⍵+⍳≢⍵} 0 0 0 2 3 3  ⍝ From target indices
1 1 1 0 0 1 0 1 1
      ~⍸⍣¯1{⍵+⍳≢⍵} 3 3 4 6      ⍝ From division endpoints
1 1 1 0 0 1 0 1 1 0
</source>
The adjusted target indices and division endpoints combine with the mesh vector and its negation to give a set of four representations that parallel the four partition representations. Instead of using lists of natural numbers, and nondecreasing lists of natural numbers, these use lists of booleans, and strictly increasing lists of natural numbers. They may be considered a representation of sets rather than multisets of natural numbers.


[[Category:Essays]]
[[Category:Essays]]

Navigation menu