Database Reference
In-Depth Information
Matrix
SparseMatrix
(abstract)
SparseMatrix
CompRow
SparseMatrix
CompRowStatic
SparseMatrix
RowBased
SparseMatrix
Hash
Fig. 12.12 Class hierarchy of matrices
The class SparseMatrixRowBased uses the storage format Direct Row Storage
( DRS ), where the matrix is stored as array of arrays whose last contains the NZEs
with their column indexes for each row. The DRS format is more dynamic than the
CRS format concerning changes of its structure but executes slower matrix-vector
multiplications. The class SparseMatrixHash is entirely based on a hash and thus
can be manipulated very easy and fast, but the execution of most operations is
slower compared to the CRS and DRS formats.
The Matrix class and all of its SparseMatrix implementations can be easily
converted into each other by special constructors and conversion methods. In this
way at the beginning of blocks of algebraic operations, the sparse matrices can be
converted into the format that is most efficient for these operations.
Example 12.11 We return to Example 12.10 and introduce a further matrix
0
1
024
000
3 12
001
@
A
F ¼
that we will use for demonstration of sparse matrices. First, we store F in CRS
format and convert it into a matrix G in DRS format that we use for further
calculations:
// Create F as CRS:
double[] values ¼ {2,4,3,11,2,1};
int[] columnIndexes ¼ {1,2,0,1,2,2};
int[] rowPointer ¼ {0,2,2,5,6};
SparseMatrixCompRowStatic F ¼
new
SparseMatrixCompRowStatic(4,
3,
values,
columnIndexes, rowPointer);
 
Search WWH ::




Custom Search