package modelkit

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

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.

type t
type view
type view_memory = {
  1. allocated_bytes : int64;
  2. shared_bytes : int64;
  3. materialized_bytes : int64;
}
val create : rows:int -> columns:int -> row_offsets:int array -> column_indices:int array -> values:Vector.t -> (t, Data_error.t) result
val of_arrays : rows:int -> columns:int -> row_offsets:int array -> column_indices:int array -> values:float array -> (t, Data_error.t) result
val of_dense : Matrix.t -> t
val to_dense : t -> Matrix.t
val rows : t -> int
val columns : t -> int
val shape : t -> int * int
val nonzero_count : t -> int
val row_offsets : t -> int array
val column_indices : t -> int array
val values : t -> Vector.t
val get : t -> int -> int -> float

Raises Invalid_argument if either index is outside the matrix.

val iter_row : t -> row:int -> f:(column:int -> value:float -> unit) -> unit

Iterates stored entries in ascending column order without allocating. Raises Invalid_argument if row is outside the matrix.

val memory : t -> Matrix_memory.t
val all : t -> view
val view : t -> Row_view.t -> (view, Data_error.t) result
val view_rows : view -> int
val view_columns : view -> int
val view_nonzero_count : view -> int
val row_view : view -> Row_view.t
val source_row : view -> int -> int
val view_get : view -> row:int -> column:int -> float
val materialize : view -> t
val view_memory : view -> view_memory

Reports bytes allocated for row indices, bytes shared with the source, and the payload bytes that explicit materialization would require.