Module type Gg.M
module type M = sig
.. end
Implemented by all (square) matrix types.
type
t
The type for matrices.
val dim : int
dim
is the dimension of rows and columns.
type
v
The type for rows and columns as vectors.
Constructors, accessors and constants
val el : int -> int -> t -> float
el i j a
is the element
a
ij
.
Raises Invalid_argument
if
i
or
j
is not in [
0;
Gg.M.dim
[.
val row : int -> t -> v
row i a
is the
i
th row of
a
.
Raises Invalid_argument
if
i
is not in [
0;
Gg.M.dim
[.
val col : int -> t -> v
col j a
is the
j
th column of
a
.
Raises Invalid_argument
if
j
is not in [
0;
Gg.M.dim
[.
val zero : t
zero
is the neutral element for
Gg.M.add
.
val id : t
id
is the identity matrix, the neutral element for
Gg.M.mul
.
Functions
val neg : t -> t
neg a
is the negated matrix -a
.
val add : t -> t -> t
add a b
is the matrix addition a + b
.
val sub : t -> t -> t
sub a b
is the matrix subtraction a - b
.
val mul : t -> t -> t
val emul : t -> t -> t
emul a b
is the element wise multiplication of a
and b
.
val ediv : t -> t -> t
ediv a b
is the element wise division of a
and b
.
val smul : float -> t -> t
smul s a
is a
's elements multiplied by the scalar s
.
val transpose : t -> t
val trace : t -> float
val det : t -> float
val inv : t -> t
Traversal
val map : (float -> float) -> t -> t
map f a
is the element wise application of f
to a
.
val mapi : (int -> int -> float -> float) -> t -> t
mapi f a
is like
Gg.M.map
but the element indices are also given.
val fold : ('a -> float -> 'a) -> 'a -> t -> 'a
fold f acc a
is f (
...(f (f acc a
00) a
10)
...)
.
val foldi : ('a -> int -> int -> float -> 'a) -> 'a -> t -> 'a
foldi f acc a
is
f (
...(f (f acc 0 0 a
00) 1 0 a
10)
...)
.
val iter : (float -> unit) -> t -> unit
iter f a
is f a
00; f a
10;
...
val iteri : (int -> int -> float -> unit) -> t -> unit
iteri f a
is f 0 0 a
00; f 1 0 a
10;
...
Predicates and comparisons
val for_all : (float -> bool) -> t -> bool
for_all p a
is p a
00 && p a
10 &&
...
val exists : (float -> bool) -> t -> bool
exists p a
is p a
00 || p a
10 ||
...
val equal : t -> t -> bool
equal a b
is a = b
.
val equal_f : (float -> float -> bool) -> t -> t -> bool
equal_f eq a b
tests
a
and
b
like
Gg.M.equal
but
uses
eq
to test floating point values.
val compare : t -> t -> int
compare a b
is Pervasives.compare a b
. That is
lexicographic comparison in column-major order.
val compare_f : (float -> float -> int) -> t -> t -> int
compare_f cmp a b
compares
a
and
b
like
Gg.M.compare
but uses
cmp
to compare floating point values.
Printers
val to_string : t -> string
to_string a
is a textual representation of a
.
val pp : Format.formatter -> t -> unit
pp ppf a
prints a textual representation of a
on ppf
.
val pp_f : (Format.formatter -> float -> unit) -> Format.formatter -> t -> unit
pp_f pp_e ppf a
prints
a
like
Gg.M.pp
but uses
pp_e
to print floating point values.