Module Slap_Z.Vec

module Vec: sig .. end

module type CNTVEC = sig .. end
The signature of modules containing dynamically-sized contiguous vectors.
module type DSCVEC = sig .. end
The signature of modules containing dynamically-sized discrete vectors.
val cnt : ('n, Slap_misc.cnt) Slap_Z.vec -> ('n, 'cnt) Slap_Z.vec
Recover polymorphism of the fourth type parameter.

Creation of vectors


val empty : (Slap_size.z, 'cnt) Slap_Z.vec
An empty vector.
val create : 'n Slap_size.t -> ('n, 'cnt) Slap_Z.vec
create n
Returns a fresh n-dimensional vector (not initialized).
val make : 'n Slap_size.t -> Slap_Z.num_type -> ('n, 'cnt) Slap_Z.vec
make n a
Returns a fresh n-dimensional vector initialized with a.
val make0 : 'n Slap_size.t -> ('n, 'cnt) Slap_Z.vec
zeros n
Returns a fresh n-dimensional vector initialized with 0.
val make1 : 'n Slap_size.t -> ('n, 'cnt) Slap_Z.vec
make1 n
Returns a fresh n-dimensional vector initialized with 1.
val init : 'n Slap_size.t -> (int -> Slap_Z.num_type) -> ('n, 'cnt) Slap_Z.vec
init n f
Returns a fresh vector (f 1, ..., f n) with n elements.

Accessors


val dim : ('n, 'cd) Slap_Z.vec -> 'n Slap_size.t
dim x
Returns the dimension of the vector x.
val get_dyn : ('n, 'cd) Slap_Z.vec -> int -> Slap_Z.num_type
get_dyn x i
Returns the i-th element of the vector x.
val set_dyn : ('n, 'cd) Slap_Z.vec -> int -> Slap_Z.num_type -> unit
set_dyn x i a assigns a to the i-th element of the vector x.
val unsafe_get : ('n, 'cd) Slap_Z.vec -> int -> Slap_Z.num_type
Like get_dyn, but size checking is not always performed.
val unsafe_set : ('n, 'cd) Slap_Z.vec -> int -> Slap_Z.num_type -> unit
Like set_dyn, but size checking is not always performed.
val replace_dyn : ('n, 'cd) Slap_Z.vec -> int -> (Slap_Z.num_type -> Slap_Z.num_type) -> unit
replace_dyn v i f is set_dyn v i (f (get_dyn v i)).

Basic operations


val cons : ?y:('n Slap_size.s, 'y_cd) Slap_Z.vec ->
Slap_Z.num_type ->
('n, 'x_cd) Slap_Z.vec -> ('n Slap_size.s, 'y_cd) Slap_Z.vec
cons ?y e x adds element e at the beginning of vector x, and copies it into y.
Since 4.0.0
Returns the vector y, which is overwritten.
y : default = a fresh vector.
val hd : ('n Slap_size.s, 'x_cd) Slap_Z.vec -> Slap_Z.num_type
Since 4.0.0
Returns the first element of a given vector. (typesafe)
val hd_dyn : ('n, 'x_cd) Slap_Z.vec -> Slap_Z.num_type
Since 4.0.0
Returns the first element of a given vector.
val last : ('n Slap_size.s, 'x_cd) Slap_Z.vec -> Slap_Z.num_type
Since 4.0.0
Returns the last element of a given vector. (typesafe)
val last_dyn : ('n, 'x_cd) Slap_Z.vec -> Slap_Z.num_type
Since 4.0.0
Returns the last element of a given vector.
val tl : ?y:('n, 'y_cd) Slap_Z.vec ->
('n Slap_size.s, 'x_cd) Slap_Z.vec -> ('n, 'x_cd) Slap_Z.vec
Since 4.0.0
Returns a given vector without the first element. (typesafe)
val tl_dyn : ?y:('n Slap_size.p, 'y_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec -> ('n Slap_size.p, 'x_cd) Slap_Z.vec
Since 4.0.0
Returns a given vector without the first element.
val inits : ?y:('n, 'y_cd) Slap_Z.vec ->
('n Slap_size.s, 'x_cd) Slap_Z.vec -> ('n, 'x_cd) Slap_Z.vec
Since 4.0.0
Returns a given vector without the first element. (typesafe) This is the same as init in Haskell.
val inits_dyn : ?y:('n Slap_size.p, 'y_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec -> ('n Slap_size.p, 'x_cd) Slap_Z.vec
Since 4.0.0
Returns a given vector without the first element. This is the same as init in Haskell.
val copy : ?y:('n, 'y_cd) Slap_Z.vec -> ('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec
copy ?y x copies the vector x to the vector y with the BLAS-1 function [sdcz]copy.
Returns the vector y, which is overwritten.
y : default = a fresh vector.
val fill : ('n, 'cd) Slap_Z.vec -> Slap_Z.num_type -> unit
Fill the given vector with the given value.
val append : ('m, 'x_cd) Slap_Z.vec ->
('n, 'y_cd) Slap_Z.vec -> (('m, 'n) Slap_size.add, 'cnt) Slap_Z.vec
Concatenate two vectors.
val shared_rev : ('n, 'cd) Slap_Z.vec -> ('n, 'cd) Slap_Z.vec
shared_rev (x1, x2, ..., xn)
Returns reversed vector (xn, ..., x2, x1). The data are shared.
val rev : ('n, 'cd) Slap_Z.vec -> ('n, 'cd) Slap_Z.vec
rev (x1, x2, ..., xn)
Returns reversed vector (xn, ..., x2, x1). The data are NOT shared.

Type conversion


val to_array : ('n, 'cd) Slap_Z.vec -> Slap_Z.num_type array
to_array x
Returns the array of all the elements of the vector x.
val of_array_dyn : 'n Slap_size.t -> Slap_Z.num_type array -> ('n, 'cnt) Slap_Z.vec
of_array_dyn n [|a1; ...; an|]
Raises Invalid_argument the length of the given array is not equal to n.
Returns a fresh vector (a1, ..., an).
val of_array : Slap_Z.num_type array -> (module Slap_Z.Vec.CNTVEC)
module V = (val of_array [|a1; ...; an|] : CNTVEC)
Returns module V containing the vector V.value (= (a1, ..., an)) that has the type (V.n, 'cnt) vec with a generative phantom type V.n as a package of an existential quantified sized type like exists n. (n, 'cnt) vec.
module Of_array: 
functor (X : sig
val value : Slap_Z.num_type array
end) -> CNTVEC
A functor version of of_array.
val unsafe_of_array : 'n Slap_size.t -> Slap_Z.num_type array -> ('n, 'cnt) Slap_Z.vec
Like of_array_dyn, but size checking is not always performed.
Since 1.0.0
val to_list : ('n, 'cd) Slap_Z.vec -> Slap_Z.num_type list
to_list x
Returns the list of all the elements of the vector x.
val of_list_dyn : 'n Slap_size.t -> Slap_Z.num_type list -> ('n, 'cnt) Slap_Z.vec
of_list_dyn n [a1; ...; an]
Raises Invalid_argument the length of the given list is not equal to n.
Returns a fresh vector (a1, ..., an).
val of_list : Slap_Z.num_type list -> (module Slap_Z.Vec.CNTVEC)
module V = (val of_list [a1; ...; an] : CNTVEC)
Returns module V containing the vector V.value (= (a1, ..., an)) that has the type (V.n, 'cnt) vec with a generative phantom type V.n as a package of an existential quantified sized type like exists n. (n, 'cnt) vec.
module Of_list: 
functor (X : sig
val value : Slap_Z.num_type list
end) -> CNTVEC
A functor version of of_list.
val unsafe_of_list : 'n Slap_size.t -> Slap_Z.num_type list -> ('n, 'cnt) Slap_Z.vec
Like of_list_dyn, but size checking is not always performed.
Since 1.0.0
val to_bigarray : ('n, 'cd) Slap_Z.vec ->
(Slap_Z.num_type, Slap_Z.prec, Bigarray.fortran_layout) Bigarray.Array1.t
to_bigarray x
Returns the big array of all the elements of the vector x.
val of_bigarray_dyn : ?share:bool ->
'n Slap_size.t ->
(Slap_Z.num_type, Slap_Z.prec, Bigarray.fortran_layout) Bigarray.Array1.t ->
('n, 'cnt) Slap_Z.vec
of_bigarray_dyn ?share n ba
Raises Invalid_argument the length of the given big array is not equal to n.
Returns a fresh vector of all the elements of big array ba.
share : true if data are shared. (default = false)
val of_bigarray : ?share:bool ->
(Slap_Z.num_type, Slap_Z.prec, Bigarray.fortran_layout) Bigarray.Array1.t ->
(module Slap_Z.Vec.CNTVEC)
module V = (val of_bigarray ?share n ba : CNTVEC)
Returns module V containing the vector V.value (of all elements of big array ba) that has the type (V.n, 'cnt) vec with a generative phantom type V.n as a package of an existential quantified sized type like exists n. (n, 'cnt) vec.
share : true if data are shared. (default = false)
module Of_bigarray: 
functor (X : sig
val share : bool
val value : (Slap_Z.num_type, Slap_Z.prec, Bigarray.fortran_layout) Bigarray.Array1.t
end) -> CNTVEC
A functor version of of_bigarray.
val unsafe_of_bigarray : ?share:bool ->
'n Slap_size.t ->
(Slap_Z.num_type, Slap_Z.prec, Bigarray.fortran_layout) Bigarray.Array1.t ->
('n, 'cnt) Slap_Z.vec
Like of_bigarray_dyn, but size checking is not always performed.
Since 1.0.0
val of_array_c : Slap_Z.num_type array -> (Slap_Z.num_type, Slap_Z.prec, 'cnt) Slap_vec.dyn
let Slap.Vec.VEC n = of_array_c [|a1; ...; an|]
Since 4.0.0
Returns a constructor VEC that has a vector (a1, ..., an) that has the existential quantified sized type exists n. (n, 'num, 'prec, 'cnt_or_dsc) Vec.t. "c" of of_array_c means a "c"onstructor of GADT. This function is available in OCaml 4.00 or above.
val of_list_c : Slap_Z.num_type list -> (Slap_Z.num_type, Slap_Z.prec, 'cnt) Slap_vec.dyn
let Slap.Vec.VEC n = of_list_c [a1; ...; an]
Since 4.0.0
Returns a constructor VEC that has a vector (a1, ..., an) that has the existential quantified sized type exists n. (n, 'num, 'prec, 'cnt_or_dsc) Vec.t. "c" of of_list_c means a "c"onstructor of GADT. This function is available in OCaml 4.00 or above.
val of_bigarray_c : ?share:bool ->
(Slap_Z.num_type, Slap_Z.prec, Bigarray.fortran_layout) Bigarray.Array1.t ->
(Slap_Z.num_type, Slap_Z.prec, 'cnt) Slap_vec.dyn
let Slap.Vec.VEC n = of_bigarray_c ?share ba
Since 4.0.0
Returns a constructor VEC that has a vector (of all the elements of big array ba) that has the existential quantified sized type exists n. (n, 'num, 'prec, 'cnt_or_dsc) Vec.t. "c" of of_bigarray_c means a "c"onstructor of GADT. This function is available in OCaml 4.00 or above.
share : true if data are shared. (default = false)

Iterators


val map : (Slap_Z.num_type -> Slap_Z.num_type) ->
?y:('n, 'y_cd) Slap_Z.vec -> ('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec
map f ?y (x1, ..., xn) is (f x1, ..., f xn).
Returns the vector y, which is overwritten.
y : default = a fresh vector.
val mapi : (int -> Slap_Z.num_type -> Slap_Z.num_type) ->
?y:('n, 'y_cd) Slap_Z.vec -> ('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec
mapi f ?y (x1, ..., xn) is (f 1 x1, ..., f n xn) with the vector's dimension n.
Returns the vector y, which is overwritten.
y : default = a fresh vector.
val fold_left : ('accum -> Slap_Z.num_type -> 'accum) ->
'accum -> ('n, 'cd) Slap_Z.vec -> 'accum
fold_left f init (x1, x2, ..., xn) is f (... (f (f init x1) x2) ...) xn.
val fold_lefti : (int -> 'accum -> Slap_Z.num_type -> 'accum) ->
'accum -> ('n, 'cd) Slap_Z.vec -> 'accum
fold_lefti f init (x1, x2, ..., xn) is f n (... (f 2 (f 1 init x1) x2) ...) xn with the vector's dimension n.
val fold_right : (Slap_Z.num_type -> 'accum -> 'accum) ->
('n, 'cd) Slap_Z.vec -> 'accum -> 'accum
fold_right f (x1, x2, ..., xn) init is f x1 (f x2 (... (f xn init) ...)).
val fold_righti : (int -> Slap_Z.num_type -> 'accum -> 'accum) ->
('n, 'cd) Slap_Z.vec -> 'accum -> 'accum
fold_righti f (x1, x2, ..., xn) init is f 1 x1 (f 2 x2 (... (f n xn init) ...)) with the vector's dimension n.
val replace_all : ('n, 'cd) Slap_Z.vec -> (Slap_Z.num_type -> Slap_Z.num_type) -> unit
replace_all x f modifies the vector x in place -- the i-th element xi of x will be set to f xi.
val replace_alli : ('n, 'cd) Slap_Z.vec -> (int -> Slap_Z.num_type -> Slap_Z.num_type) -> unit
replace_alli x f modifies the vector x in place -- the i-th element xi of x will be set to f i xi.
val iter : (Slap_Z.num_type -> unit) -> ('n, 'cd) Slap_Z.vec -> unit
iter f (x1, x2, ..., xn) is f x1; f x2; ...; f xn.
val iteri : (int -> Slap_Z.num_type -> unit) -> ('n, 'cd) Slap_Z.vec -> unit
iteri f (x1, x2, ..., xn) is f 1 x1; f 2 x2; ...; f n xn.

Iterators on two vectors


val map2 : (Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type) ->
?z:('n, 'z_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec
map2 f ?z (x1, x2, ..., xn) (y1, y2, ..., yn) is (f x1 y1, f x2 y2, ..., f xn yn).
Returns the vector z, which is overwritten.
z : default = a fresh vector.
val mapi2 : (int -> Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type) ->
?z:('n, 'z_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec
mapi2 f ?z (x1, x2, ..., xn) (y1, y2, ..., yn) is (f 1 x1 y1, f 2 x2 y2, ..., f n xn yn) with the vectors' dimension n.
Returns the vector z, which is overwritten.
z : default = a fresh vector.
val fold_left2 : ('accum -> Slap_Z.num_type -> Slap_Z.num_type -> 'accum) ->
'accum -> ('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> 'accum
fold_left2 f init (x1, x2, ..., xn) (y1, y2, ..., yn) is f (... (f (f init x1 y1) x2 y2) ...) xn yn.
val fold_lefti2 : (int -> 'accum -> Slap_Z.num_type -> Slap_Z.num_type -> 'accum) ->
'accum -> ('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> 'accum
fold_lefti2 f init (x1, x2, ..., xn) (y1, y2, ..., yn) is f n (... (f 2 (f 1 init x1 y1) x2 y2) ...) xn yn with the vectors' dimension n.
val fold_right2 : (Slap_Z.num_type -> Slap_Z.num_type -> 'accum -> 'accum) ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> 'accum -> 'accum
fold_righti2 f (x1, x2, ..., xn) (y1, y2, ..., yn) init is f x1 y1 (f x2 y2 (... (f xn yn init) ...)).
val fold_righti2 : (int -> Slap_Z.num_type -> Slap_Z.num_type -> 'accum -> 'accum) ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> 'accum -> 'accum
fold_righti2 f (x1, x2, ..., xn) (y1, y2, ..., yn) init is f 1 x1 y1 (f 2 x2 y2 (... (f n xn yn init) ...)) with the vectors' dimension n.
val iter2 : (Slap_Z.num_type -> Slap_Z.num_type -> unit) ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> unit
iter2 f (x1, x2, ..., xn) (y1, y2, ..., yn) is f x1 y1; f x2 y2; ...; f xn yn.
val iteri2 : (int -> Slap_Z.num_type -> Slap_Z.num_type -> unit) ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> unit
iteri2 f (x1, x2, ..., xn) (y1, y2, ..., yn) is f 1 x1 y1; f 2 x2 y2; ...; f n xn yn.

Iterators on three vectors


val map3 : (Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type) ->
?w:('n, 'w_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec ->
('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec -> ('n, 'w_cd) Slap_Z.vec
map3 f ?w (x1, x2, ..., xn) (y1, y2, ..., yn) (z1, z2, ..., zn) is (f x1 y1 z1, f x2 y2 z2, ..., f xn yn zn).
Returns the vector w, which is overwritten.
w : default = a fresh vector.
val mapi3 : (int ->
Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type) ->
?w:('n, 'w_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec ->
('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec -> ('n, 'w_cd) Slap_Z.vec
mapi3 f ?w (x1, x2, ..., xn) (y1, y2, ..., yn) (z1, z2, ..., zn) is (f 1 x1 y1 z1, f 2 x2 y2 z2, ..., f n xn yn zn) with the vectors' dimension n.
Returns the vector w, which is overwritten.
w : default = a fresh vector.
val fold_left3 : ('accum -> Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type -> 'accum) ->
'accum ->
('n, 'x_cd) Slap_Z.vec ->
('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec -> 'accum
fold_left3 f init (x1, x2, ..., xn) (y1, y2, ..., yn) (z1, z2, ..., zn) is f (... (f (f init x1 y1 z1) x2 y2 z2) ...) xn yn zn.
val fold_lefti3 : (int ->
'accum -> Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type -> 'accum) ->
'accum ->
('n, 'x_cd) Slap_Z.vec ->
('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec -> 'accum
fold_lefti3 f init (x1, x2, ..., xn) (y1, y2, ..., yn) (z1, z2, ..., zn) is f n (... (f 2 (f 1 init x1 y1 z1) x2 y2 z2) ...) xn yn zn with the vectors' dimension n.
val fold_right3 : (Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type -> 'accum -> 'accum) ->
('n, 'x_cd) Slap_Z.vec ->
('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec -> 'accum -> 'accum
fold_right3 f (x1, x2, ..., xn) (y1, y2, ..., yn) (z1, z2, ..., zn) init is f x1 y1 z1 (f x2 y2 z2 (... (f xn yn zn init) ...)).
val fold_righti3 : (int ->
Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type -> 'accum -> 'accum) ->
('n, 'x_cd) Slap_Z.vec ->
('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec -> 'accum -> 'accum
fold_righti3 f (x1, x2, ..., xn) (y1, y2, ..., yn) (z1, z2, ..., zn) init is f 1 x1 y1 z1 (f 2 x2 y2 z2 (... (f n xn yn zn init) ...)) with the vectors' dimension n.
val iter3 : (Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type -> unit) ->
('n, 'x_cd) Slap_Z.vec ->
('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec -> unit
iter3 f (x1, x2, ..., xn) (y1, y2, ..., yn) (z1, z2, ..., zn) is f x1 y1 z1; f x2 y2 z2; ...; f xn yn zn.
val iteri3 : (int -> Slap_Z.num_type -> Slap_Z.num_type -> Slap_Z.num_type -> unit) ->
('n, 'x_cd) Slap_Z.vec ->
('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec -> unit
iteri3 f (x1, x2, ..., xn) (y1, y2, ..., yn) (z1, z2, ..., zn) is f 1 x1 y1 z1; f 2 x2 y2 z2; ...; f n xn yn zn.

Scanning


val for_all : (Slap_Z.num_type -> bool) -> ('n, 'cd) Slap_Z.vec -> bool
for_all p (x1, x2, ..., xn) is (p x1) && (p x2) && ... && (p xn).
Returns true if and only if all elements of the given vector satisfy the predicate p.
val exists : (Slap_Z.num_type -> bool) -> ('n, 'cd) Slap_Z.vec -> bool
exists p (x1, x2, ..., xn) is (p x1) || (p x2) || ... || (p xn).
Returns true if and only if at least one element of the given vector satisfies the predicate p.
val for_all2 : (Slap_Z.num_type -> Slap_Z.num_type -> bool) ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> bool
for_all2 p (x1, x2, ..., xn) (y1, y2, ..., yn) is (p x1 y1) && (p x2 y2) && ... && (p xn yn).
Returns true if and only if all elements of the given two vectors satisfy the predicate p.
val exists2 : (Slap_Z.num_type -> Slap_Z.num_type -> bool) ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> bool
exists2 p (x1, x2, ..., xn) (y1, y2, ..., yn) is (p x1 y1) || (p x2 y2) || ... || (p xn yn).
Returns true if and only if at least one pair of elements of the given two vectors satisfies the predicate p.

Arithmetic operations


val max : ('n, 'cd) Slap_Z.vec -> Slap_Z.num_type
max x
Returns the largest element in x. NaNs is ignored. If only NaNs are encountered, the negative infinity value is returned.
val min : ('n, 'cd) Slap_Z.vec -> Slap_Z.num_type
min x
Returns the smallest element in x. NaNs is ignored. If only NaNs are encountered, the positive infinity value is returned.
val sum : ('n, 'cd) Slap_Z.vec -> Slap_Z.num_type
sum x
Returns the sum of all elements in x.
val prod : ('n, 'cd) Slap_Z.vec -> Slap_Z.num_type
prod x
Returns the product of all elements in x.
val add_const : Slap_Z.num_type ->
?y:('n, 'y_cd) Slap_Z.vec -> ('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec
add_const c ?y x adds constant value c to all elements in vector x.
Since 0.1.0
Returns the vector y, which is overwritten.
val sqr_nrm2 : ?stable:bool -> ('n, 'cd) Slap_Z.vec -> float
sqr_nrm2 ?stable x computes the square of the 2-norm (Euclidean norm) of vector x.
stable : default = false.
val ssqr : ?c:Slap_Z.num_type -> ('n, 'cd) Slap_Z.vec -> Slap_Z.num_type
ssqr ?c (x1, x2, ..., xn) computes the sum of squared differences of the elements in the given vector from scalar value c: (x1 - c)^2 + (x2 - c)^2 + ... + (xn - c)^2.
c : default = 0.0.
val sort : ?cmp:(Slap_Z.num_type -> Slap_Z.num_type -> int) ->
?decr:bool ->
?p:('n, 'p_cd) Slap_common.int_vec -> ('n, 'x_cd) Slap_Z.vec -> unit
sort ?cmp ?decr ?p x sorts the elements in vector x in increasing order according to the comparison function cmp.
cmp : default = the usual order (on real numbers) or the lexicographic order (on complex numbers).
decr : sort in decreasing order.
p : If p is passed, x is unchanged and the permutation is stored into p. (default = None.)
val neg : ?y:('n, 'y_cd) Slap_Z.vec -> ('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec
neg ?y (x1, x2, ..., xn) returns (-x1, -x2, ..., -xn).
Returns the vector y, which is overwritten.
val reci : ?y:('n, 'y_cd) Slap_Z.vec -> ('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec
reci ?y (x1, x2, ..., xn) returns (1 / x1, 1 / x2, ..., 1 / xn).
Since 0.1.0
Returns the vector y, which is overwritten.
val add : ?z:('n, 'z_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec
add ?z (x1, x2, ..., xn) (y1, y2, ..., yn) returns (x1 + y1, x2 + y2, ..., xn + yn).
Returns the vector z, which is overwritten.
val sub : ?z:('n, 'z_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec
sub ?z (x1, x2, ..., xn) (y1, y2, ..., yn) returns (x1 - y1, x2 - y2, ..., xn - yn).
Returns the vector z, which is overwritten.
val mul : ?z:('n, 'z_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec
mul ?z (x1, x2, ..., xn) (y1, y2, ..., yn) returns (x1 * y1, x2 * y2, ..., xn * yn).
Returns the vector z, which is overwritten.
val div : ?z:('n, 'z_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec
div ?z (x1, x2, ..., xn) (y1, y2, ..., yn) returns (x1 / y1, x2 / y2, ..., xn / yn).
Returns the vector z, which is overwritten.
val zpxy : ('n, 'z_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec
zpxy (z1, z2, ..., zn) (x1, x2, ..., xn) (y1, y2, ..., yn) returns (z1 + x1 * y1, z2 + x2 * y2, ..., zn + xn * yn). This function is useful for convolutions.
Since 0.1.0
Returns the vector z, which is overwritten.
val zmxy : ('n, 'z_cd) Slap_Z.vec ->
('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> ('n, 'z_cd) Slap_Z.vec
zmxy (z1, z2, ..., zn) (x1, x2, ..., xn) (y1, y2, ..., yn) returns (z1 - x1 * y1, z2 - x2 * y2, ..., zn - xn * yn). This function is useful for convolutions.
Since 0.1.0
Returns the vector z, which is overwritten.
val ssqr_diff : ('n, 'x_cd) Slap_Z.vec -> ('n, 'y_cd) Slap_Z.vec -> Slap_Z.num_type
ssqr_diff x yreturns the sum of squared differences of the elements of vectors x and y.

Subvectors


val subcntvec_dyn : 'm Slap_size.t ->
?ofsx:int -> ('n, Slap_misc.cnt) Slap_Z.vec -> ('m, 'cnt) Slap_Z.vec
subcntvec_dyn m ?ofsx x
Raises Invalid_argument m and ofsx do not designate a valid subvector of x.
Returns a subvector of the contiguous vector x. The i-th element of it refers (ofsx+i-1)-th element of x. The data are shared.
ofsx : default = 1
val subdscvec_dyn : 'm Slap_size.t ->
?ofsx:int ->
?incx:int -> ('n, 'cd) Slap_Z.vec -> ('m, Slap_misc.dsc) Slap_Z.vec
subdscvec_dyn m ?ofsx ?incx x
Raises Invalid_argument m, ofsx and incx do not designate a valid subvector of x.
Returns a subvector of the vector x. The i-th element of it refers (ofsx+(i-1)*incx)-th element of x. The data are shared.
val subvec_dyn : 'm Slap_size.t ->
?ofsx:int ->
?incx:int -> ('n, 'cd) Slap_Z.vec -> ('m, Slap_misc.dsc) Slap_Z.vec
An alias of subdscvec_dyn.

Creation of vectors


val random : ?rnd_state:Random.State.t ->
?re_from:float ->
?re_range:float ->
?im_from:float -> ?im_range:float -> 'n Slap_size.t -> ('n, 'cnt) Slap_Z.vec
random ?rnd_state ?from ?range n creates a n-dimensional vector randomly initialized with the uniform distribution between re_from/im_from and re_from+re_range/im_from+im_range for real and imaginary parts, respectively.
rnd_state : default = Random.get_state ().
re_from : default = -1.0.
re_range : default = 2.0.
im_from : default = -1.0.
im_range : default = 2.0.