Library
Module
Module type
Parameter
Class
Class type
2D square matrices.
type t = m2
The type for 2D square matrices.
type v = v2
The type for rows and columns as vectors.
val v : float -> float -> float -> float -> m2
v e00 e01 e10 e11
is a matrix whose components are specified in row-major order
val el : int -> int -> m2 -> float
el i j a
is the element a
ij
. See also the direct element accessors.
Raises Invalid_argument
if i
or j
is not in [0;
dim
[.
row i a
is the i
th row of a
.
Raises Invalid_argument
if i
is not in [0;
dim
[.
col j a
is the j
th column of a
.
Raises Invalid_argument
if j
is not in [0;
dim
[.
mul a b
is the matrix multiplication a * b
.
val trace : m2 -> float
trace a
is the matrix trace trace(a)
.
val det : m2 -> float
det a
is the determinant |a|
.
inv a
is the inverse matrix a
-1.
val rot2 : float -> m2
rot2 theta
rotates 2D space around the origin by theta
radians.
mapi f a
is like map
but the element indices are also given.
val fold : ('a -> float -> 'a) -> 'a -> m2 -> 'a
fold f acc a
is f (
...(f (f acc a
00) a
10)
...)
.
val foldi : ('a -> int -> int -> float -> 'a) -> 'a -> m2 -> 'a
foldi f acc a
is f (
...(f (f acc 0 0 a
00) 1 0 a
10)
...)
.
val iter : (float -> unit) -> m2 -> unit
iter f a
is f a
00; f a
10;
...
val iteri : (int -> int -> float -> unit) -> m2 -> unit
iteri f a
is f 0 0 a
00; f 1 0 a
10;
...
val for_all : (float -> bool) -> m2 -> bool
for_all p a
is p a
00 && p a
10 &&
...
val exists : (float -> bool) -> m2 -> bool
exists p a
is p a
00 || p a
10 ||
...
equal_f eq a b
tests a
and b
like equal
but uses eq
to test floating point values.
compare a b
is Stdlib.compare a b
. That is lexicographic comparison in column-major order.
compare_f cmp a b
compares a
and b
like compare
but uses cmp
to compare floating point values.
val pp : Format.formatter -> m2 -> unit
pp ppf a
prints a textual representation of a
on ppf
.
val pp_f :
(Format.formatter -> float -> unit) ->
Format.formatter ->
m2 ->
unit
pp_f pp_e ppf a
prints a
like pp
but uses pp_e
to print floating point values.
val e00 : m2 -> float
val e01 : m2 -> float
val e10 : m2 -> float
val e11 : m2 -> float