package slap

  1. Overview
  2. Docs
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) vec -> ('n, 'cnt) vec

Recover polymorphism of the fourth type parameter.

Creation of vectors

val empty : (Slap_size.z, 'cnt) vec

An empty vector.

val create : 'n Slap_size.t -> ('n, 'cnt) vec

create n

  • returns

    a fresh n-dimensional vector (not initialized).

val make : 'n Slap_size.t -> num_type -> ('n, 'cnt) vec

make n a

  • returns

    a fresh n-dimensional vector initialized with a.

val make0 : 'n Slap_size.t -> ('n, 'cnt) vec

zeros n

  • returns

    a fresh n-dimensional vector initialized with 0.

val make1 : 'n Slap_size.t -> ('n, 'cnt) vec

make1 n

  • returns

    a fresh n-dimensional vector initialized with 1.

val init : 'n Slap_size.t -> (int -> num_type) -> ('n, 'cnt) vec

init n f

  • returns

    a fresh vector (f 1, ..., f n) with n elements.

Accessors

val dim : ('n, 'cd) vec -> 'n Slap_size.t

dim x

  • returns

    the dimension of the vector x.

val get_dyn : ('n, 'cd) vec -> int -> num_type

get_dyn x i

  • returns

    the i-th element of the vector x.

val set_dyn : ('n, 'cd) vec -> int -> num_type -> unit

set_dyn x i a assigns a to the i-th element of the vector x.

val unsafe_get : ('n, 'cd) vec -> int -> num_type

Like get_dyn, but size checking is not always performed.

val unsafe_set : ('n, 'cd) vec -> int -> num_type -> unit

Like set_dyn, but size checking is not always performed.

val replace_dyn : ('n, 'cd) vec -> int -> (num_type -> 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) vec -> num_type -> ('n, 'x_cd) vec -> ('n Slap_size.s, 'y_cd) vec

cons ?y e x adds element e at the beginning of vector x, and copies it into y.

  • returns

    the vector y, which is overwritten.

  • parameter y

    default = a fresh vector.

  • since 4.0.0
val hd : ('n Slap_size.s, 'x_cd) vec -> num_type
  • returns

    the first element of a given vector. (typesafe)

  • since 4.0.0
val hd_dyn : ('n, 'x_cd) vec -> num_type
  • returns

    the first element of a given vector.

  • since 4.0.0
val last : ('n Slap_size.s, 'x_cd) vec -> num_type
  • returns

    the last element of a given vector. (typesafe)

  • since 4.0.0
val last_dyn : ('n, 'x_cd) vec -> num_type
  • returns

    the last element of a given vector.

  • since 4.0.0
val tl : ?y:('n, 'y_cd) vec -> ('n Slap_size.s, 'x_cd) vec -> ('n, 'x_cd) vec
  • returns

    a given vector without the first element. (typesafe)

  • since 4.0.0
val tl_dyn : ?y:('n Slap_size.p, 'y_cd) vec -> ('n, 'x_cd) vec -> ('n Slap_size.p, 'x_cd) vec
  • returns

    a given vector without the first element.

  • since 4.0.0
val inits : ?y:('n, 'y_cd) vec -> ('n Slap_size.s, 'x_cd) vec -> ('n, 'x_cd) vec
  • returns

    a given vector without the first element. (typesafe) This is the same as init in Haskell.

  • since 4.0.0
val inits_dyn : ?y:('n Slap_size.p, 'y_cd) vec -> ('n, 'x_cd) vec -> ('n Slap_size.p, 'x_cd) vec
  • returns

    a given vector without the first element. This is the same as init in Haskell.

  • since 4.0.0
val copy : ?y:('n, 'y_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) 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.

  • parameter y

    default = a fresh vector.

val fill : ('n, 'cd) vec -> num_type -> unit

Fill the given vector with the given value.

val append : ('m, 'x_cd) vec -> ('n, 'y_cd) vec -> (('m, 'n) Slap_size.add, 'cnt) vec

Concatenate two vectors.

val shared_rev : ('n, 'cd) vec -> ('n, 'cd) vec

shared_rev (x1, x2, ..., xn)

  • returns

    reversed vector (xn, ..., x2, x1). The data are shared.

val rev : ('n, 'cd) vec -> ('n, 'cd) vec

rev (x1, x2, ..., xn)

  • returns

    reversed vector (xn, ..., x2, x1). The data are NOT shared.

Type conversion

val to_array : ('n, 'cd) vec -> 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 -> num_type array -> ('n, 'cnt) vec

of_array_dyn n [|a1; ...; an|]

  • returns

    a fresh vector (a1, ..., an).

val of_array : num_type array -> (module 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 (X : sig ... end) : CNTVEC

A functor version of of_array.

val unsafe_of_array : 'n Slap_size.t -> num_type array -> ('n, 'cnt) vec

Like of_array_dyn, but size checking is not always performed.

  • since 1.0.0
val to_list : ('n, 'cd) vec -> 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 -> num_type list -> ('n, 'cnt) vec

of_list_dyn n [a1; ...; an]

  • returns

    a fresh vector (a1, ..., an).

val of_list : num_type list -> (module 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 (X : sig ... end) : CNTVEC

A functor version of of_list.

val unsafe_of_list : 'n Slap_size.t -> num_type list -> ('n, 'cnt) vec

Like of_list_dyn, but size checking is not always performed.

  • since 1.0.0
val to_bigarray : ('n, 'cd) vec -> (num_type, 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 -> (num_type, prec, Bigarray.fortran_layout) Bigarray.Array1.t -> ('n, 'cnt) vec

of_bigarray_dyn ?share n ba

  • returns

    a fresh vector of all the elements of big array ba.

  • parameter share

    true if data are shared. (default = false)

val of_bigarray : ?share:bool -> (num_type, prec, Bigarray.fortran_layout) Bigarray.Array1.t -> (module 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.

  • parameter share

    true if data are shared. (default = false)

module Of_bigarray (X : sig ... end) : CNTVEC

A functor version of of_bigarray.

val unsafe_of_bigarray : ?share:bool -> 'n Slap_size.t -> (num_type, prec, Bigarray.fortran_layout) Bigarray.Array1.t -> ('n, 'cnt) vec

Like of_bigarray_dyn, but size checking is not always performed.

  • since 1.0.0
val of_array_c : num_type array -> (num_type, prec, 'cnt) Slap_vec.dyn

let Slap.Vec.VEC n = of_array_c [|a1; ...; an|]

  • 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.

  • since 4.0.0
val of_list_c : num_type list -> (num_type, prec, 'cnt) Slap_vec.dyn

let Slap.Vec.VEC n = of_list_c [a1; ...; an]

  • 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.

  • since 4.0.0
val of_bigarray_c : ?share:bool -> (num_type, prec, Bigarray.fortran_layout) Bigarray.Array1.t -> (num_type, prec, 'cnt) Slap_vec.dyn

let Slap.Vec.VEC n = of_bigarray_c ?share ba

  • 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.

  • parameter share

    true if data are shared. (default = false)

  • since 4.0.0

Iterators

val map : (num_type -> num_type) -> ?y:('n, 'y_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec

map f ?y (x1, ..., xn) is (f x1, ..., f xn).

  • returns

    the vector y, which is overwritten.

  • parameter y

    default = a fresh vector.

val mapi : (int -> num_type -> num_type) -> ?y:('n, 'y_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) 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.

  • parameter y

    default = a fresh vector.

val fold_left : ('accum -> num_type -> 'accum) -> 'accum -> ('n, 'cd) vec -> 'accum

fold_left f init (x1, x2, ..., xn) is f (... (f (f init x1) x2) ...) xn.

val fold_lefti : (int -> 'accum -> num_type -> 'accum) -> 'accum -> ('n, 'cd) 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 : (num_type -> 'accum -> 'accum) -> ('n, 'cd) vec -> 'accum -> 'accum

fold_right f (x1, x2, ..., xn) init is f x1 (f x2 (... (f xn init) ...)).

val fold_righti : (int -> num_type -> 'accum -> 'accum) -> ('n, 'cd) 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) vec -> (num_type -> 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) vec -> (int -> num_type -> 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 : (num_type -> unit) -> ('n, 'cd) vec -> unit

iter f (x1, x2, ..., xn) is f x1; f x2; ...; f xn.

val iteri : (int -> num_type -> unit) -> ('n, 'cd) vec -> unit

iteri f (x1, x2, ..., xn) is f 1 x1; f 2 x2; ...; f n xn.

Iterators on two vectors

val map2 : (num_type -> num_type -> num_type) -> ?z:('n, 'z_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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.

  • parameter z

    default = a fresh vector.

val mapi2 : (int -> num_type -> num_type -> num_type) -> ?z:('n, 'z_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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.

  • parameter z

    default = a fresh vector.

val fold_left2 : ('accum -> num_type -> num_type -> 'accum) -> 'accum -> ('n, 'x_cd) vec -> ('n, 'y_cd) 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 -> num_type -> num_type -> 'accum) -> 'accum -> ('n, 'x_cd) vec -> ('n, 'y_cd) 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 : (num_type -> num_type -> 'accum -> 'accum) -> ('n, 'x_cd) vec -> ('n, 'y_cd) 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 -> num_type -> num_type -> 'accum -> 'accum) -> ('n, 'x_cd) vec -> ('n, 'y_cd) 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 : (num_type -> num_type -> unit) -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> unit

iter2 f (x1, x2, ..., xn) (y1, y2, ..., yn) is f x1 y1; f x2 y2; ...; f xn yn.

val iteri2 : (int -> num_type -> num_type -> unit) -> ('n, 'x_cd) vec -> ('n, 'y_cd) 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 : (num_type -> num_type -> num_type -> num_type) -> ?w:('n, 'w_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) vec -> ('n, 'w_cd) 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.

  • parameter w

    default = a fresh vector.

val mapi3 : (int -> num_type -> num_type -> num_type -> num_type) -> ?w:('n, 'w_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) vec -> ('n, 'w_cd) 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.

  • parameter w

    default = a fresh vector.

val fold_left3 : ('accum -> num_type -> num_type -> num_type -> 'accum) -> 'accum -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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 -> num_type -> num_type -> num_type -> 'accum) -> 'accum -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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 : (num_type -> num_type -> num_type -> 'accum -> 'accum) -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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 -> num_type -> num_type -> num_type -> 'accum -> 'accum) -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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 : (num_type -> num_type -> num_type -> unit) -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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 -> num_type -> num_type -> num_type -> unit) -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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 : (num_type -> bool) -> ('n, 'cd) 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 : (num_type -> bool) -> ('n, 'cd) 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 : (num_type -> num_type -> bool) -> ('n, 'x_cd) vec -> ('n, 'y_cd) 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 : (num_type -> num_type -> bool) -> ('n, 'x_cd) vec -> ('n, 'y_cd) 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) vec -> 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) vec -> 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) vec -> num_type

sum x

  • returns

    the sum of all elements in x.

val prod : ('n, 'cd) vec -> num_type

prod x

  • returns

    the product of all elements in x.

val add_const : num_type -> ?y:('n, 'y_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec

add_const c ?y x adds constant value c to all elements in vector x.

  • returns

    the vector y, which is overwritten.

  • since 0.1.0
val sqr_nrm2 : ?stable:bool -> ('n, 'cd) vec -> float

sqr_nrm2 ?stable x computes the square of the 2-norm (Euclidean norm) of vector x.

  • parameter stable

    default = false.

    • If stable = true, BLAS function nrm2 is used;
    • If stable = false, BLAS function dot is used instead for greatly improved performance.
val ssqr : ?c:num_type -> ('n, 'cd) vec -> 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.

  • parameter c

    default = 0.0.

val sort : ?cmp:(num_type -> num_type -> int) -> ?decr:bool -> ?p:('n, 'p_cd) Slap_common.int_vec -> ('n, 'x_cd) vec -> unit

sort ?cmp ?decr ?p x sorts the elements in vector x in increasing order according to the comparison function cmp.

  • parameter cmp

    default = the usual order (on real numbers) or the lexicographic order (on complex numbers).

    • cmp a b < 0 iff a < b;
    • cmp a b = 0 iff a = b;
    • cmp a b > 0 iff a > b.
    • NaNs must be considered larger than any other value.
  • parameter decr

    sort in decreasing order.

  • parameter p

    If p is passed, x is unchanged and the permutation is stored into p. (default = None.)

val neg : ?y:('n, 'y_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec

neg ?y (x1, x2, ..., xn) returns (-x1, -x2, ..., -xn).

  • returns

    the vector y, which is overwritten.

val reci : ?y:('n, 'y_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec

reci ?y (x1, x2, ..., xn) returns (1 / x1, 1 / x2, ..., 1 / xn).

  • returns

    the vector y, which is overwritten.

  • since 0.1.0
val add : ?z:('n, 'z_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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.

  • returns

    the vector z, which is overwritten.

  • since 0.1.0
val zmxy : ('n, 'z_cd) vec -> ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> ('n, 'z_cd) 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.

  • returns

    the vector z, which is overwritten.

  • since 0.1.0
val ssqr_diff : ('n, 'x_cd) vec -> ('n, 'y_cd) vec -> 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) vec -> ('m, 'cnt) vec

subcntvec_dyn m ?ofsx 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.

  • parameter ofsx

    default = 1

val subdscvec_dyn : 'm Slap_size.t -> ?ofsx:int -> ?incx:int -> ('n, 'cd) vec -> ('m, Slap_misc.dsc) vec

subdscvec_dyn m ?ofsx ?incx 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.

  • parameter ofs

    default = 1

  • parameter inc

    default = 1

  • raises Invalid_argument

    m, ofsx and incx do not designate a valid subvector of x.

val subvec_dyn : 'm Slap_size.t -> ?ofsx:int -> ?incx:int -> ('n, 'cd) vec -> ('m, Slap_misc.dsc) 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) 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.

  • parameter rnd_state

    default = Random.get_state ().

  • parameter re_from

    default = -1.0.

  • parameter re_range

    default = 2.0.

  • parameter im_from

    default = -1.0.

  • parameter im_range

    default = 2.0.

OCaml

Innovation. Community. Security.