Module Gg.M2
type t= m2The type for 2D square matrices.
type v= v2The type for rows and columns as vectors.
Constructors, accessors and constants
val v : float -> float -> float -> float -> m2v e00 e01 e10 e11is a matrix whose components are specified in row-major order
val el : int -> int -> m2 -> floatel i j ais the elementaij. See also the direct element accessors.- raises Invalid_argument
if
iorjis not in [0;dim[.
Functions
val mul : m2 -> m2 -> m2mul a bis the matrix multiplicationa * b.
val trace : m2 -> floattrace ais the matrix tracetrace(a).
val det : m2 -> floatdet ais the determinant|a|.
val inv : m2 -> m2inv ais the inverse matrixa-1.
2D space transformations
val rot2 : float -> m2rot2 thetarotates 2D space around the origin bythetaradians.
Traversal
val mapi : (int -> int -> float -> float) -> m2 -> m2mapi f ais likemapbut the element indices are also given.
val fold : ('a -> float -> 'a) -> 'a -> m2 -> 'afold f acc aisf (...(f (f acc a00) a10)...).
val foldi : ('a -> int -> int -> float -> 'a) -> 'a -> m2 -> 'afoldi f acc aisf (...(f (f acc 0 0 a00) 1 0 a10)...).
val iter : (float -> unit) -> m2 -> unititer f aisf a00; f a10;...
val iteri : (int -> int -> float -> unit) -> m2 -> unititeri f aisf 0 0 a00; f 1 0 a10;...
Predicates and comparisons
val for_all : (float -> bool) -> m2 -> boolfor_all p aisp a00&& p a10&&...
val exists : (float -> bool) -> m2 -> boolexists p aisp a00|| p a10||...
val equal_f : (float -> float -> bool) -> m2 -> m2 -> boolequal_f eq a btestsaandblikeequalbut useseqto test floating point values.
Printers
val pp : Stdlib.Format.formatter -> m2 -> unitpp ppf aprints a textual representation ofaonppf.
val pp_f : (Stdlib.Format.formatter -> float -> unit) -> Stdlib.Format.formatter -> m2 -> unitpp_f pp_e ppf aprintsalikeppbut usespp_eto print floating point values.