SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.matrix.doubles.matrixtype
Class MatrixStorageImpl<T extends Matrix>

java.lang.Object
  extended by com.numericalmethod.suanshu.matrix.doubles.matrixtype.MatrixMathImpl<T>
      extended by com.numericalmethod.suanshu.matrix.doubles.matrixtype.MatrixStorageImpl<T>
All Implemented Interfaces:
DeepCopyable, AbelianGroup<Matrix>, Monoid<Matrix>, Ring<Matrix>, Matrix, MatrixAccessor, MatrixRing, MatrixDimension
Direct Known Subclasses:
BidiagonalMatrix, DenseMatrix, DiagonalMatrix, SymmetricMatrix, TriangularMatrix, TridiagonalMatrix

public abstract class MatrixStorageImpl<T extends Matrix>
extends MatrixMathImpl<T>

This is one implementation of Matrix. It provides default implementation for common methods used in the double based Matrix. It assumes no knowledge of how a Matrix subclass is implemented and the data structure. Subclasses can (and should) override these methods for performance whenever possible.

This implementation assumes that the user supplies a data storage.


Constructor Summary
MatrixStorageImpl(int nRows, int nCols, MatrixData storage)
          Construct a MatrixStorageImpl, allowing overriding the default implementation.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Check if two matrices (of different implementations) are equal.
 double get(int row, int col)
          Get the matrix entry at [row, col].
protected  MatrixData getMatrixData()
           
 int hashCode()
           
 void set(int row, int col, double value)
          Set the matrix entry at [row, col] to value.
protected  void setMatrixData(MatrixData storage)
           
 
Methods inherited from class com.numericalmethod.suanshu.matrix.doubles.matrixtype.MatrixMathImpl
add, call, getColumn, getRow, getSample, minus, multiply, multiply, nCols, nRows, opposite, scaled, setColumn, setColumn, setRow, setRow, t, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.numericalmethod.suanshu.matrix.doubles.Matrix
deepCopy
 
Methods inherited from interface com.numericalmethod.suanshu.matrix.doubles.MatrixRing
ONE, ZERO
 

Constructor Detail

MatrixStorageImpl

public MatrixStorageImpl(int nRows,
                         int nCols,
                         MatrixData storage)
Construct a MatrixStorageImpl, allowing overriding the default implementation.

Parameters:
nRows - number of rows
nCols - number of columns
storage - matrix data storage/representation
Method Detail

getMatrixData

protected MatrixData getMatrixData()

setMatrixData

protected void setMatrixData(MatrixData storage)

set

public void set(int row,
                int col,
                double value)
         throws MatrixAccessException
Description copied from interface: MatrixAccessor
Set the matrix entry at [row, col] to value.

This is the only method that may change the entries of a matrix.

Parameters:
row - the row index
col - the column index
value - the value to set A[row, col] to
Throws:
MatrixAccessException - if row or col is out of range

get

public double get(int row,
                  int col)
           throws MatrixAccessException
Description copied from interface: MatrixAccessor
Get the matrix entry at [row, col].

Parameters:
row - the row index
col - the column index
Returns:
A[row, col]
Throws:
MatrixAccessException - if row or col is out of range

equals

public boolean equals(java.lang.Object obj)
Check if two matrices (of different implementations) are equal. They are equal iff two matrices have the same values, entry-by-entry.

Overrides:
equals in class java.lang.Object
Returns:
true iff two matrices have the same values, entry-by-entry

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.