Integer Matrix API¶
Functions for computing SNF, HNF, and elementary divisors of integer matrices.
All functions accept a DenseIntMatrix, SparseIntMatrix, or a plain dict conforming to either schema. See Input Formats for details.
Functions¶
snforacle.interface.smith_normal_form ¶
Compute the Smith normal form of an integer matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Any
|
The input matrix as a |
required |
backend
|
_IntBackend | None
|
Name of the backend to use: |
None
|
Returns:
| Type | Description |
|---|---|
SNFResult
|
A Pydantic model with fields:
|
snforacle.interface.smith_normal_form_with_transforms ¶
smith_normal_form_with_transforms(
matrix: Any, backend: _IntBackend | None = None
) -> SNFWithTransformsResult
Compute the Smith normal form together with the unimodular transformations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Any
|
The input matrix (same accepted types as :func: |
required |
backend
|
_IntBackend | None
|
Name of the backend to use. |
None
|
Returns:
| Type | Description |
|---|---|
SNFWithTransformsResult
|
A Pydantic model with fields:
The matrices satisfy |
snforacle.interface.hermite_normal_form ¶
Compute the row Hermite Normal Form of an integer matrix.
The Hermite Normal Form is the unique upper-triangular matrix H with positive pivots (smallest to largest) satisfying H = U·M for some unimodular integer matrix U.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Any
|
The input matrix as a |
required |
backend
|
_IntBackend | None
|
Name of the backend to use. Default is |
None
|
Returns:
| Type | Description |
|---|---|
HNFResult
|
A Pydantic model with field:
|
snforacle.interface.hermite_normal_form_with_transform ¶
hermite_normal_form_with_transform(
matrix: Any, backend: _IntBackend | None = None
) -> HNFWithTransformResult
Compute the row Hermite Normal Form together with the left unimodular transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Any
|
The input matrix (same accepted types as :func: |
required |
backend
|
_IntBackend | None
|
Name of the backend to use. Default is |
None
|
Returns:
| Type | Description |
|---|---|
HNFWithTransformResult
|
A Pydantic model with fields:
The matrices satisfy |
snforacle.interface.elementary_divisors ¶
Compute the non-zero invariant factors (elementary divisors) of an integer matrix.
These are the diagonal entries of the Smith normal form, returned in non-decreasing order. They may be computed via a potentially faster dedicated path than the full SNF computation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Any
|
The input matrix (same accepted types as :func: |
required |
backend
|
_IntBackend | None
|
Name of the backend to use. Default is |
None
|
Returns:
| Type | Description |
|---|---|
ElementaryDivisorsResult
|
A Pydantic model with field:
|
Input models¶
snforacle.schema.DenseIntMatrix ¶
Bases: BaseModel
An integer matrix stored as a full list of rows.
snforacle.schema.SparseIntMatrix ¶
Bases: BaseModel
An integer matrix stored as a list of (row, col, value) triples.
Entries not listed are implicitly zero. Duplicate (row, col) pairs are
not allowed; the last value wins only if allow_duplicates is True
(default: False).
snforacle.schema.SparseEntry ¶
Bases: BaseModel
A single nonzero entry in a sparse integer matrix.
Output models¶
snforacle.schema.SNFResult ¶
Bases: BaseModel
The Smith normal form of an integer matrix.
smith_normal_form is always returned as a dense matrix whose
diagonal contains the invariant factors d₁ | d₂ | … | dᵣ (in
non-decreasing order) and whose off-diagonal entries are zero.
invariant_factors is the same sequence as the diagonal, listed
without the surrounding zero rows/columns.
snforacle.schema.SNFWithTransformsResult ¶
Bases: BaseModel
The Smith normal form together with unimodular transformation matrices.
Let M be the input matrix. The matrices satisfy::
left_transform · M · right_transform = smith_normal_form
All three matrices are returned as dense integer matrices.
snforacle.schema.HNFResult ¶
Bases: BaseModel
Row Hermite Normal Form of an integer matrix.
The Hermite Normal Form is the unique upper-triangular matrix H with positive pivots (smallest to largest) satisfying H = U·M for some unimodular integer matrix U.
snforacle.schema.HNFWithTransformResult ¶
Bases: BaseModel
Row Hermite Normal Form together with the left unimodular transform.
Let M be the input matrix. The matrices satisfy::
left_transform · M = hermite_normal_form
Both matrices are returned as dense integer matrices.
snforacle.schema.ElementaryDivisorsResult ¶
Bases: BaseModel
Non-zero invariant factors of an integer matrix.
These are the same values as the diagonal of the Smith normal form, returned in non-decreasing order. They can be computed via a potentially faster dedicated path than the full SNF computation.