package spurs

  1. Overview
  2. Docs

Module Spurs.CstriSource

Sourcetype 'a t = {
  1. rows : int;
  2. cols : int;
  3. row_inds : int Common.Dynarray.t;
  4. col_inds : int Common.Dynarray.t;
  5. data : 'a Common.Dynarray.t;
}

Sparse matrix in the triplet format.

Sparse matrices in the triplet format use three arrays of equal sizes (accessible through the methods `row_inds`, `col_inds`, `data`), the first one storing the row indices of non-zero values, the second storing the corresponding column indices and the last array storing the corresponding scalar value. If a non-zero location is repeated in the arrays, the non-zero value is taken as the sum of the corresponding scalar entries.

This format is useful for iteratively building a sparse matrix, since the various non-zero entries can be specified in any order, or even partially as is common in physics with partial derivatives equations.

This format cannot be used for arithmetic operations. Arithmetic operations are more efficient in the compressed format. A matrix in the triplet format can be converted to the compressed format using the functions `to_csc` and `to_csr`.

Sourceval equal : 'a. ('a -> 'a -> Ppx_deriving_runtime.bool) -> 'a t -> 'a t -> Ppx_deriving_runtime.bool
Sourceval get_rows : 'a t -> int
Sourceval get_cols : 'a t -> int
Sourceval get_row_inds : 'a t -> int Common.Dynarray.t
Sourceval get_col_inds : 'a t -> int Common.Dynarray.t
Sourceval get_data : 'a t -> 'a Common.Dynarray.t
OCaml

Innovation. Community. Security.