q1ss.ap.sequence
Affine partitions generated by fixed sequences of matrices.
SeqAP
- final class SeqAP(data)[source]
Bases:
APClass for ordered balanced affine partitions of
n-bitstrings defined by a fixed sequence of invertible matrices for partial labels.- static __new__(cls, data)[source]
Constructs a new affine partition from the given sequences of matrices.
- _get_subspace(label)[source]
Returns the affine subspace corresponding to the given label, providing the underlying logic for
__getitem__.Let
kbe thelabel_dimandnbe theambient_dimfor this generator, so thatn-kis thesubsp_dim.Start from the standard affine subspace spanned by the first
n-kstandard basis vectors. The basepoint is given by a vector which is zero on the firstn-kcomponents, and is the reverse of the label on the remainingkcomponents.Selects a sequence of
k-2inverse matrices from thedata, selecting fromdata.mats0_invanddata.mats1_invbased on the reverse bits of the label, starting from the penultimate and ending at the first. Then appendsdata.start_invas the final matrix in the sequence, which hask-1matrices in total.Transform the standard subspace using the inverse matrices in the sequence, where matrix at index
iacts on the subspace spanned by the firstn-k+1+istd. basis vectors (n-k+1->n).
Uses the
AffineSubspace.transformmethod withpartial=True.- Parameters:
label (
binvec)- Return type:
- _label(vec)[source]
Returns the label of the given vector in this affine partition, providing the underlying logic for
label.Let
kbe thelabel_dimandnbe theambient_dimfor this generator.Start from the given vector.
Applies the
data.startmatrix to the vector (unlesskis 0, in which case the vector is returned unchanged by this method).For each
i in range(k-1), generates a matrix using the bit at positionk-i-1in the vector, selectsmats0[i]ormats1[i]based on its value, and applies the matrix to the firstn-i-1bits of the vector.Returns the last
kbits of the resulting vector, read in reverse.
Note that each matrix application keeps fixed the bits of the vector upon which the matrix itself depended.
SeqAPData
- final class SeqAPData(ambient_dim, start, mats0, mats1, *, copy=False)[source]
Bases:
objectData used to construct a
SeqAPinstance:an ambient vector space dimension \(n\)
an \(n \times n\) invertible
startmatrixtwo sequences
mats0andmats1of \(m\) invertible matrices, where the matrix at index \(j=0,...,m-1\) in each sequence has size \((n-1-j)\times(n-1-j)\)
The inverses to all matrices above can be supplied, or are otherwise computed, and are stored in
start_inv,mats0_inv, andmats1_inv. The subspace dimension for the affine partition is \(n-m-1\).- static __new__(cls, ambient_dim, start, mats0, mats1, *, copy=False)[source]
Creates an empty
SeqAPdata container for given ambient dimension. Each invertible matrix instart,mats0andmats1can be passed as either a single matrix, or a pair of a matrix and its inverse: the inverse is automatically computed in the first case and it is validated in the second case. All matrices are made read-only as part of the constructor: if this is not desirable, thecopyparameter can be set toTrueto make fresh copies of all matrices.
- property as_matrix_gen
Returns the matrix generating function for this data.
- Return type:
- property is_complete
Whether the affine partition data has been completely specified.
- Return type:
- property mats0_inv
Inverses of the
mats0matrices for this affine partition.
- property mats1_inv
Inverses of the
mats1matrices for this affine partition.
- static random(subsp_dim, ambient_dim, *, rng=None)[source]
Creates random
SeqAPdata for given subspace and ambient dimension, usingbinmat.random_invto sample matrix-inverse pairs for all matrices involved.Warning
For moderately large dimensions, this method is computationally intensive. For example,
subsp_dim=128andambient_dim=256takes roughly 20s on a i7-1065G7. This will be optimised in future releases.
SeqAPMatrixGen
- class SeqAPMatrixGen(data)[source]
Bases:
APMatrixGenMatrix generator based on
SeqAPData.- _get_matrix(label)[source]
Generates a (matrix, inverse) pair based on the last bit of the label.
If
labelis empty, returns the pair ofstartand its inverse.If the last bit of
labelis 0, returns the pair ofmats0[k-1]and its inverse, wherek=len(label).If the last bit of
labelis 1, returns the pair ofmats1[k-1]and its inverse, wherek=len(label).