Constructor
new PermutationRepository(initialDegreeopt, initialPermCapacityopt)
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
initialDegree |
number |
<optional> |
4
|
The initial degree (number of points) for permutations. The repository will automatically expand if permutations with higher degrees are registered. |
initialPermCapacity |
number |
<optional> |
1024
|
The initial capacity for storing permutations. The capacity will automatically expand as more unique permutations are registered. |
Classes
Members
count :number
- Description:
The number of unique permutations currently stored in the repository. Also serves as the next available ID for a new permutation.
- Source:
The number of unique permutations currently stored in the repository. Also serves as the next available ID for a new permutation.
Type:
- number
globalDegree :number
- Description:
The current maximum degree of all permutations stored in the repository. Auto-expands as larger permutations are registered.
- Source:
The current maximum degree of all permutations stored in the repository. Auto-expands as larger permutations are registered.
Type:
- number
(readonly) identity :number
- Description:
The unique ID for the identity permutation. This is always 0.
- Source:
The unique ID for the identity permutation. This is always 0.
Type:
- number
permBuffer :Int32Array
- Description:
A flat Int32Array that stores the actual permutation data. Each permutation of
globalDegreesize occupiesglobalDegreecontiguous slots.
- Source:
A flat Int32Array that stores the actual permutation data.
Each permutation of globalDegree size occupies globalDegree contiguous slots.
Type:
- Int32Array
permCapacity :number
- Description:
The current allocated capacity for storing permutations. This defines the maximum number of unique permutations that can be stored before the
permBufferneeds to be expanded.
- Source:
The current allocated capacity for storing permutations.
This defines the maximum number of unique permutations that can be stored
before the permBuffer needs to be expanded.
Type:
- number
trieBuffer :Int32Array
- Description:
A flat Int32Array representing the memory arena for the trie nodes.
- Source:
A flat Int32Array representing the memory arena for the trie nodes.
Type:
- Int32Array
trieFreePtr :number
- Description:
Pointer to the next available slot in the
trieBufferfor allocating a new node.
- Source:
Pointer to the next available slot in the trieBuffer for allocating a new node.
Type:
- number
trieNodeSize :number
- Description:
The size of each node in the trie buffer. A node stores an ID and
globalDegreechild pointers.
- Source:
The size of each node in the trie buffer.
A node stores an ID and globalDegree child pointers.
Type:
- number
Methods
commutator(idA, idB) → {number}
- Description:
Computes the commutator of two permutations:
[idA, idB] = idA^-1 * idB^-1 * idA * idB.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
idA |
number | The ID of the first permutation (a). |
idB |
number | The ID of the second permutation (b). |
Returns:
The ID of the resulting commutator permutation.
- Type
- number
conjugate(g, h) → {number}
- Description:
Computes the conjugate of permutation
hbyg:g * h * g^-1. This operation results in a permutation that has the same cycle structure ash.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
g |
number | The ID of the conjugating permutation (g). |
h |
number | The ID of the permutation to be conjugated (h). |
Returns:
The ID of the resulting conjugated permutation (g * h * g^-1).
- Type
- number
get(id) → {Int32Array}
- Description:
Retrieves the permutation data for a given ID. Returns a zero-copy view (subarray) of the internal
permBuffer.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
number | The unique ID of the permutation to retrieve. |
Returns:
A subarray representing the permutation (e.g., [0, 1, 2]).
- Type
- Int32Array
getAsCycles(id) → {string}
- Description:
Retrieves the permutation for a given ID and converts it into a 1-based cycle notation string.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
number | The unique ID of the permutation. |
Returns:
The cycle notation string (e.g., "(1 2 3)(4 5)"). Returns "()" for the identity permutation.
- Type
- string
inverse(id) → {number}
- Description:
Computes the inverse of a given permutation ID. If the inverse has already been registered, its ID is retrieved; otherwise, it's computed and registered.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
number | The ID of the permutation to invert. |
Returns:
The ID of the inverse permutation.
- Type
- number
multiply(idA, idB) → {number}
- Description:
Multiplies two permutations,
idAandidB, according to the convention (A * B)(x) = A(B(x)). This means permutationidBis applied first, thenidA. The resulting permutation is registered, and its ID is returned. Exposed as Public API for solvers.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
idA |
number | The ID of the first permutation (A). |
idB |
number | The ID of the second permutation (B). |
Returns:
The ID of the resulting permutation (A * B).
- Type
- number
register(rawPerm) → {number}
- Description:
Registers a permutation (or retrieves its existing ID if already registered). If the input permutation's degree is greater than the current
globalDegree, the repository will automatically upgrade its degree.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
rawPerm |
ArrayLike.<number> | The permutation to register, represented as an array-like object (e.g., |
Returns:
The unique ID assigned to the permutation.
- Type
- number