Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@maruaudio/dsp/math/permutation-six encodes an ordering of six stable identities (0 to 5) as its lexicographic rank, 0 to 719, and decodes a rank back into an order. It is the Lehmer code with fixed factorial weights 120, 24, 6, 2, 1, 1 and a six-bit "used" mask, so both directions run in bounded loops over caller-owned Int32Array storage. The identity order 0, 1, 2, 3, 4, 5 is rank 0.

Functions

NameInputsOutputDomain as coded
rankPermutationSixorder: Int32Arrayrank 0..719, or −1−1 unless the array has length 6 and holds each of 0..5 exactly once
tryUnrankPermutationSixrank, output: Int32Arraytrue and fills output[0..5], or falsefalse for NaN, ±Infinity, fractions, ranks outside 0..719, or an output shorter than 6; ranks never wrap
PERMUTATION_SIX_SIZE, PERMUTATION_SIX_COUNTconstants6, 720

Lifecycle

None. Stateless validation and codec operations; the caller owns the arrays.

When to use it

Store the order of a six-slot serial effect chain as one integer parameter, so a Processor and its face agree on the same order. The Multifx Processor stack and face share it.

Limits

  • Exactly six items; there is no generic size.
  • On a rejected rank, output is left as it was; a valid unrank writes all six slots. An output longer than six keeps its extra slots.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Dependencies

None: this node imports no other node.

Dependents

Used by