Module Mavryk_benchmark.Maths

module Vector = Linalg.Vec.Float
module Matrix = Linalg.Mat.Float
type vector = int Vector.t

Vectors with elements indexed by ints

type matrix = (int * int) Matrix.t

Read-only matrices with elements indexed by pairs (column, row)

type out_matrix = (int * int) Matrix.out

Write-only matrices with elements indexed by pairs (column, row)

val vec_dim : vector -> int

Number of elements of a vector

val col_dim : matrix -> int

Number of columns of a matrix

val row_dim : matrix -> int

Number of rows of a matrix

val matrix_of_array_array : float array array -> matrix

Create a read-only matrix overlay over an array of arrays. Note how we switch from row major to column major in order to comply to Linalg's defaults.

val out_matrix_of_array_array : float array array -> out_matrix

Create a write-only overlay over an array of arrays. Note how we switch from row major to column major in order to comply to Linalg's defaults.

val mm_ : out_matrix -> matrix -> matrix -> unit

mm_ out lhs rhs computes the matrix product lhs x rhs and stores it in out

val vector_to_array : vector -> float array

Create a float array from a vector

val vector_of_array : float array -> vector

Create a vector from a float array

val vector_to_seq : vector -> float Mavryk_base.TzPervasives.Seq.t

Construct a sequence out of the elements of a vector

val map_rows : (vector -> float) -> matrix -> vector

Map a scalar function on the rows of a matrix, yielding a column vector

val mapi_rows : (int -> vector -> float) -> matrix -> vector

Map a scalar function on the rows of a matrix, yielding a column vector

val map_cols : (vector -> float) -> matrix -> vector

Map a scalar function on the columns of a matrix, yielding a row vector

val empty_matrix : matrix

An empty matrix.

val l2_norm : vector -> float

l2 norm of a vector

val mse : vector -> float

Mean square error

val average : vector -> float

Average

val std : vector -> float

Standard deviation

val vector_encoding : vector Mavryk_base.TzPervasives.Data_encoding.t

An encoding for vectors.

val pp_vec : Stdlib.Format.formatter -> vector -> unit

Pretty printing vectors.