SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.matrix.doubles.matrixtype.sparse
Interface SparseMatrix

All Superinterfaces:
AbelianGroup<Matrix>, DeepCopyable, Densifiable, Matrix, MatrixAccessor, MatrixDimension, MatrixRing, Monoid<Matrix>, Ring<Matrix>, SparseStructure
All Known Implementing Classes:
CsrSparseMatrix, DokSparseMatrix, LilSparseMatrix

public interface SparseMatrix
extends Matrix, Densifiable, SparseStructure

This interface defines the sparse matrix which stores non-zero values only. If there are only a few non-zeros in a matrix, sparse matrix does save memory space for storing the matrix. In addition, matrix operations based on sparse matrix are also more efficient. Usually, the time complexities of are just proportional to the number of non-zero values, instead of the dimension of the matrix as in the dense case.


Method Summary
 java.util.List<SparseElement> toElementList()
          Export the non-zero values in the matrix as a list of SparseElements.
 
Methods inherited from interface com.numericalmethod.suanshu.matrix.doubles.Matrix
deepCopy, multiply, scaled
 
Methods inherited from interface com.numericalmethod.suanshu.matrix.MatrixDimension
nCols, nRows
 
Methods inherited from interface com.numericalmethod.suanshu.matrix.doubles.MatrixAccessor
get, getColumn, getRow, set
 
Methods inherited from interface com.numericalmethod.suanshu.matrix.doubles.MatrixRing
add, minus, multiply, ONE, opposite, t, ZERO
 
Methods inherited from interface com.numericalmethod.suanshu.matrix.doubles.matrixtype.dense.Densifiable
toDense
 
Methods inherited from interface com.numericalmethod.suanshu.matrix.doubles.matrixtype.sparse.SparseStructure
dropTolerance, nnz
 

Method Detail

toElementList

java.util.List<SparseElement> toElementList()
Export the non-zero values in the matrix as a list of SparseElements.

This is useful for converting between SparseMatrix of different formats. For example,

 // construct matrix using DOK
 DokSparseMatrix dok = new DokSparseMatrix(5, 5);
 // ... insert some values to DOK matrix
 // convert to CSR matrix for efficient matrix operations
 CsrSparseMatrix csr = new CsrSparseMatrix(5, 5, dok.toElementList());
 

Returns:
the element list

SuanShu, a Java numerical and statistical library

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