 | CompressedSparseRowT Class |
Class CompressedSparseRow stores general sparse matrix data in compressed row format.
Inheritance Hierarchy Namespace: CenterSpace.NMath.CoreAssembly: NMath (in NMath.dll) Version: 7.4
Syntax[SerializableAttribute]
public class CompressedSparseRow<T> : ISparseMatrixStorage<T>,
IEquatable<CompressedSparseRow<T>>, ICloneable
<SerializableAttribute>
Public Class CompressedSparseRow(Of T)
Implements ISparseMatrixStorage(Of T), IEquatable(Of CompressedSparseRow(Of T)),
ICloneable
[SerializableAttribute]
generic<typename T>
public ref class CompressedSparseRow : ISparseMatrixStorage<T>,
IEquatable<CompressedSparseRow<T>^>, ICloneable
[<SerializableAttribute>]
type CompressedSparseRow<'T> =
class
interface ISparseMatrixStorage<'T>
interface IEquatable<CompressedSparseRow<'T>>
interface ICloneable
end
Type Parameters
- T
- Type of values stored in the sparse matrix.
The CompressedSparseRowT type exposes the following members.
Constructors | Name | Description |
---|
 | CompressedSparseRowT |
No argument constructor. All values initialized to null or 0.
|
 | CompressedSparseRowT(IDictionaryIntPair, T, Int32) |
Constructs a compressed row storage instance from the given coordinate
map format.
|
 | CompressedSparseRowT(IDictionaryIntPair, T, Int32, Int32) |
Constructs a compressed row storage instance from the given coordinate
map format.
|
 | CompressedSparseRowT(Int32, Int32, Int32) |
Sizes all arrays to hold the specified number of non-zero values and rows.
|
 | CompressedSparseRowT(T, Int32, Int32, Int32) |
Constructs a CompressedSparseRow instance from the given data.
|
Top
Properties | Name | Description |
---|
 | Cols |
Gets the number of columns in self.
|
 | Columns |
Gets and sets the columns array.
|
 | Item |
Indexer to retrieve values.
|
 | NumberNonZero |
Gets the number of non-zero entries in self.
|
 | RowIndex |
Gets and sets the row index array.
|
 | Rows |
Gets the number of rows in self.
|
 | Values |
Gets and sets the array on non-zero values.
|
Top
Methods
Operators
Fields
RemarksCompressed 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 integer 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 entry 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.
Example
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 )
See Also