shh.csparse
Class DenseMatrixZ

Object
  extended byMatrix
      extended byDenseMatrixZ
All Implemented Interfaces:
Cloneable

public class DenseMatrixZ
extends Matrix
implements Cloneable

Matrices over Z using BigIntegers, implemented as m × n arrays in a straightforward way. In addition to the basic methods, the LLL algorithm is available at doLLL().

Author:
Mark McConnell

Field Summary
protected  BigInteger[][] a
          Holds the entries.
 
Constructor Summary
DenseMatrixZ(int n)
          Constructs an n × n identity matrix.
DenseMatrixZ(int m, int n)
          Constructs an m × n zero matrix.
 
Method Summary
 Matrix add(Matrix b0)
          Adds this and another DenseMatrixZ, returning a DenseMatrixZ.
 Object clone()
           
 int doLLL()
          Does LLL reduction on the columns, destructively, using Cohen, Algorithm 2.7.2 (see reference in NumThy).
 SparseElt get(int i, int j)
          Returns a SparseElt whose value is the i,j value of the matrix.
 int getNumCols()
          Returns the number n of columns.
 int getNumRows()
          Returns the number m of rows.
 Matrix inverse()
          Unsupported.
 boolean isIdentity()
          Whether this is an n × n identity matrix.
 boolean isProductZero(Matrix b0)
          Silly implementation that stores the entire product.
 boolean isZero()
          Whether every entry in this matrix is zero.
static void main(String[] args)
          Tests doLLL().
 Matrix mult(Matrix b0)
          Non-destructive if b0 is a CSparse or DenseMatrixZ, destructive to this if b0 is an ElemMatrix.
 void set(int i, int j, BigInteger val)
          Easier to use in this class than set(SparseElt, int).
 void set(SparseElt rowIndexAndVal, int colIndex)
          Set method.
 Matrix transpose()
          Non-destructive.
 
Methods inherited from class Matrix
toString
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

a

protected final BigInteger[][] a
Holds the entries.

Constructor Detail

DenseMatrixZ

public DenseMatrixZ(int m,
                    int n)
Constructs an m × n zero matrix.


DenseMatrixZ

public DenseMatrixZ(int n)
Constructs an n × n identity matrix.

Method Detail

add

public Matrix add(Matrix b0)
Adds this and another DenseMatrixZ, returning a DenseMatrixZ. Does not support other classes of b0. Non-destructive.

Specified by:
add in class Matrix
Throws:
IllegalArgumentException - If the dimensions don't match.

get

public SparseElt get(int i,
                     int j)
Description copied from class: Matrix
Returns a SparseElt whose value is the i,j value of the matrix. May return null for a zero entry. The index of the SparseElt is unspecified--there is no guarantee it is either i or j.

Specified by:
get in class Matrix

getNumCols

public int getNumCols()
Description copied from class: Matrix
Returns the number n of columns.

Specified by:
getNumCols in class Matrix

getNumRows

public int getNumRows()
Description copied from class: Matrix
Returns the number m of rows.

Specified by:
getNumRows in class Matrix

inverse

public Matrix inverse()
Unsupported.

Specified by:
inverse in class Matrix

isIdentity

public boolean isIdentity()
Description copied from class: Matrix
Whether this is an n × n identity matrix.

Specified by:
isIdentity in class Matrix

isZero

public boolean isZero()
Description copied from class: Matrix
Whether every entry in this matrix is zero.

Specified by:
isZero in class Matrix

mult

public Matrix mult(Matrix b0)
Non-destructive if b0 is a CSparse or DenseMatrixZ, destructive to this if b0 is an ElemMatrix.

Specified by:
mult in class Matrix
Throws:
IllegalArgumentException - If the inner dimensions don't match.
ClassCastException - If not all entries of b0 are over Z (i.e., of class SparseEltZ).

isProductZero

public boolean isProductZero(Matrix b0)
Silly implementation that stores the entire product. Unsupported unless b0 is of class CSparse or DenseMatrixZ.

Specified by:
isProductZero in class Matrix

set

public void set(SparseElt rowIndexAndVal,
                int colIndex)
Set method.

Specified by:
set in class Matrix
Throws:
ClassCastException - If the first argument isn't a SparseEltZ.

set

public final void set(int i,
                      int j,
                      BigInteger val)
Easier to use in this class than set(SparseElt, int).


transpose

public Matrix transpose()
Description copied from class: Matrix
Non-destructive.

Specified by:
transpose in class Matrix

clone

public Object clone()

doLLL

public int doLLL()
Does LLL reduction on the columns, destructively, using Cohen, Algorithm 2.7.2 (see reference in NumThy).

Returns:
kerdim = the dim of the kernel. The columns j ≥ kerdim are a Q-basis (and I think in fact a Z-basis) of the lattice generated by the columns of the original matrix.

main

public static void main(String[] args)
Tests doLLL(). Input: m n entry0 entry1 entry2, and so on. The entries are placed in a matrix in row-major order, repeating if necessary.