org.rubato.math.matrix
Class ZMatrix

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

public final class ZMatrix
extends Matrix

Matrixes over integers.


Constructor Summary
ZMatrix(int[] v)
          Creates a nx1 integer matrix from the vector v, where n is the length of v.
ZMatrix(int[][] c)
          Creates a mxn integer matrix from the 2-dimensional array c of integers.
ZMatrix(int rows, int cols)
          Creates an integer rows x cols matrix with all coefficients set to 0.
ZMatrix(int rows, int cols, int value)
          Creates an integer rows x cols matrix with all coefficients set to value.
ZMatrix(ZMatrix m)
          Creates a copy of the integer matrix m.
ZMatrix(ZnMatrix m)
          Creates an integer copy of the modular integer matrix m.
 
Method Summary
 ZMatrix adjoint()
           
 ZMatrix affineDifference()
           
 int compareTo(Matrix object)
          Compares this matrix to object.
 int determinant()
           
 ZMatrix difference(ZMatrix m)
           
 int dotProduct(ZMatrix 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.
 ZMatrix getMinorMatrix(int row, int col)
           
 ZMatrix getSubMatrix(int fromRow, int toRow, int fromCol, int toCol)
           
static ZMatrix getUnitMatrix(int size)
          Returns the unit integer matrix of the given size.
 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.
 ZMatrix power(int exponent)
           
 int[] product(int[] vector)
           
 ZMatrix product(ZMatrix m)
           
 ZMatrix quadraticForm()
           
 int rank()
          Returns the rank of this matrix.
 ZMatrix 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, ZMatrix 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.
 ZMatrix sum(ZMatrix m)
           
 java.lang.String toString()
          Returns a string representation of this matrix.
 ZMatrix 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

ZMatrix

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


ZMatrix

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


ZMatrix

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


ZMatrix

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


ZMatrix

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


ZMatrix

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

Method Detail

getUnitMatrix

public static ZMatrix getUnitMatrix(int size)
Returns the unit integer 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.


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

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

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 ZMatrix getSubMatrix(int fromRow,
                            int toRow,
                            int fromCol,
                            int toCol)

getMinorMatrix

public ZMatrix getMinorMatrix(int row,
                              int col)

transposed

public ZMatrix transposed()

adjoint

public ZMatrix adjoint()

affineDifference

public ZMatrix affineDifference()

quadraticForm

public ZMatrix quadraticForm()

scaled

public ZMatrix scaled(int scalar)

power

public ZMatrix power(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(ZMatrix 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,
                         ZMatrix m)

sum

public ZMatrix sum(ZMatrix m)

difference

public ZMatrix difference(ZMatrix m)

product

public ZMatrix product(ZMatrix 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