SparseMatrix
Constructs a SparseMatrix instance with the specified number of rows, columns, and non-zero values.
Return
A new SparseMatrix instance with the given dimensions and non-zero values.
Parameters
The number of rows in the matrix.
The number of columns in the matrix.
A map containing the non-zero values and their positions, where the key is a pair of row and column indices, and the value is the corresponding matrix value.
Constructs a sparse matrix in Compressed Sparse Row (CSR) format.
Return
The constructed SparseMatrix
object in CSR format.
Parameters
The number of rows in the matrix.
The number of columns in the matrix.
A list of pairs representing the row and column indices of non-zero elements.
A list of values corresponding to the non-zero elements at the specified indices.
Indicates whether the indices are already sorted by row and column. If set to false
, the indices will be sorted internally. Defaults to false
.
Throws
If the number of indices does not match the number of values, or if the indices list is empty.