Click or drag to resize
SparseMatrixSparseArray Class
The SparseArray class uses public fields to hold the data for a sparse matrix in the Sparse Array format.
Inheritance Hierarchy
SystemObject
  Imsl.MathSparseMatrixSparseArray

Namespace: Imsl.Math
Assembly: ImslCS (in ImslCS.dll) Version: 6.5.2.0
Syntax
[SerializableAttribute]
public class SparseArray

The SparseMatrixSparseArray type exposes the following members.

Constructors
  NameDescription
Public methodSparseMatrixSparseArray
Initializes a new instance of the SparseMatrixSparseArray class
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Fields
  NameDescription
Public fieldIndex
Jagged array containing column indices. The length of this array equals numberOfRows. The length of each row equals the number of nonzeros in that row of the sparse matrix.
Public fieldNumberOfColumns
Number of columns in the matrix.
Public fieldNumberOfNonZeros
Number of nonzeros in the matrix.
Public fieldNumberOfRows
Number of rows in the matrix.
Public fieldValues
Jagged array containing sparse array values. This array must have the same shape as Index.
Top
Remarks

This format came about as a means for storing sparse matrices. In this format, a sparse matrix is represented by two arrays of arrays. One array contains the references to the nonzero value arrays for each row of the sparse matrix. The other contains the references to the associated column index arrays.

As an example, consider the following real sparse matrix:


            A=\begin{pmatrix} 10.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\
            0.0 & 10.0 & -3.0 & -1.0 & 0.0 & 0.0 \\
            0.0 & 0.0 &  15.0 &	0.0 & 0.0 & 0.0 \\
            -2.0 & 0.0 & 0.0 & 10.0 & -1.0 &  0.0 \\
            -1.0 & 0.0 & 0.0 & -5.0 &  1.0 & -3.0 \\
            -1.0 & -2.0 & 0.0 & 0.0 &  0.0 & 6.0 \end{pmatrix}
In SparseArray, this matrix can be represented by the two jagged arrays, values and index, where values refers to the nonzero entries in A and index to the column indices:
double values[][] = {{10.0},
                     {10.0, -3.0, -1.0},
                     {15.0},
                     {-2.0, 10.0, -1.0}, 
                     {-1.0, -5.0, 1.0, -3.0},
                     {-1.0, -2.0, 6.0}
                    };

int index[][] = {{0}, 
                 {1, 2, 3},
                 {2},
                 {0, 3, 4},
                 {0, 3, 4, 5},
                 {0, 1, 5}
                };

See Also