Module type Gg.M
Implemented by all (square) matrix types.
Constructors, accessors and constants
val el : int -> int -> t -> float
el i j a
is the elementa
ij
.- raises Invalid_argument
if
i
orj
is not in [0;
dim
[.
Functions
val mul : t -> t -> t
mul a b
is the matrix multiplicationa * b
.
val trace : t -> float
trace a
is the matrix tracetrace(a)
.
val det : t -> float
det a
is the determinant|a|
.
val inv : t -> t
inv a
is the inverse matrixa
-1.
Traversal
val mapi : (int -> int -> float -> float) -> t -> t
mapi f a
is likemap
but the element indices are also given.
val fold : ('a -> float -> 'a) -> 'a -> t -> 'a
fold f acc a
isf (
...(f (f acc a
00) a
10)
...)
.
val foldi : ('a -> int -> int -> float -> 'a) -> 'a -> t -> 'a
foldi f acc a
isf (
...(f (f acc 0 0 a
00) 1 0 a
10)
...)
.
val iter : (float -> unit) -> t -> unit
iter f a
isf a
00; f a
10;
...
val iteri : (int -> int -> float -> unit) -> t -> unit
iteri f a
isf 0 0 a
00; f 1 0 a
10;
...
Predicates and comparisons
val for_all : (float -> bool) -> t -> bool
for_all p a
isp a
00&& p a
10&&
...
val exists : (float -> bool) -> t -> bool
exists p a
isp a
00|| p a
10||
...
val equal_f : (float -> float -> bool) -> t -> t -> bool
equal_f eq a b
testsa
andb
likeequal
but useseq
to test floating point values.
Printers
val pp : Stdlib.Format.formatter -> t -> unit
pp ppf a
prints a textual representation ofa
onppf
.
val pp_f : (Stdlib.Format.formatter -> float -> unit) -> Stdlib.Format.formatter -> t -> unit
pp_f pp_e ppf a
printsa
likepp
but usespp_e
to print floating point values.