gov.sandia.cognition.math.matrix.mtj
Class SparseColumnMatrix

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.AbstractRing<Matrix>
          extended by gov.sandia.cognition.math.matrix.AbstractMatrix
              extended by gov.sandia.cognition.math.matrix.mtj.AbstractMTJMatrix
                  extended by gov.sandia.cognition.math.matrix.mtj.AbstractSparseMatrix
                      extended by gov.sandia.cognition.math.matrix.mtj.SparseColumnMatrix
All Implemented Interfaces:
Matrix, Vectorizable, Ring<Matrix>, CloneableSerializable, Serializable, Cloneable, Iterable<MatrixEntry>

@CodeReview(reviewer="Justin Basilico",
            date="2006-07-27",
            changesNeeded=false,
            comments="Looks good.")
public class SparseColumnMatrix
extends AbstractSparseMatrix

A sparse matrix, represented as a collection of sparse column vectors. Generally, this is the slowest sparse matrix for premultiplying against a vector.

Since:
1.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Constructor Summary
protected SparseColumnMatrix(no.uib.cipr.matrix.sparse.FlexCompColMatrix internalMatrix)
          Creates a SparseColumnMatrix based on the appropriate MTJ matrix, does NOT create a copy of internalMatrix.
protected SparseColumnMatrix(int numRows, int numColumns)
          Creates a new empty instance of SparseColumnMatrix.
protected SparseColumnMatrix(Matrix matrix)
          Copy constructor for general matrices, copies over nonzero values.
protected SparseColumnMatrix(SparseColumnMatrix matrix)
          Copy constructor for SparseColumnMatrix matrices.
 
Method Summary
 void compact()
          Compact the memory used by the matrix, getting rid of any zero elements
 SparseVector getColumn(int columnIndex)
          Gets the specified column of the matrix, using MTJ's internal routine to speed things up
 no.uib.cipr.matrix.sparse.FlexCompColMatrix getInternalMatrix()
          Gets the internal MTJ matrix that this class is wrapping.
 SparseColumnMatrix getSubMatrix(int minRow, int maxRow, int minColumn, int maxColumn)
          Gets the embedded submatrix inside of the Matrix, specified by the inclusive, zero-based indices such that the result matrix will have size (maxRow-minRow+1) x (maxColum-minCcolumn+1)
 void setColumn(int columnIndex, SparseVector columnVector)
          Sets the column of the matrix using the given SparseVector, using MTJ's internal routine to speed things up
 SparseColumnMatrix times(AbstractMTJMatrix matrix)
          Matrix multiplication of this and matrix, operates like the "*" operator in Matlab
 SparseRowMatrix transpose()
          Returns the transpose of this
 
Methods inherited from class gov.sandia.cognition.math.matrix.mtj.AbstractSparseMatrix
getRow, isSparse, pseudoInverse, setElement, solve, times, toString, toString
 
Methods inherited from class gov.sandia.cognition.math.matrix.mtj.AbstractMTJMatrix
clone, convertFromVector, convertToVector, dotTimesEquals, dotTimesEquals, equals, getElement, getNumColumns, getNumRows, getSubMatrixInto, identity, inverse, isSquare, isSymmetric, iterator, logDeterminant, minusEquals, minusEquals, normFrobenius, plusEquals, plusEquals, rank, scaledMinusEquals, scaledPlusEquals, scaledPlusEquals, scaleEquals, setInternalMatrix, solve, solve, solve, times, times, timesInto, timesInto, transposeInto, zero
 
Methods inherited from class gov.sandia.cognition.math.matrix.AbstractMatrix
assertSameDimensions, checkMultiplicationDimensions, checkSameDimensions, dotDivide, dotDivideEquals, equals, equals, getColumnInto, getRowInto, hashCode, isSymmetric, isZero, pseudoInverse, rank, setColumn, setRow, setSubMatrix, sumOfColumns, sumOfRows, toArray, trace
 
