Page
Library
Module
Module type
Parameter
Class
Class type
Source
Spurs.Csvec
SourceA sparse vector, storing the indices of its non-zero data.
It contains a sorted indices
array and a corresponding data
array.
val pp :
'a. (Ppx_deriving_runtime.Format.formatter ->
'a ->
Ppx_deriving_runtime.unit) ->
Ppx_deriving_runtime.Format.formatter ->
'a t ->
Ppx_deriving_runtime.unit
val show :
'a. (Ppx_deriving_runtime.Format.formatter ->
'a ->
Ppx_deriving_runtime.unit) ->
'a t ->
Ppx_deriving_runtime.string
val equal :
'a. ('a -> 'a -> Ppx_deriving_runtime.bool) ->
'a t ->
'a t ->
Ppx_deriving_runtime.bool
Create a sparse vector.
Returns an error:
indices
and data
lengths differn
Same as try_new_csvec
, but raises an error if invalid
Creates a CsVec, sorting indices and data if necessary.
Returns an error if the lengths mismatch.
Try to index a vector at a specific index. Returns Some nnz
if index exists.
Access element at given NNZ
index, with constant complexity.
Set element at given NNZ
index, with constant complexity.
Set element at given index, with logarithmic complexity. Returns None
if the index does not exist already as a non-zero..
fold f acc v
calls f acc index data
, through each index-data pair in v
iter f v
calls f index data
on each index-data pair in v
Append an element to the sparse vector. The append should preserve the structure.
Raises an exception if:
ind
is lower or equal to the last element of v.indicesind
is greater than v.dimCheck the sparse structure, namely that:
indices
are sortedindices
are less than dim
Convert this vector into a dense array.
The rest of the vector is filled with zeroes.