Finite-Field Matrix API¶
Functions for matrices whose entries are elements of F_p (integers mod a prime p).
Over a field every nonzero element is a unit, so:
- The SNF is always
diag(1, ..., 1, 0, ..., 0)where the number of 1s equals the rank. - The HNF is the unique reduced row echelon form (RREF).
Functions¶
snforacle.ff_interface.ff_smith_normal_form ¶
Compute the Smith normal form of a matrix over F_p.
Over a finite field every nonzero element is a unit, so the SNF is
always diag(1, ..., 1, 0, ..., 0) where the number of 1s equals
the rank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Any
|
The input matrix as a |
required |
backend
|
_FFBackend | None
|
Name of the backend to use: |
None
|
Returns:
| Type | Description |
|---|---|
FFSNFResult
|
A Pydantic model with fields:
|
snforacle.ff_interface.ff_smith_normal_form_with_transforms ¶
ff_smith_normal_form_with_transforms(
matrix: Any, backend: _FFBackend | None = None
) -> FFSNFWithTransformsResult
Compute the SNF together with invertible left and right transforms over F_p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Any
|
The input matrix (same accepted types as :func: |
required |
backend
|
_FFBackend | None
|
Name of the backend to use. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
FFSNFWithTransformsResult
|
A Pydantic model with fields:
Satisfies: |
snforacle.ff_interface.ff_hermite_normal_form ¶
Compute the row Hermite Normal Form of a matrix over F_p.
Over a finite field the HNF is the unique reduced row echelon form (RREF): upper-staircase with leading 1 in each nonzero row, and all other entries in each pivot column equal to 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Any
|
The input matrix (same accepted types as :func: |
required |
backend
|
_FFBackend | None
|
Name of the backend to use. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
FFHNFResult
|
A Pydantic model with field:
|
snforacle.ff_interface.ff_hermite_normal_form_with_transform ¶
ff_hermite_normal_form_with_transform(
matrix: Any, backend: _FFBackend | None = None
) -> FFHNFWithTransformResult
Compute the row HNF together with the left invertible transform over F_p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Any
|
The input matrix (same accepted types as :func: |
required |
backend
|
_FFBackend | None
|
Name of the backend to use. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
FFHNFWithTransformResult
|
A Pydantic model with fields:
Satisfies: |
snforacle.ff_interface.ff_rank ¶
Compute the rank of a matrix over F_p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Any
|
The input matrix (same accepted types as :func: |
required |
backend
|
_FFBackend | None
|
Name of the backend to use. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
FFRankResult
|
A Pydantic model with field:
|
Input models¶
snforacle.ff_schema.DenseFFMatrix ¶
Bases: BaseModel
A matrix over F_p stored as a full list of rows.
Each entry is an integer in [0, p-1].
snforacle.ff_schema.SparseFFMatrix ¶
Bases: BaseModel
A matrix over F_p stored as (row, col, value) triples.
Entries not listed are implicitly zero. Listed entries must be nonzero
(value in [1, p-1]). Duplicate (row, col) pairs are not allowed.
Output models¶
snforacle.ff_schema.FFSNFResult ¶
Bases: BaseModel
The Smith normal form of a matrix over F_p.
Over a field, every nonzero element is a unit, so invariant factors are
either 1 (nonzero) or 0. The SNF is diag(1, ..., 1, 0, ..., 0)
where the number of 1s equals the rank.
smith_normal_form has 1s at positions (0,0), ..., (r-1,r-1) and 0s
elsewhere. rank gives r directly.
snforacle.ff_schema.FFSNFWithTransformsResult ¶
Bases: BaseModel
The SNF together with invertible left and right transforms over F_p.
Satisfies: left_transform @ M @ right_transform = smith_normal_form.
All matrices have entries in [0, p-1].
snforacle.ff_schema.FFHNFResult ¶
Bases: BaseModel
Row Hermite Normal Form of a matrix over F_p.
Over a field the HNF is the unique reduced row echelon form (RREF): upper-staircase structure with leading 1 in each nonzero row, and all other entries in each pivot column equal to 0.
snforacle.ff_schema.FFHNFWithTransformResult ¶
Bases: BaseModel
Row HNF together with the left invertible transform over F_p.
Satisfies: left_transform @ M = hermite_normal_form.
snforacle.ff_schema.FFRankResult ¶
Bases: BaseModel
The rank of a matrix over F_p.