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 = {
|
Description
- ↑module type matrix_regular
- ↑type t
The scalar type.
- ↑type mat [n] [m]
The type of regular-sized sparse matrices of dimension
n
xm
.- ↑val zero: (n: i64) -> (m: i64) -> mat [n] [m]
The zero matrix. Given
n
andm
, the function returns ann
timesm
empty sparse matrix (zeros everywhere).- ↑val eye: (n: i64) -> (m: i64) -> mat [n] [m]
The eye. Given
n
andm
, the function returns ann
timesm
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 byv
.- ↑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.