Module Gg.M2

module M2: sig .. end

type t = Gg.m2 
The type for 2D square matrices.
val dim : int
dim is the dimension of rows and columns.
type v = Gg.v2 
The type for rows and columns as vectors.

Constructors, accessors and constants

val v : float -> float -> float -> float -> Gg.m2
v e00 e01 e10 e11 is a matrix whose components are specified in row-major order
val of_rows : Gg.v2 -> Gg.v2 -> Gg.m2
of_rows r0 r1 is the matrix whose rows are r0 and r1.
val of_cols : Gg.v2 -> Gg.v2 -> Gg.m2
of_cols c0 c1 is the matrix whose columns are c0 and c1.
val el : int -> int -> Gg.m2 -> float
el i j a is the element aij. See also the direct element accessors.
Raises Invalid_argument if i or j is not in [0;Gg.M2.dim[.
val row : int -> Gg.m2 -> Gg.v2
row i a is the ith row of a.
Raises Invalid_argument if i is not in [0;Gg.M2.dim[.
val col : int -> Gg.m2 -> Gg.v2
col j a is the jth column of a.
Raises Invalid_argument if j is not in [0;Gg.M2.dim[.
val zero : Gg.m2
zero is the neutral element for Gg.M2.add.
val id : Gg.m2
id is the identity matrix, the neutral element for Gg.M2.mul.
val of_m3 : Gg.m3 -> Gg.m2
of_m3 m extracts the 2D linear part (top-left 2x2 matrix) of m.
val of_m4 : Gg.m4 -> Gg.m2
of_m4 m extracts the 2D linear part (top-left 2x2 matrix) of m.


val neg : Gg.m2 -> Gg.m2
neg a is the negated matrix -a.
val add : Gg.m2 -> Gg.m2 -> Gg.m2
add a b is the matrix addition a + b.
val sub : Gg.m2 -> Gg.m2 -> Gg.m2
sub a b is the matrix subtraction a - b.
val mul : Gg.m2 -> Gg.m2 -> Gg.m2
mul a b is the matrix multiplication a * b.
val emul : Gg.m2 -> Gg.m2 -> Gg.m2
emul a b is the element wise multiplication of a and b.
val ediv : Gg.m2 -> Gg.m2 -> Gg.m2
ediv a b is the element wise division of a and b.
val smul : float -> Gg.m2 -> Gg.m2
smul s a is a's elements multiplied by the scalar s.
val transpose : Gg.m2 -> Gg.m2
transpose a is the transpose aT.
val trace : Gg.m2 -> float
trace a is the matrix trace trace(a).
val det : Gg.m2 -> float
det a is the determinant |a|.
val inv : Gg.m2 -> Gg.m2
inv a is the inverse matrix a-1.

2D space transformations

val rot2 : float -> Gg.m2
rot2 theta rotates 2D space around the origin by theta radians.
val scale2 : Gg.v2 -> Gg.m2
scale2 s scales 2D space in the x and y dimensions according to s.


val map : (float -> float) -> Gg.m2 -> Gg.m2
map f a is the element wise application of f to a.
val mapi : (int -> int -> float -> float) -> Gg.m2 -> Gg.m2
mapi f a is like but the element indices are also given.
val fold : ('a -> float -> 'a) -> 'a -> Gg.m2 -> 'a
fold f acc a is f (...(f (f acc a00) a10)...).
val foldi : ('a -> int -> int -> float -> 'a) -> 'a -> Gg.m2 -> 'a
foldi f acc a is f (...(f (f acc 0 0 a00) 1 0 a10)...).
val iter : (float -> unit) -> Gg.m2 -> unit
iter f a is f a00; f a10; ...
val iteri : (int -> int -> float -> unit) -> Gg.m2 -> unit
iteri f a is f 0 0 a00; f 1 0 a10; ...

Predicates and comparisons

val for_all : (float -> bool) -> Gg.m2 -> bool
for_all p a is p a00 && p a10 && ...
val exists : (float -> bool) -> Gg.m2 -> bool
exists p a is p a00 || p a10 || ...
val equal : Gg.m2 -> Gg.m2 -> bool
equal a b is a = b.
val equal_f : (float -> float -> bool) -> Gg.m2 -> Gg.m2 -> bool
equal_f eq a b tests a and b like Gg.M2.equal but uses eq to test floating point values.
val compare : Gg.m2 -> Gg.m2 -> int
compare a b is a b. That is lexicographic comparison in column-major order.
val compare_f : (float -> float -> int) -> Gg.m2 -> Gg.m2 -> int
compare_f cmp a b compares a and b like but uses cmp to compare floating point values.


val pp : Format.formatter -> Gg.m2 -> unit
pp ppf a prints a textual representation of a on ppf.
val pp_f : (Format.formatter -> float -> unit) -> Format.formatter -> Gg.m2 -> unit
pp_f pp_e ppf a prints a like Gg.M2.pp but uses pp_e to print floating point values.

Element accessors

val e00 : Gg.m2 -> float
val e01 : Gg.m2 -> float
val e10 : Gg.m2 -> float
val e11 : Gg.m2 -> float