org.rubato.math.matrix
Class Matrix

java.lang.Object
  extended by org.rubato.math.matrix.Matrix
All Implemented Interfaces:
java.lang.Comparable<Matrix>
Direct Known Subclasses:
CMatrix, QMatrix, RMatrix, ZMatrix, ZnMatrix

public abstract class Matrix
extends java.lang.Object
implements java.lang.Comparable<Matrix>

Abstract base class for matrixes. Contains only some common methods that are independent of the underlying ring.

Author:
Gérard Milmeister

Method Summary
 int compareTo(Matrix object)
          Compares this matrix to object.
abstract  boolean equals(java.lang.Object object)
           
 int getColumnCount()
          Returns the number of columns of this matrix.
 int getRowCount()
          Returns the number of rows of this matrix.
abstract  boolean isConstant()
          Returns true iff the coefficients of this matrix are equal to a constant value.
abstract  boolean isOne(int row, int col)
          Returns true iff the coefficient at row,col is one.
abstract  boolean isRegular()
          Returns true iff this matrix is regular.
 boolean isSquare()
          Returns true iff this is a square matrix.
abstract  boolean isUnit()
          Returns true iff this is a unit matrix.
abstract  boolean isZero()
          Returns true iff this is a zero matrix.
abstract  boolean isZero(int row, int col)
          Returns true iff the coefficient at row,col is zero.
 boolean isZeroColumn(int c)
          Returns true iff column c is zero.
 boolean isZeroRow(int r)
          Returns true iff row r is zero.
 boolean productPossible(Matrix m)
          Returns true iff the product of this matrix and m is possible.
static boolean productPossible(Matrix m1, Matrix m2)
          Returns true iff the product of m1 and m2 is possible.
abstract  int rank()
          Returns the rank of this matrix.
 boolean sameSize(Matrix m)
          Returns true iff this matrix and m have the same size.
static boolean sameSize(Matrix m1, Matrix m2)
          Returns true iff m1 and m2 have the same size.
abstract  void setColumnCount(int cols)
          Resizes this matrix by changing the number of columns.
abstract  void setRowCount(int rows)
          Resizes this matrix by changing the number of rows.
abstract  void setToOne(int row, int col)
          Sets the coefficient at row,col to one.
abstract  void setToUnitMatrix()
          Makes this matrix unit square.
abstract  void setToZero(int row, int col)
          Sets the coefficient at row,col to zero.
abstract  void setToZeroMatrix()
          Sets all coefficients to zero.
abstract  java.lang.String toString()
          Returns a string representation of this matrix.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getRowCount

public final int getRowCount()
Returns the number of rows of this matrix.


setRowCount

public abstract void setRowCount(int rows)
Resizes this matrix by changing the number of rows. If new rows are created, their values are set to 0.


getColumnCount

public final int getColumnCount()
Returns the number of columns of this matrix.


setColumnCount

public abstract void setColumnCount(int cols)
Resizes this matrix by changing the number of columns. If new columns are created, the new coefficients are all set to zero.


setToZeroMatrix

public abstract void setToZeroMatrix()
Sets all coefficients to zero.


setToZero

public abstract void setToZero(int row,
                               int col)
Sets the coefficient at row,col to zero.


setToOne

public abstract void setToOne(int row,
                              int col)
Sets the coefficient at row,col to one.


setToUnitMatrix

public abstract void setToUnitMatrix()
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.


rank

public abstract int rank()
Returns the rank of this matrix.


isConstant

public abstract boolean isConstant()
Returns true iff the coefficients of this matrix are equal to a constant value.


isZero

public abstract boolean isZero()
Returns true iff this is a zero matrix.


isUnit

public abstract boolean isUnit()
Returns true iff this is a unit matrix.


isSquare

public final boolean isSquare()
Returns true iff this is a square matrix.


isRegular

public abstract boolean isRegular()
Returns true iff this matrix is regular.


isZero

public abstract boolean isZero(int row,
                               int col)
Returns true iff the coefficient at row,col is zero.


isOne

public abstract boolean isOne(int row,
                              int col)
Returns true iff the coefficient at row,col is one.


isZeroRow

public boolean isZeroRow(int r)
Returns true iff row r is zero.


isZeroColumn

public boolean isZeroColumn(int c)
Returns true iff column c is zero.


sameSize

public final boolean sameSize(Matrix m)
Returns true iff this matrix and m have the same size.


sameSize

public static final boolean sameSize(Matrix m1,
                                     Matrix m2)
Returns true iff m1 and m2 have the same size.


productPossible

public final boolean productPossible(Matrix m)
Returns true iff the product of this matrix and m is possible.


productPossible

public static final boolean productPossible(Matrix m1,
                                            Matrix m2)
Returns true iff the product of m1 and m2 is possible.


toString

public abstract java.lang.String toString()
Returns a string representation of this matrix.

Overrides:
toString in class java.lang.Object

equals

public abstract boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(Matrix object)
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>