Module Sls.SparseMatrix

module SparseMatrix: sig .. end
Sparse matrices as passed to callback functions.
See sundials: The SLS Module

type csc 
type csr 
type 'sformat t = 'sformat Sls_impl.t 
A sparse matrix. Values of this type are passed to linear solver callback functions, in which case their lifetimes are determined by the underlying library and they should only be used within the callback to avoid the Invalidated exception.

The type argument 'sformat specifies the storage format. It is either Sls.SparseMatrix.csc or Sls.SparseMatrix.csr.

See sundials: Type SlsMat
type t_csc = csc t 
type t_csr = csr t 

Basic access


val make_csc : int -> int -> int -> csc t
make m n nnz returns an m by n sparse matrix in compressed-sparse-column format with a potential for nnz non-zero elements. All elements are initially zero.
See sundials: SparseNewMat
val create_csc : int -> int -> int -> csc t
create m n nnz returns an uninitialized m by n sparse matrix in compressed-sparse-column format with a potential for nnz non-zero elements.
See sundials: SparseNewMat
val make_csr : int -> int -> int -> csr t
make m n nnz returns an m by n sparse matrix in compressed-sparse-row format with a potential for nnz non-zero elements. All elements are initially zero.
Since 2.7.0
Raises Sundials.NotImplementedBySundialsVersion CSR format not available.
See sundials: SparseNewMat
val create_csr : int -> int -> int -> csr t
create m n nnz returns an uninitialized m by n sparse matrix in compressed-sparse-row format with a potential for nnz non-zero elements.
Since 2.7.0
Raises Sundials.NotImplementedBySundialsVersion CSR format not available.
See sundials: SparseNewMat
val size : 'f t -> int * int * int
m, n, nnz = size a returns the numbers of columns m, rows n, and the maximum number of non-zero elements of a.
val print : Sundials.Logfile.t -> 'f t -> unit
Prints a sparse matrix to stdout.

In versions of Sundials prior to 2.7.0, the only valid log file is .

Raises Sundials.NotImplementedBySundialsVersion log file not supported.
See sundials: SparsePrintMat
val pp : Format.formatter -> 'f t -> unit
Pretty-print a sparse matrix using the Format module.
val csc_from_dense : Dls.DenseMatrix.t -> csc t
Create a compressed-sparse-column matrix from a dense one.
See sundials: SparseFromDenseMat
val csr_from_dense : Dls.DenseMatrix.t -> csr t
Create a compressed-sparse-row matrix from a dense one.
See sundials: SparseFromDenseMat
val csc_from_band : Dls.BandMatrix.t -> csc t
Create a sparse matrix from a banded one.
See sundials: SparseFromDenseMat
val csr_from_band : Dls.BandMatrix.t -> csr t
Create a sparse matrix from a banded one.
See sundials: SparseFromDenseMat
val set_col : csc t -> int -> int -> unit
set_col a j idx sets the data index of column j to idx.
val get_col : csc t -> int -> int
get_col a j returns the data index of column j.
val set_row : csr t -> int -> int -> unit
set_row a j idx sets the data index of row j to idx.
val get_row : csr t -> int -> int
get_row a j returns the data index of row j.
val set : 'f t -> int -> int -> float -> unit
set a idx i v sets the idxth row/column to i and its value to v.
val get : 'f t -> int -> int * float
r, v = get a idx returns the row/column r and value v at the idxth position.
val set_to_zero : 'f t -> unit
Fills a matrix with zeros.
See sundials: SparseSetMatToZero
val realloc : 'f t -> int -> unit
Reallocates enoughs space for the given number of non-zero values.

Calculations


val add_identity : 'f t -> unit
Increments a square matrix by the identity matrix.
See sundials: SparseAddIdentityMat
val blit : 'f t -> 'f t -> unit
blit src dst copies the contents of src into dst.
See sundials: SparseCopyMat
val scale : float -> 'f t -> unit
Multiplies each element by a constant.
See sundials: SparseScaleMat
val add : 'f t -> 'f t -> unit
Adds two matrices.
See sundials: SparseAddMat
val matvec : 'f t -> Sundials.RealArray.t -> Sundials.RealArray.t -> unit
matvec a x y computes the matrix-vector product y = A*x. If a has dimensions m by n, then x must be of size n, and y must be of size m.
See sundials: SparseMatvec

Low-level details


val set_rowval : csc t -> int -> int -> unit
set_rowval a idx i sets the idxth row to i.
val get_rowval : csc t -> int -> int
r = get_rowval a idx returns the row r at the idxth position.
val set_colval : csr t -> int -> int -> unit
set_colval a idx i sets the idxth column to i.
val get_colval : csr t -> int -> int
c = get_colval a idx returns the column c at the idxth position.
val set_data : 'f t -> int -> float -> unit
set_data a idx v sets the value of the idxth row v.
val get_data : 'f t -> int -> float
v = get_data a idx returns the value v at the idxth position.
exception Invalidated
Raised on an attempt to access a value that has become invalid. Such values refer to matrices that no longer exist in the underlying library.
val invalidate : 'f t -> unit
Called internally when the corresponding value in the underlying library ceases to exist.