Methods inherited from class gov.sandia.cognition.math.AbstractRing
dotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.math.Ring
dotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus
 

Constructor Detail

SparseColumnMatrix

protected SparseColumnMatrix(int numRows,
                             int numColumns)
Creates a new empty instance of SparseColumnMatrix.

Parameters:
numRows - Number of rows in the matrix.
numColumns - Number of columns in the matrix.

SparseColumnMatrix

protected SparseColumnMatrix(SparseColumnMatrix matrix)
Copy constructor for SparseColumnMatrix matrices.

Parameters:
matrix - Matrix from which to copy the internal MTJ matrix.

SparseColumnMatrix

protected SparseColumnMatrix(Matrix matrix)
Copy constructor for general matrices, copies over nonzero values.

Parameters:
matrix - Matrix from which to copy the nonzero elements into this.

SparseColumnMatrix

protected SparseColumnMatrix(no.uib.cipr.matrix.sparse.FlexCompColMatrix internalMatrix)
Creates a SparseColumnMatrix based on the appropriate MTJ matrix, does NOT create a copy of internalMatrix.

Parameters:
internalMatrix - New internal matrix for this, no copy made.
Method Detail

getInternalMatrix

public no.uib.cipr.matrix.sparse.FlexCompColMatrix getInternalMatrix()
Description copied from class: AbstractMTJMatrix
Gets the internal MTJ matrix that this class is wrapping.

Overrides:
getInternalMatrix in class AbstractMTJMatrix
Returns:
Internal MTJ matrix.

times

public SparseColumnMatrix times(AbstractMTJMatrix matrix)
Description copied from class: AbstractMTJMatrix
Matrix multiplication of this and matrix, operates like the "*" operator in Matlab

Specified by:
times in class AbstractMTJMatrix
Parameters:
matrix - this.getNumColumns()==matrix.getNumRows()
Returns:
Matrix multiplication of this and matrix, will this.getNumRows() rows and matrix.getNumColumns() columns

getSubMatrix

public SparseColumnMatrix getSubMatrix(int minRow,
                                       int maxRow,
                                       int minColumn,
                                       int maxColumn)
Description copied from interface: Matrix
Gets the embedded submatrix inside of the Matrix, specified by the inclusive, zero-based indices such that the result matrix will have size (maxRow-minRow+1) x (maxColum-minCcolumn+1)

Parameters:
minRow - Zero-based index into the rows of the Matrix, must be less than or equal to maxRow
maxRow - Zero-based index into the rows of the Matrix, must be greater than or equal to minRow
minColumn - Zero-based index into the rows of the Matrix, must be less than or equal to maxColumn
maxColumn - Zero-based index into the rows of the Matrix, must be greater than or equal to minColumn
Returns:
the Matrix of dimension (maxRow-minRow+1)x(maxColumn-minColumn+1)

getColumn

public SparseVector getColumn(int columnIndex)
Gets the specified column of the matrix, using MTJ's internal routine to speed things up

Specified by:
getColumn in interface Matrix
Overrides:
getColumn in class AbstractSparseMatrix
Parameters:
columnIndex - zero-based column index
Returns:
SparseVector with the same dimensions as this has rows

setColumn

public void setColumn(int columnIndex,
                      SparseVector columnVector)
Sets the column of the matrix using the given SparseVector, using MTJ's internal routine to speed things up

Parameters:
columnIndex - Zero-based column index.
columnVector - SparseVector containing the elements to replace in this.

transpose

public SparseRowMatrix transpose()
Description copied from interface: Matrix
Returns the transpose of this

Returns:
Matrix whose elements are equivalent to: this.getElement(i, j) == this.transpose().getElement(j, i) for any valid i, j.

compact

public void compact()
Description copied from class: AbstractSparseMatrix
Compact the memory used by the matrix, getting rid of any zero elements

Specified by:
compact in class AbstractSparseMatrix