charpoly,
determinant,
HNF,
ncols,
nrows
Further documentation:
) |
The input matrix A=self is an n x m matrix of rank m (so n >= m), and D is a multiple of the determinant of the lattice L spanned by the rows of A. The output W is the Hermite Normal Form of A; that is, W is the unique m x m matrix whose rows span L, such that
- W is lower triangular, - the diagonal entries are positive, - any entry below the diagonal is a non-negative number strictly less than the diagonal entry in its column.
This is implemented using the algorithm of [P. Domich, R. Kannan and L. Trotter, Math. Oper. Research 12:50-59, 1987].
TIMINGS: NTL isn't very good compared to MAGMA, unfortunately:
sage: import ntl sage: a=MatrixSpace(Q,200).random_element() # -2 to 2 sage: A=ntl.mat_ZZ(200,200) sage: for i in xrange(a.nrows()): ....: for j in xrange(a.ncols()): ....: A[i,j] = a[i,j] ....: sage: time d=A.determinant() Time.: 3.89 seconds sage: time B=A.HNF(d) Time.: 27.59 seconds
In comparison, MAGMA does this much more quickly:
> A := MatrixAlgebra(Z,200)![Random(-2,2) : i in [1..200^2]]; > time d := Determinant(A); Time: 0.710 > time H := HermiteForm(A); Time: 3.080
Also, PARI is also faster than NTL if one uses the flag 1 to the mathnf routine. The above takes 16 seconds in PARI.
Instances of class mat_ZZ_class also have the following special methods:
__add__,
__delitem__,
__getitem__,
__mul__,
__pow__,
__radd__,
__repr__,
__rmul__,
__rpow__,
__rsub__,
__setitem__,
__sub__
See About this document... for information on suggesting changes.