org.rubato.math.matrix
Class ZnMatrix

java.lang.Object
  extended by org.rubato.math.matrix.Matrix
      extended by org.rubato.math.matrix.ZnMatrix
All Implemented Interfaces:
java.lang.Comparable<Matrix>

public final class ZnMatrix
extends Matrix

Matrixes over modular integers.


Constructor Summary
ZnMatrix(int[][] c, int modulus)
          Creates a mxn integer mod modulus matrix from the 2-dimensional array c of integers.
ZnMatrix(int[] v, int modulus)
          Creates a nx1 integer modular modulus matrix from the vector v, where n is the length of v.
ZnMatrix(int rows, int cols, int modulus)
          Creates an integer mod modulus rows x cols matrix with all coefficients set to 0.
ZnMatrix(int rows, int cols, int modulus, int value)
          Creates an integer mod modulus rows x cols matrix with all coefficients set to value.
ZnMatrix(ZMatrix m, int modulus)
          Creates an integer mod modulus copy of the integer matrix m.
ZnMatrix(ZnMatrix m)
          Creates a copy of the modular integer matrix m.
ZnMatrix(ZnMatrix m, int modulus)
          Creates an integer mod modulus copy of the modular integer matrix m.
 
Method Summary
 ZnMatrix adjoint()
           
 ZnMatrix affineDifference()
           
 int compareTo(Matrix object)
          Compares this matrix to object.
 void computeRREF()
          Compute the reducted row echelon form of this matrix.
 int determinant()
           
 ZnMatrix difference(ZnMatrix m)
           
 int dotProduct(ZnMatrix m)
           
 boolean equals(java.lang.Object object)
           
 int euclidean()
          Returns the Euclidean norm of this matrix.
 int get(int row, int col)
          Returns the value at index row,col.
 ZnMatrix getMinorMatrix(int row, int col)
           
 int getModulus()
          Returns the modulus of the coefficient modular integer ring.
 ZnMatrix getSubMatrix(int fromRow, int toRow, int fromCol, int toCol)
           
static ZnMatrix getUnitMatrix(int size, int modulus)
          Returns the unit integer mod modulus matrix of the given size.
 ZnMatrix inverse()
           
 boolean isConstant()
          Returns true iff the coefficients of this matrix are equal to a constant value.
 boolean isOne(int row, int col)
          Returns true iff the coefficient at row,col is one.
 boolean isRegular()
          Returns true iff this matrix is regular.
 boolean isUnit()
          Returns true iff this is a unit matrix.
 boolean isZero()
          Returns true iff this is a zero matrix.
 boolean isZero(int row, int col)
          Returns true iff the coefficient at row,col is zero.
 int minor(int row, int col)
          Returns the minor at row,col.
 ZnMatrix power(int exponent)
           
 int[] product(int[] vector)
           
 ZnMatrix product(ZnMatrix m)
           
 ZnMatrix quadraticForm()
           
 int rank()
          Returns the rank of this matrix.
 ZnMatrix scaled(int scalar)
           
 void set(int row, int col, int value)
          Sets index row,col to value.
 void setColumnCount(int cols)
          Resizes this matrix by changing the number of columns.
 void setRowCount(int rows)
          Resizes this matrix by changing the number of rows.
 void setSubMatrix(int row, int col, ZnMatrix m)
           
 void setToElementaryMatrix(int value)
          Sets all values of this matrix to value.
 void setToOne(int row, int col)
          Sets the coefficient at row,col to one.
 void setToUnitMatrix()
          Makes this matrix unit square.
 void setToZero(int row, int col)
          Sets the coefficient at row,col to zero.
 void setToZeroMatrix()
          Sets all coefficients to zero.
 int sum()
          Returns the 1-norm of this matrix.
 ZnMatrix sum(ZnMatrix m)
           
 ZnMatrix taylor(int exponent)
           
 java.lang.String toString()
          Returns a string representation of this matrix.
 ZnMatrix transposed()
           
 
Methods inherited from class org.rubato.math.matrix.Matrix
getColumnCount, getRowCount, isSquare, isZeroColumn, isZeroRow, productPossible, productPossible, sameSize, sameSize
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZnMatrix

public ZnMatrix(int rows,
                int cols,
                int modulus)
Creates an integer mod modulus rows x cols matrix with all coefficients set to 0.


ZnMatrix

public ZnMatrix(int rows,
                int cols,
                int modulus,
                int value)
Creates an integer mod modulus rows x cols matrix with all coefficients set to value.


ZnMatrix

public ZnMatrix(ZnMatrix m)
Creates a copy of the modular integer matrix m.


ZnMatrix

public ZnMatrix(ZMatrix m,
                int modulus)
Creates an integer mod modulus copy of the integer matrix m.


ZnMatrix

public ZnMatrix(ZnMatrix m,
                int modulus)
Creates an integer mod modulus copy of the modular integer matrix m.


ZnMatrix

public ZnMatrix(int[] v,
                int modulus)
