Module Lacaml.Z.Vec

module Vec: sig .. end

val random : ?rnd_state:Random.State.t ->
?re_from:float ->
?re_range:float -> ?im_from:float -> ?im_range:float -> int -> Lacaml.Z.vec
random ?rnd_state ?re_from ?re_range ?im_from ?im_range n
Returns a vector of size n initialized with random elements sampled uniformly from re_range and im_range starting at re_from and im_from for real and imaginary numbers respectively. A random state rnd_state can be passed.
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
val create : int -> Lacaml.Z.vec
create n
Returns a vector with n rows (not initialized).
val make : int -> Lacaml.Z.num_type -> Lacaml.Z.vec
make n x
Returns a vector with n rows initialized with value x.
val make0 : int -> Lacaml.Z.vec
make0 n x
Returns a vector with n rows initialized with the zero element.
val init : int -> (int -> Lacaml.Z.num_type) -> Lacaml.Z.vec
init n f
Returns a vector containing n elements, where each element at position i is initialized by the result of calling f i.
val of_array : Lacaml.Z.num_type array -> Lacaml.Z.vec
of_array ar
Returns a vector initialized from array ar.
val to_array : Lacaml.Z.vec -> Lacaml.Z.num_type array
to_array v
Returns an array initialized from vector v.
val of_list : Lacaml.Z.num_type list -> Lacaml.Z.vec
of_list l
Returns a vector initialized from list l.
val to_list : Lacaml.Z.vec -> Lacaml.Z.num_type list
to_list v
Returns a list initialized from vector v.
val append : Lacaml.Z.vec -> Lacaml.Z.vec -> Lacaml.Z.vec
append v1 v2
Returns the vector resulting from appending vector v2 to v1.
val concat : Lacaml.Z.vec list -> Lacaml.Z.vec
concat vs
Returns the concatenation of vectors vs.
val empty : Lacaml.Z.vec
empty, the empty vector.
val linspace : ?y:Lacaml.Z.vec ->
Lacaml.Z.num_type -> Lacaml.Z.num_type -> int -> Lacaml.Z.vec
linspace ?z a b n
Returns the vector y overwritten with n linearly spaced points between and including a and b.
y : default = fresh vector of dim n
val logspace : ?y:Lacaml.Z.vec ->
Lacaml.Z.num_type -> Lacaml.Z.num_type -> ?base:float -> int -> Lacaml.Z.vec
logspace ?z a b base n
Returns the vector y overwritten with n points logarithmically spaced using base b between and including base ** a and base ** b.
y : default = fresh vector of dim n
base : default = 10.0
val dim : Lacaml.Z.vec -> int
dim x
Returns the dimension of vector x.
val map : (Lacaml.Z.num_type -> Lacaml.Z.num_type) ->
?n:int ->
?ofsy:int ->
?incy:int ->
?y:Lacaml.Z.vec -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> Lacaml.Z.vec
map f ?n ?ofsx ?incx x
Returns a new vector resulting from the application of f to each element of x.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
y : default = new vector with ofsy+(n-1)(abs incy) rows
ofsx : default = 1
incx : default = 1
val iter : (Lacaml.Z.num_type -> unit) ->
?n:int -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> unit
iter ?n ?ofsx ?incx f x applies function f in turn to all elements of vector x.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsx : default = 1
incx : default = 1
val iteri : (int -> Lacaml.Z.num_type -> unit) ->
?n:int -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> unit
iteri ?n ?ofsx ?incx f x same as iter but additionally passes the index of the element as first argument and the element itself as second argument.
val fold : ('a -> Lacaml.Z.num_type -> 'a) ->
'a -> ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> 'a
fold f a ?n ?ofsx ?incx x is f (... (f (f a x.{ofsx}) x.{ofsx + incx}) ...) x.{ofsx + (n-1)*incx} if incx > 0 and the same in the reverse order of appearance of the x values if incx < 0.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsx : default = 1
incx : default = 1
val fill : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> Lacaml.Z.num_type -> unit
fill ?n ?ofsx ?incx x a fills vector x with value a in the designated range.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsx : default = 1
incx : default = 1
val rev : Lacaml.Z.vec -> Lacaml.Z.vec
rev x reverses vector x (non-destructive).
val max : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> Lacaml.Z.num_type
max ?n ?ofsx ?incx x computes the greater of the n elements in vector x (2-norm), separated by incx incremental steps. NaNs are ignored. If only NaNs are encountered, the negative infinity value will be returned.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsx : default = 1
incx : default = 1
val min : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> Lacaml.Z.num_type
min ?n ?ofsx ?incx x computes the smaller of the n elements in vector x (2-norm), separated by incx incremental steps. NaNs are ignored. If only NaNs are encountered, the infinity value will be returned.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsx : default = 1
incx : default = 1
val sum : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> Lacaml.Z.num_type
sum ?n ?ofsx ?incx x computes the sum of the n elements in vector x, separated by incx incremental steps.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsx : default = 1
incx : default = 1
val prod : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> Lacaml.Z.num_type
prod ?n ?ofsx ?incx x computes the product of the n elements in vector x, separated by incx incremental steps.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsx : default = 1
incx : default = 1
val add_const : Lacaml.Z.num_type ->
?n:int ->
?ofsy:int ->
?incy:int ->
?y:Lacaml.Z.vec -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> Lacaml.Z.vec
add_const c ?n ?ofsy ?incy ?y ?ofsx ?incx x adds constant c to the n elements of vector x and stores the result in y, using incx and incy as incremental steps respectively. If y is given, the result will be stored in there using increments of incy, otherwise a fresh vector will be used. The resulting vector is returned.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsy : default = 1
incy : default = 1
y : default = fresh vector with ofsy+(n - 1)(abs incy) rows
ofsx : default = 1
incx : default = 1
val sqr_nrm2 : ?stable:bool -> ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> float
sqr_nrm2 ?stable ?n ?c ?ofsx ?incx x computes the square of the 2-norm (Euclidean norm) of vector x separated by incx incremental steps. If stable is true, this is equivalent to squaring the result of calling the BLAS-function nrm2, which avoids over- and underflow if possible. If stable is false (default), dot will be called instead for greatly improved performance.
stable : default = false
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsx : default = 1
incx : default = 1
val ssqr : ?n:int ->
?c:Lacaml.Z.num_type ->
?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> Lacaml.Z.num_type
ssqr ?n ?c ?ofsx ?incx x computes the sum of squared differences of the n elements in vector x from constant c, separated by incx incremental steps. Please do not confuse with Lacaml.Z.Vec.sqr_nrm2! The current function behaves differently with complex numbers when zero is passed in for c. It computes the square for each entry then, whereas Lacaml.Z.Vec.sqr_nrm2 uses the conjugate transpose in the product. The latter will therefore always return a real number.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
c : default = zero
ofsx : default = 1
incx : default = 1
val sort : ?cmp:(Lacaml.Z.num_type -> Lacaml.Z.num_type -> int) ->
?decr:bool ->
?n:int ->
?ofsp:int ->
?incp:int ->
?p:Lacaml.Common.int_vec -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> unit
sort ?cmp ?n ?ofsx ?incx x sorts the array x in increasing order according to the comparison function cmp.
cmp : a function such that cmp a b < 0 if a is less than b, cmp a b = 0 if a equal b and cmp a b > 0 if a is greater than b for the desired order. Default: the usual order on floating point values or the lexicographic order on complex ones (a special routine makes it fast). Whatever the order you choose, NaNs (in any component for complex numbers) are considered larger than any other value (so they will be last, in no specified order, in the sorted vector). Therefore, NaN are never passed to cmp.
decr : sort in decreasing order (stays fast for the default cmp).
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsp : default = 1
incp : default = 1
p : if you pass a vector of size ofsp+(n - 1)(abs incp), the vector x will be unchanged and the permutation to sort it will be stored in p. Thus x.{p.{ofsp + (i-1) * incp}} will give the elements of x in increasing order. Default: no vector is provided.
ofsx : default = 1
incx : default = 1
val neg : ?n:int ->
?ofsy:int ->
?incy:int ->
?y:Lacaml.Z.vec -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> Lacaml.Z.vec
neg ?n ?ofsy ?incy ?y ?ofsx ?incx x negates n elements of the vector x using incx as incremental steps. If y is given, the result will be stored in there using increments of incy, otherwise a fresh vector will be used. The resulting vector is returned.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsy : default = 1
incy : default = 1
y : default = fresh vector with ofsy+(n - 1)(abs incy) rows
ofsx : default = 1
incx : default = 1
val reci : ?n:int ->
?ofsy:int ->
?incy:int ->
?y:Lacaml.Z.vec -> ?ofsx:int -> ?incx:int -> Lacaml.Z.vec -> Lacaml.Z.vec
reci ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the reciprocal value of n elements of the vector x using incx as incremental steps. If y is given, the result will be stored in there using increments of incy, otherwise a fresh vector will be used. The resulting vector is returned.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsy : default = 1
incy : default = 1
y : default = fresh vector with ofsy+(n - 1)(abs incy) rows
ofsx : default = 1
incx : default = 1
val add : ?n:int ->
?ofsz:int ->
?incz:int ->
?z:Lacaml.Z.vec ->
?ofsx:int ->
?incx:int ->
Lacaml.Z.vec -> ?ofsy:int -> ?incy:int -> Lacaml.Z.vec -> Lacaml.Z.vec
add ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y adds n elements of vectors x and y elementwise, using incx and incy as incremental steps respectively. If z is given, the result will be stored in there using increments of incz, otherwise a fresh vector will be used. The resulting vector is returned.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsz : default = 1
incz : default = 1
z : default = fresh vector with ofsz+(n - 1)(abs incz) rows
ofsx : default = 1
incx : default = 1
ofsy : default = 1
incy : default = 1
val sub : ?n:int ->
?ofsz:int ->
?incz:int ->
?z:Lacaml.Z.vec ->
?ofsx:int ->
?incx:int ->
Lacaml.Z.vec -> ?ofsy:int -> ?incy:int -> Lacaml.Z.vec -> Lacaml.Z.vec
sub ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y subtracts n elements of vectors x and y elementwise, using incx and incy as incremental steps respectively. If z is given, the result will be stored in there using increments of incz, otherwise a fresh vector will be used. The resulting vector is returned.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsz : default = 1
incz : default = 1
z : default = fresh vector with ofsz+(n - 1)(abs incz) rows
ofsx : default = 1
incx : default = 1
ofsy : default = 1
incy : default = 1
val mul : ?n:int ->
?ofsz:int ->
?incz:int ->
?z:Lacaml.Z.vec ->
?ofsx:int ->
?incx:int ->
Lacaml.Z.vec -> ?ofsy:int -> ?incy:int -> Lacaml.Z.vec -> Lacaml.Z.vec
mul ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y multiplies n elements of vectors x and y elementwise, using incx and incy as incremental steps respectively. If z is given, the result will be stored in there using increments of incz, otherwise a fresh vector will be used. The resulting vector is returned.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsz : default = 1
incz : default = 1
z : default = fresh vector with ofsz+(n - 1)(abs incz) rows
ofsx : default = 1
incx : default = 1
ofsy : default = 1
incy : default = 1
val div : ?n:int ->
?ofsz:int ->
?incz:int ->
?z:Lacaml.Z.vec ->
?ofsx:int ->
?incx:int ->
Lacaml.Z.vec -> ?ofsy:int -> ?incy:int -> Lacaml.Z.vec -> Lacaml.Z.vec
div ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y divides n elements of vectors x and y elementwise, using incx and incy as incremental steps respectively. If z is given, the result will be stored in there using increments of incz, otherwise a fresh vector will be used. The resulting vector is returned.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsz : default = 1
incz : default = 1
z : default = fresh vector with ofsz+(n - 1)(abs incz) rows
ofsx : default = 1
incx : default = 1
ofsy : default = 1
incy : default = 1
val zpxy : ?n:int ->
?ofsz:int ->
?incz:int ->
?z:Lacaml.Z.vec ->
?ofsx:int ->
?incx:int ->
Lacaml.Z.vec -> ?ofsy:int -> ?incy:int -> Lacaml.Z.vec -> Lacaml.Z.vec
zpxy ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y multiplies n elements of vectors x and y elementwise, using incx and incy as incremental steps respectively, and adds the result to and stores it in the specified range in z if provided. If z is given, the result will be stored in there using increments of incz, otherwise a fresh vector will be used and assumed to be zero. The resulting vector is returned. This function is useful for convolutions.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsz : default = 1
incz : default = 1
z : default = fresh vector with ofsz+(n - 1)(abs incz) rows
ofsx : default = 1
incx : default = 1
ofsy : default = 1
incy : default = 1
val zmxy : ?n:int ->
?ofsz:int ->
?incz:int ->
?z:Lacaml.Z.vec ->
?ofsx:int ->
?incx:int ->
Lacaml.Z.vec -> ?ofsy:int -> ?incy:int -> Lacaml.Z.vec -> Lacaml.Z.vec
zmxy ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y multiplies n elements of vectors x and y elementwise, using incx and incy as incremental steps respectively, and substracts the result from and stores it in the specified range in z if provided. If z is given, the result will be stored in there using increments of incz, otherwise a fresh vector will be used and assumed to be zero. The resulting vector is returned. This function is useful for convolutions.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsz : default = 1
incz : default = 1
z : default = fresh vector with ofsz+(n - 1)(abs incz) rows
ofsx : default = 1
incx : default = 1
ofsy : default = 1
incy : default = 1
val ssqr_diff : ?n:int ->
?ofsx:int ->
?incx:int ->
Lacaml.Z.vec -> ?ofsy:int -> ?incy:int -> Lacaml.Z.vec -> Lacaml.Z.num_type
ssqr_diff ?n ?ofsx ?incx x ?ofsy ?incy y returns the sum of squared differences of n elements of vectors x and y, using incx and incy as incremental steps respectively.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
ofsx : default = 1
incx : default = 1
ofsy : default = 1
incy : default = 1