Module type Gg.V
Implemented by all vector types.
val dim : int
dim
is the dimension of vectors of typet
.
type m
The type for matrices representing linear transformations of
dim
space.
Constructors, accessors and constants
val comp : int -> t -> float
comp i v
isv
i
, thei
th component ofv
.- raises Invalid_argument
if
i
is not in [0;
dim
[.
val infinity : t
infinity
is the vector whose components areinfinity
.
val neg_infinity : t
neg_infinity
is the vector whose components areneg_infinity
.
val basis : int -> t
basis i
is thei
th vector of an orthonormal basis of the vector spacet
with inner productdot
.- raises Invalid_argument
if
i
is not in [0;
dim
[.
Functions
val dot : t -> t -> float
dot u v
is the dot productu.v
.
val norm : t -> float
norm v
is the norm|v| = sqrt v.v
.
val norm2 : t -> float
norm2 v
is the squared norm|v|
2 .
val homogene : t -> t
homogene v
is the vectorv/(comp (dim - 1) v)
ifcomp (dim - 1) v <> 0
andv
otherwise.
val ltr : m -> t -> t
ltr m v
is the linear transformmv
.
Overridden Pervasives
operators
Traversal
val mapi : (int -> float -> float) -> t -> t
mapi f v
is likemap
but the component index is also given.
val fold : ('a -> float -> 'a) -> 'a -> t -> 'a
fold f acc v
isf (
...(f (f acc v
0) v
1)
...)
.
val foldi : ('a -> int -> float -> 'a) -> 'a -> t -> 'a
foldi f acc v
isf (
...(f (f acc 0 v
0) 1 v
1)
...)
.
val iter : (float -> unit) -> t -> unit
iter f v
isf v
0; f v
1;
...
val iteri : (int -> float -> unit) -> t -> unit
iteri f v
isf 0 v
0; f 1 v
1;
...
Predicates and comparisons
val for_all : (float -> bool) -> t -> bool
for_all p v
isp v
0&& p v
1&&
...
val exists : (float -> bool) -> t -> bool
exists p v
isp v
0|| p v
1||
...
Printers
val pp : Stdlib.Format.formatter -> t -> unit
pp ppf v
prints a textual representation ofv
onppf
.
val pp_f : (Stdlib.Format.formatter -> float -> unit) -> Stdlib.Format.formatter -> t -> unit
pp_f pp_comp ppf v
printsv
likepp
but usespp_comp
to print floating point values.