9.2.1.2 mat_ZZ_class Objects

class mat_ZZ_class
The mat_ZZ class implements arithmetic with matrices over $ \mathbf{Z}$ .
Instances of class mat_ZZ_class have the following methods (in addition to inherited methods and special methods):

charpoly,$  $ determinant,$  $ HNF,$  $ ncols,$  $ nrows

These methods are defined as follows:

charpoly( )

determinant( )

HNF( )

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

Nonetheless, NTL is superior to PARI, which can't even do a 100x100 HNF at all, as far as I can tell.

ncols( )

nrows( )

See About this document... for information on suggesting changes.