| org.jscience.mathematics.vector.SparseMatrix
SparseMatrix | final public class SparseMatrix extends Matrix (Code) | | This class represents a matrix made of
SparseVector sparsevectors (as rows). To create a sparse matrix made of column vectors the
SparseMatrix.transpose method can be used.
For example:[code]
SparseVector column0 = SparseVector.valueOf(...);
SparseVector column1 = SparseVector.valueOf(...);
SparseMatrix M = SparseMatrix.valueOf(column0, column1).transpose();
[/code]
As for any concrete
org.jscience.mathematics.structure.Structurestructure , this class is declared final (otherwise most
operations would have to be overridden to return the appropriate type).
Specialized dense matrix should sub-class
Matrix directly.
For example:[code]
// Extension through composition.
final class BandMatrix > extends Matrix {
private SparseMatrix _value;
...
public BandMatrix opposite() { // Returns the right type.
return BandMatrix.valueOf(_value.opposite());
}
...
}[/code]
author: Jean-Marie Dautelle version: 3.3, January 2, 2007 |
Field Summary | |
int | _n Holds the number of columns n or the number of rows m if transposed. | final FastTable<SparseVector<F>> | _rows Holds this matrix rows (or columns when transposed). | boolean | _transposed Indicates if this matrix is transposed (the rows are then the columns). | F | _zero Holds the zero. |
_n | int _n(Code) | | Holds the number of columns n or the number of rows m if transposed.
|
_rows | final FastTable<SparseVector<F>> _rows(Code) | | Holds this matrix rows (or columns when transposed).
|
_transposed | boolean _transposed(Code) | | Indicates if this matrix is transposed (the rows are then the columns).
|
_zero | F _zero(Code) | | Holds the zero.
|
cofactor | public F cofactor(int i, int j)(Code) | | |
determinant | public F determinant()(Code) | | |
get | public F get(int i, int j)(Code) | | |
getNumberOfColumns | public int getNumberOfColumns()(Code) | | |
getNumberOfRows | public int getNumberOfRows()(Code) | | |
getZero | public F getZero()(Code) | | Returns the value of the non-set elements for this sparse matrix.
the element corresponding to zero. |
valueOf | public static SparseMatrix<F> valueOf(Vector<F> diagonal, F zero)(Code) | | Returns the sparse square matrix having the specified diagonal
vector. This method is typically used to create an identity matrix.
For example:[code]
SparseMatrix IDENTITY = Matrix.valueOf(
DenseVector.valueOf({Real.ONE, Real.ONE, Real.ONE}), Real.ZERO);
[/code]
Parameters: diagonal - the diagonal vector. Parameters: zero - value of non-diagonal elements. a square matrix with diagonal on the diagonal andzero elsewhere. |
valueOf | public static SparseMatrix<F> valueOf(Matrix<F> that, F zero)(Code) | | Returns a sparse matrix equivalent to the specified matrix but with
the zero elements removed using the default object equality comparator.
Parameters: that - the matrix to convert. Parameters: zero - the zero element for the sparse vector to return. SparseMatrix.valueOf(that, zero, FastComparator.DEFAULT) or a dense matrix holding the same elements |
valueOf | public static SparseMatrix<F> valueOf(Matrix<F> that, F zero, FastComparator<? super F> comparator)(Code) | | Returns a sparse matrix equivalent to the specified matrix but with
the zero elements removed using the specified object equality comparator.
Parameters: that - the matrix to convert. Parameters: zero - the zero element for the sparse vector to return. Parameters: comparator - the comparator used to determinate zero equality. that or a dense matrix holding the same elementsas the specified matrix. |
|
|