Abstract

Module type for regular sparse matrix operations. The abstract matrix type mat is not size-lifted. The module type is declared local to avoid that outside code makes direct use of the module type.

Synopsis

module type matrix_regular = {
type t
type mat [n] [m]
val zero: (n: i64) -> (m: i64) -> mat [n] [m]
val eye: (n: i64) -> (m: i64) -> mat [n] [m]
val dense [n] [m]: mat [n] [m] -> [n][m]t
val scale [n] [m]: t -> mat [n] [m] -> mat [n] [m]
val sparse [nnz]: (n: i64) -> (m: i64) -> [nnz](i64, i64, t) -> mat [n] [m]
val nnz [n] [m]: mat [n] [m] -> i64
val coo [n] [m]: mat [n] [m] -> ?[nnz].[nnz](i64, i64, t)
val + [n] [m]: mat [n] [m] -> mat [n] [m] -> mat [n] [m]
val - [n] [m]: mat [n] [m] -> mat [n] [m] -> mat [n] [m]
}

Description

module type matrix_regular
type t

The scalar type.

type mat [n] [m]

The type of regular-sized sparse matrices of dimension n x m.

val zero: (n: i64) -> (m: i64) -> mat [n] [m]

The zero matrix. Given n and m, the function returns an n times m empty sparse matrix (zeros everywhere).

val eye: (n: i64) -> (m: i64) -> mat [n] [m]

The eye. Given n and m, the function returns an n times m sparse matrix with ones in the diagonal and zeros elsewhere.

val dense [n] [m]: mat [n] [m] -> [n][m]t

Convert to dense format. Given a sparse matrix, the function returns a dense representation of the matrix.

val scale [n] [m]: t -> mat [n] [m] -> mat [n] [m]

Scale elements. Given a sparse matrix and a scale value v, the function returns a new sparse matrix with the elements scaled by v.

val sparse [nnz]: (n: i64) -> (m: i64) -> [nnz](i64, i64, t) -> mat [n] [m]

Create a sparse matrix from a coordinate array.

val nnz [n] [m]: mat [n] [m] -> i64

Number of non-zero elements. Given a sparse matrix, the function returns an upper approximation of the number of non-zero elements.

val coo [n] [m]: mat [n] [m] -> ?[nnz].[nnz](i64, i64, t)

Convert to coordinate vectors. Given a sparse matrix, convert it to coordinate vectors.

val + [n] [m]: mat [n] [m] -> mat [n] [m] -> mat [n] [m]

Element-wise addition.

val - [n] [m]: mat [n] [m] -> mat [n] [m] -> mat [n] [m]

Element-wise subtraction.