Library
Module
Module type
Parameter
Class
Class type
Float
allows to manipulate float-valued matrices
type base_index = Tensor.Int.pos
type 'a shape = 'a Tensor.Int.t
type index := base_index * base_index
include Intf.Vec
with type 'a k := 'a k
and type 'a m := 'a m
and type 'a shape := 'a shape
with type ('a, 'b) morphism = ('a, 'b) Tensor.Int.Morphism.t
with type elt = float
type ('a, 'b) morphism = ('a, 'b) Tensor.Int.Morphism.t
Type of shape morphisms.
Creates an input vector from a dimension and a function.
Get an elemement of an input vector. Does not perform bound checking.
basis s i r
is the vector of shape s
everywhere equal to R.zero except at index i
where it is equal to r
. Raises Out_of_bounds
if i
does not belong to s
.
Pointwise addition. Raises Dimensions_mismatch
if the shape of operands are not equal.
Pointwise subtraction. Raises Dimensions_mismatch
if the shape of operands are not equal.
Pointwise multiplication. Raises Dimensions_mismatch
if the shape of operands are not equal.
Swapping of indices. Raises Out_of_bounds
if given indices are invalid.
iter v
iterates the effectful computation at each index
reduce op zero v
folds the binary, associative operator op
over the elements of v
with initial value zero
. Fold ordering is implementation-dependent: consider using commutative operators.
Vector assignement.
Pointwise multiplication, stores result in first operand.
module Infix : sig ... end
val index : c:base_index m -> r:base_index m -> index m
Indexing
val cols : index t -> base_index shape
cols m
returns the shape of the columns of m
.
val rows : index t -> base_index shape
rows m
returns the shape of the rows of m
val identity : base_index shape -> index t
Identity matrix
val diagonal : (base_index shape, base_index m, elt m) Intf.vec -> index t
Square matrix with given vector on diagonal
val col :
index t ->
base_index m ->
(base_index shape, base_index m, elt m) Intf.vec k
Get a column.
val of_col : (base_index shape, base_index m, elt m) Intf.vec -> index t
Convert a vector into a matrix with this vector as single column.
val row :
index t ->
base_index m ->
(base_index shape, base_index m, elt m) Intf.vec k
Get a row.
val of_row : (base_index shape, base_index m, elt m) Intf.vec -> index t
Convert a vector into a matrix with this vector as single row.
val swap_rows : index t -> base_index m -> base_index m -> index t k
Swap two rows.
val swap_cols : index t -> base_index m -> base_index m -> index t k
Swap two columns.
Concatenate two matrices horizontally, provided they have the same number of rows.
Concatenate two matrices vertically, provided they have the same number of columns.