Dom::SparseMatrixF2 --
the domain of sparse matrices over the field with two elements
IntroductionDom::SparseMatrixF2 represents the set of all matrices
over the finite field with two elements.
DomainDom::SparseMatrixF2()
DetailsDom::SparseMatrixF2 is mathematically equivalent to
Dom::Matrix(Dom::IntegerMod(2)).
However, the internal representation guarantees that both storage and
computing time required for the arithmetical operations depend on the
number of nonzero entries. Therefore, Dom::SparseMatrixF2
should be used for matrices with few nonzero entries.
IntroductionDom::SparseMatrixF2(m, n, [s1, ..., sm])
creates the m times n matrix
(aij) such that, for each i, the set
of all j with aij=1 equals the set (or
list) si.
Creating
ElementsDom::SparseMatrixF2(m, n, [s1...])
Dom::SparseMatrixF2(m, n, f)
Parametersm, n |
- | positive integers |
s1... |
- | sets or lists of integers between 1 and
n |
f |
- | a procedure or another object that, when called with
an integer between 1 and m and another integer
between 1 and n, returns an element of Dom::IntegerMod(2). |
Cat::Matrix(Dom::IntegerMod(2))
Related
DomainsThe coefficient ring always equals
Dom::IntegerMod(2).
This entry is always set to TRUE.
zeroMatrix(integer m, integer n)_plus(dom A...)_plus._negate(dom A)A is just A itself._negate.matrixvectorproduct(dom A, dom b)A and
the column vector b; the number of columns of
A must be the same as the number of rows of
b._mult(dom A, dom
b)"matrixvectorproduct"._mult.The product of arbitrary sparse matrices (where
b is not a vector) has not been implemented.
randmatrix(integer m, integer n <integer s>)s is not given, it defaults
to 6.nrows(dom A)A.ncols(dom A)A.dimen(dom A)A.body(dom A)row(dom A, integer
i)A as a 1 times
n matrix of type Dom::SparseMatrixF2.col(dom A, integer
i)A as a row vector, i.e.
as a 1 times m matrix of type
Dom::SparseMatrixF2._index(dom A, integer
i)A._index operator; A[i]
may be entered equivalently._index(dom A, integer
i, integer j)A in the i-th row,
j-th column.A[i,j] may be entered.set_index(dom A, integer i, integer j, value v)A, with the result of
converting v into an element of Dom::IntegerMod(2)
entered in the i-th row, j-th column. Dom::IntegerMod(2)
must be able to convert v into a field element.A[i,j]:=v. In this case, the value of the identifier or
local variable A is changed as a side effect;
v (but not the result of converting it to a field
element!) is returned.
If the assignment stops with an error, the domain
element stored in A is destroyed, and the new value of
A is FAIL.
_assign for
more information about indexed assignments.convert_to(dom A, any
T)A into type
T. Currently only a conversion into a Dom::Matrix(Dom::IntegerMod(2))
is possible.
Example
1We create a sparse matrix with three nonzero entries:
>> A:=Dom::SparseMatrixF2(3, 3, [{2}, {1}, {3}])
[{2}, {1}, {3}]
Conversion to a Dom::Matrix yields a nicer output, but
now nine entries have to be stored:
>> A::dom::convert_to(A, Dom::Matrix(Dom::IntegerMod(2)))
+- -+
| 0 mod 2, 1 mod 2, 0 mod 2 |
| |
| 1 mod 2, 0 mod 2, 0 mod 2 |
| |
| 0 mod 2, 0 mod 2, 1 mod 2 |
+- -+
Super-DomainAx::canonicalRep