package modelkit
Module Modelkit.Csr_matrixSource
Immutable checked compressed sparse row storage.
Row offsets must begin at zero, end at the stored-value count, and be nondecreasing. Column indices must be in bounds and strictly increasing within each row. Admission copies index arrays; of_arrays also copies values. Explicit stored zeroes are retained.
val create :
rows:int ->
columns:int ->
row_offsets:int array ->
column_indices:int array ->
values:Vector.t ->
(t, Data_error.t) resultval of_arrays :
rows:int ->
columns:int ->
row_offsets:int array ->
column_indices:int array ->
values:float array ->
(t, Data_error.t) resultval rows : t -> intval columns : t -> intval shape : t -> int * intval nonzero_count : t -> intval row_offsets : t -> int arrayval column_indices : t -> int arrayval get : t -> int -> int -> floatRaises Invalid_argument if either index is outside the matrix.
val iter_row : t -> row:int -> f:(column:int -> value:float -> unit) -> unitIterates stored entries in ascending column order without allocating. Raises Invalid_argument if row is outside the matrix.
val memory : t -> Matrix_memory.tval view : t -> Row_view.t -> (view, Data_error.t) resultval view_rows : view -> intval view_columns : view -> intval view_nonzero_count : view -> intval row_view : view -> Row_view.tval source_row : view -> int -> intval view_get : view -> row:int -> column:int -> floatval view_memory : view -> view_memoryReports bytes allocated for row indices, bytes shared with the source, and the payload bytes that explicit materialization would require.