shh.csparse
Class Matrix

Object
  extended byMatrix
Direct Known Subclasses:
CSparse, DenseMatrixZ, ElemMatrix

public abstract class Matrix
extends Object

A general interface for m × n matrices.

The interface specifies whether operations are destructive--whether they alter this matrix or any of their arguments. Consult the individual implementations for whether a method is supported, whether it checks for errors in its arguments, or whether null can be a return value.

Vectors are thought of as column vectors throughout. If the vector space V has dimension n and W has dimension m, then a map V → W is represented by an m × n matrix A. If x is an n-dimensional column vector giving a point of V with respect to standard coordinates, then the coordinates of its image are given by the m-dimensional column vector Ax.

Author:
Mark McConnell

Constructor Summary
Matrix()
           
 
Method Summary
abstract  Matrix add(Matrix b)
          The sum of two matrices.
abstract  SparseElt get(int i, int j)
          Returns a SparseElt whose value is the i,j value of the matrix.
abstract  int getNumCols()
          Returns the number n of columns.
abstract  int getNumRows()
          Returns the number m of rows.
abstract  Matrix inverse()
          Check the implementation for whether it's supported, and whether it's destructive.
abstract  boolean isIdentity()
          Whether this is an n × n identity matrix.
abstract  boolean isProductZero(Matrix b)
          Says whether this * b is zero, without storing the product.
abstract  boolean isZero()
          Whether every entry in this matrix is zero.
abstract  Matrix mult(Matrix b)
          Returns this * b.
abstract  void set(SparseElt rowIndexAndVal, int colIndex)
          Check the implementation for whether it throws an UnsupportedOperationException.
 String toString()
          Formats the matrix with each column left-justified.
abstract  Matrix transpose()
          Non-destructive.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix

public Matrix()
Method Detail

add

public abstract Matrix add(Matrix b)
The sum of two matrices. Non-destructive.

Throws:
IllegalArgumentException - If the dimensions don't match.

get

public abstract SparseElt get(int i,
                              int j)
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.


getNumCols

public abstract int getNumCols()
Returns the number n of columns.


getNumRows

public abstract int getNumRows()
Returns the number m of rows.


inverse

public abstract Matrix inverse()
Check the implementation for whether it's supported, and whether it's destructive.


isIdentity

public abstract boolean isIdentity()
Whether this is an n × n identity matrix.


isProductZero

public abstract boolean isProductZero(Matrix b)
Says whether this * b is zero, without storing the product. Is not destructive.


isZero

public abstract boolean isZero()
Whether every entry in this matrix is zero.


mult

public abstract Matrix mult(Matrix b)
Returns this * b. Check the implementation for whether it's destructive.

Throws:
UnsupportedOperationException - If there is no implementation for multiplying the class of this by the class of b.
IllegalArgumentException - The implementation may (or may not) throw this if the inner dimensions don't match.

set

public abstract void set(SparseElt rowIndexAndVal,
                         int colIndex)
Check the implementation for whether it throws an UnsupportedOperationException.


toString

public String toString()
Formats the matrix with each column left-justified.


transpose

public abstract Matrix transpose()
Non-destructive.