Page
Library
Module
Module type
Parameter
Class
Class type
Source
Spurs.CsmatSourceval pp_compressed_storage :
Ppx_deriving_runtime.Format.formatter ->
compressed_storage ->
Ppx_deriving_runtime.unitval equal_compressed_storage :
compressed_storage ->
compressed_storage ->
Ppx_deriving_runtime.booltype 'a t = {mutable storage : compressed_storage;mutable nrows : int;mutable ncols : int;indptr : int Common.Dynarray.t;indices : int Common.Dynarray.t;data : 'a Common.Dynarray.t;}val pp :
'a. (Ppx_deriving_runtime.Format.formatter ->
'a ->
Ppx_deriving_runtime.unit) ->
Ppx_deriving_runtime.Format.formatter ->
'a t ->
Ppx_deriving_runtime.unitval show :
'a. (Ppx_deriving_runtime.Format.formatter ->
'a ->
Ppx_deriving_runtime.unit) ->
'a t ->
Ppx_deriving_runtime.stringval equal :
'a. ('a -> 'a -> Ppx_deriving_runtime.bool) ->
'a t ->
'a t ->
Ppx_deriving_runtime.boolIn the CSR (Compressed Sparse Row) format, a matrix is represented by three vectors: indptr, indices, and data.
These vectors satisfy the following relation:
for i in [0, nrows]:
A(i, indices[indptr[i] .. indptr[i + 1]]) = data[indptr[i] .. indptr[i + 1]]In the CSC (Compressed Sparse Column) format, the relation becomes:
for i in [0, ncols]:
A(indices[indptr[i] .. indptr[i + 1]], i) = data[indptr[i] .. indptr[i + 1]]val check_structure :
int ->
int ->
int Common.Dynarray.t ->
int Common.Dynarray.t ->
(unit, string) Result.tCheck the structure of CsMat components, ensuring:
outer_dim() + 1nnz == indptr[outer_dims()]inner_dims()val new_checked_dyn :
compressed_storage ->
(int * int) ->
int Common.Dynarray.t ->
int Common.Dynarray.t ->
'a Common.Dynarray.t ->
('a t, string) resultval new_checked :
compressed_storage ->
(int * int) ->
int array ->
int array ->
'a array ->
('a t, string) resultnew_csr indptr indices data creates a new CSR matrix. Raises an exception if the inputs do not describe a valid CSR matrix.
See new_csc for the CSC equivalent.
new_csc indptr indices data creates a new CSC matrix. Raises an exception if the inputs do not describe a valid CSC matrix.
See new_csr for the CSR equivalent.
val new_from_unsorted :
compressed_storage ->
(int * int) ->
int array ->
int array ->
'a array ->
('a t, string) resultCreate a new matrix.
Returns Some matrix if the inputs represent a valid sparse matrix, or None if the inputs are invalid.
val new_csr_from_unsorted :
(int * int) ->
int array ->
int array ->
'a array ->
('a t, string) resultTry to create a CSR matrix.
If necessary, the indices will be sorted.
val new_csc_from_unsorted :
(int * int) ->
int array ->
int array ->
'a array ->
('a t, string) resultTry to create a CSC matrix.
If necessary, the indices will be sorted.
Iterates through the matrix, calling f outer inner x on each element.
Create a matrix mathematically equal to this one, but with the opposite storage: CSR → CSC, or CSC → CSR.
Return the transpose of this matrix, in the other format.
Does not modify the original matrix.
Create a CSR matrix from a dense matrix, ignoring elements lower than epsilon.
Create a CSC matrix from a dense matrix, ignoring elements less than epsilon.
Create an empty matrix for building purposes
Same as get_outer, but raises an exception if the outer index is invalid.
Calls f outer v on each outer dimension, where v is the corresponding sparse vector.
Try to find the value at the given outer and inner indices.
Returns None if the indexing is invalid, otherwise returns Some NNZ index.
Find the non-zero index of the element specified by row and column.
This search is logarithmic in the number of non-zeros in the corresponding outer slice. Once available, the `nnz_index` type allows retrieval with O(1) complexity.
Returns None if the element is not found, otherwise returns Some NNZ index.
Index a sparse matrix using an Nnz_index.t.
Raises an exception if the index is out of bounds.
Reassign an index of a sparse matrix using an Nnz_index.t.
Raises an exception if the index is out of bounds.
Index a sparse matrix using row and column.
Has the same complexity as nnz_index.
Returns None if the row and column are invalid, otherwise returns Some value at that position.
Reassign an element using row and column.
Has the same complexity as nnz_index.
Returns None if the row and column are invalid, otherwise sets the value at that position.
Append an outer dimension to an existing matrix, extending the size of the outer dimension by one.
Raises an exception if the vector to add does not have compatible dimension.
Insert an element in the matrix. If the element is already present, its value is overwritten.
This is not an efficient operation. However, it is efficient if the elements are inserted in order according to the formatting (for example, row-by-row for CSR matrices)
If the index is out of bounds, the matrix will be resized to the necessary size.
Create a new CSR matrix equivalent to this one. If this is a CSR matrix, it is returned as a value. For a version that copies, see to_csr
Create a new CSR matrix equivalent to this one. If this is a CSR matrix, create a copy.
Create a new CSC matrix equivalent to this one. If this is a CSC matrix, it is returned as a value. For a version that copies, see to_csc
Create a new CSC matrix equivalent to this one. If this is a CSC matrix, create a copy.
Returns a vector containing the degree of each vertex, ie the number of neighbors of each vertex. We do not count diagonal entries as a neighbor.
Generate a one-hot matrix, compressing the inner dimension.
Returns a matrix with the same size, the same CSR/CSC type, and a single value of 1.0 within each populated inner vector.