Creates a nx1 integer modular modulus matrix from the vector v, where n is the length of v.


ZnMatrix

public ZnMatrix(int[][] c,
                int modulus)
Creates a mxn integer mod modulus matrix from the 2-dimensional array c of integers.

Method Detail

getModulus

public int getModulus()
Returns the modulus of the coefficient modular integer ring.


getUnitMatrix

public static ZnMatrix getUnitMatrix(int size,
                                     int modulus)
Returns the unit integer mod modulus matrix of the given size.


get

public int get(int row,
               int col)
Returns the value at index row,col.


set

public void set(int row,
                int col,
                int value)
Sets index row,col to value.


setToZero

public void setToZero(int row,
                      int col)
Description copied from class: Matrix
Sets the coefficient at row,col to zero.

Specified by:
setToZero in class Matrix

setToOne

public void setToOne(int row,
                     int col)
Description copied from class: Matrix
Sets the coefficient at row,col to one.

Specified by:
setToOne in class Matrix

setRowCount

public void setRowCount(int rows)
Description copied from class: Matrix
Resizes this matrix by changing the number of rows. If new rows are created, their values are set to 0.

Specified by:
setRowCount in class Matrix

setColumnCount

public void setColumnCount(int cols)
Description copied from class: Matrix
Resizes this matrix by changing the number of columns. If new columns are created, the new coefficients are all set to zero.

Specified by:
setColumnCount in class Matrix

setToZeroMatrix

public void setToZeroMatrix()
Description copied from class: Matrix
Sets all coefficients to zero.

Specified by:
setToZeroMatrix in class Matrix

setToUnitMatrix

public void setToUnitMatrix()
Description copied from class: Matrix
Makes this matrix unit square. If necessary, the matrix is resized, its final size being the larger of the number of rows and the number of columns.

Specified by:
setToUnitMatrix in class Matrix

setToElementaryMatrix

public void setToElementaryMatrix(int value)
Sets all values of this matrix to value.


getSubMatrix

public ZnMatrix getSubMatrix(int fromRow,
                             int toRow,
                             int fromCol,
                             int toCol)

getMinorMatrix

public ZnMatrix getMinorMatrix(int row,
                               int col)

transposed

public ZnMatrix transposed()

inverse

public ZnMatrix inverse()

adjoint

public ZnMatrix adjoint()

affineDifference

public ZnMatrix affineDifference()

quadraticForm

public ZnMatrix quadraticForm()

scaled

public ZnMatrix scaled(int scalar)

power

public ZnMatrix power(int exponent)

taylor

public ZnMatrix taylor(int exponent)

rank

public int rank()
Description copied from class: Matrix
Returns the rank of this matrix.

Specified by:
rank in class Matrix

isConstant

public boolean isConstant()
Description copied from class: Matrix
Returns true iff the coefficients of this matrix are equal to a constant value.

Specified by:
isConstant in class Matrix

isZero

public boolean isZero()
Description copied from class: Matrix
Returns true iff this is a zero matrix.

Specified by:
isZero in class Matrix

isUnit

public boolean isUnit()
Description copied from class: Matrix
Returns true iff this is a unit matrix.

Specified by:
isUnit in class Matrix

isRegular

public boolean isRegular()
Description copied from class: Matrix
Returns true iff this matrix is regular.

Specified by:
isRegular in class Matrix

isZero

public boolean isZero(int row,
                      int col)
Description copied from class: Matrix
Returns true iff the coefficient at row,col is zero.

Specified by:
isZero in class Matrix

isOne

public boolean isOne(int row,
                     int col)
Description copied from class: Matrix
Returns true iff the coefficient at row,col is one.

Specified by:
isOne in class Matrix

dotProduct

public int dotProduct(ZnMatrix m)

equals

public boolean equals(java.lang.Object object)
Specified by:
equals in class Matrix

compareTo

public int compareTo(Matrix object)
Description copied from class: Matrix
Compares this matrix to object. If object is a matrix, but not of the same type, then the strings representation are compared.

Specified by:
compareTo in interface java.lang.Comparable<Matrix>
Overrides:
compareTo in class Matrix

setSubMatrix

public void setSubMatrix(int row,
                         int col,
                         ZnMatrix m)

computeRREF

public void computeRREF()
Compute the reducted row echelon form of this matrix. This operation is destructive, i.e., the contents are replaced.


sum

public ZnMatrix sum(ZnMatrix m)

difference

public ZnMatrix difference(ZnMatrix m)

product

public ZnMatrix product(ZnMatrix m)

product

public int[] product(int[] vector)

determinant

public int determinant()

minor

public int minor(int row,
                 int col)
Returns the minor at row,col.


euclidean

public int euclidean()
Returns the Euclidean norm of this matrix.


sum

public int sum()
Returns the 1-norm of this matrix.


toString

public java.lang.String toString()
Description copied from class: Matrix
Returns a string representation of this matrix.

Specified by:
toString in class Matrix