Class CompressedSparseRow stores general sparse matrix data in compressed row format.

Namespace:  CenterSpace.NMath.Matrix
Assembly:  NMath (in NMath.dll) Version: 5.1.0.0

Syntax

C#
[SerializableAttribute]
public class CompressedSparseRow<T> : ISparseMatrixStorage<T>, 
	IEquatable<CompressedSparseRow<T>>, ICloneable
Visual Basic (Declaration)
<SerializableAttribute> _
Public Class CompressedSparseRow(Of T) _
	Implements ISparseMatrixStorage(Of T), IEquatable(Of CompressedSparseRow(Of T)),  _
	ICloneable
Visual C++
[SerializableAttribute]
generic<typename T>
public ref class CompressedSparseRow : ISparseMatrixStorage<T>, 
	IEquatable<CompressedSparseRow<T>^>, ICloneable

Type Parameters

T
Type of values stored in the sparse matrix.

Remarks

Compressed row sparse matrix storage is specified by three arrays:
values, columns, and rowIndex. The columns and rowIndex arrays are zero-based!
values - array of type T that contains the non-zero elements of a sparse matrix. The values are mapped into this array in row-major format.
columns - Element I of the interger array columns is the number of the column that contains the I-th element of the values array.
rowIndex - Element j of the integer array rowIndex gives the index of the element in the values array that is the first non-zero element in the row j.
As the rowIndex array gives the location of the first non-zero element within a row, and the non-zero elements are stored consecutively, the number of non-zero elements in the Ith row is equal to the difference of rowIndex[I] and rowIndex[I+1]. To have this relationship hold for the last row of the matrix, an additional entery is added to the end of rowIndex. Its value is equal to the number of non-zero elements. This makes the rowIndex array one larger that the number of rows in the matrix.

Examples

For example, the matrix | 1 -1 0 -3 0 | | -2 5 0 0 0 | B = | 0 0 4 6 4 | | -4 0 2 7 0 | | 0 8 0 0 -5 | is stored as values = (1, -1, -3, -2, 5, 4, 6, 4, -4, 2, 7, 8, -5) columns = ( 0, 1, 3, 0, 1, 2, 3, 4, 0, 2, 3, 1, 4 ) rowIndex = ( 0, 3, 5, 8, 11, 13 )

Inheritance Hierarchy

System..::.Object
  CenterSpace.NMath.Matrix..::.CompressedSparseRow<(Of <(T>)>)

See Also