module Vec:sig..end
typet =Lacaml__S.vec
typeunop =?n:int ->
?ofsy:int ->
?incy:int ->
?y:Lacaml__S.vec -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> Lacaml__S.vec
typebinop =?n:int ->
?ofsz:int ->
?incz:int ->
?z:Lacaml__S.vec ->
?ofsx:int ->
?incx:int ->
Lacaml__S.vec -> ?ofsy:int -> ?incy:int -> Lacaml__S.vec -> Lacaml__S.vec
val random : ?rnd_state:Stdlib.Random.State.t ->
?from:float -> ?range:float -> int -> Lacaml__S.vecrandom ?rnd_state ?from ?range n
n initialized with random elements sampled uniformly from
range starting at from. A random state rnd_state can be passed.rnd_state : default = Random.get_state ()from : default = -1.0range : default = 2.0val abs : unopabs ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the absolute 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.
val signum : unopsignum ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the sign value (-1 for
negative numbers, 0 (or -0) for zero, 1 for positive numbers,
nan for nan) 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.
val sqr : unopsqr ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the square
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.
val sqrt : unopsqrt ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the square root
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.
val cbrt : unopcbrt ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the cubic root
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.
val exp : unopexp ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the exponential
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.
val exp2 : unopexp2 ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the base-2 exponential
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.
val expm1 : unopexpm1 ?n ?ofsy ?incy ?y ?ofsx ?incx x computes exp x -. 1.
for 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.
val log : unoplog ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the logarithm
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.
val log10 : unoplog10 ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the base-10 logarithm
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.
val log2 : unoplog2 ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the base-2 logarithm
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.
val log1p : unoplog1p ?n ?ofsy ?incy ?y ?ofsx ?incx x computes log (1 + x) for 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.
val sin : unopsin ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the sine 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.
val cos : unopcos ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the cosine 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.
val tan : unoptan ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the tangent 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.
val asin : unopasin ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the arc sine 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.
val acos : unopacos ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the arc cosine 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.
val atan : unopatan ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the arc tangent 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.
val sinh : unopsinh ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the hyperbolic sine 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.
val cosh : unopcosh ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the hyperbolic cosine 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.
val tanh : unoptanh ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the hyperbolic tangent 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.
val asinh : unopasinh ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the hyperbolic arc sine 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.
val acosh : unopcosh ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the hyperbolic arc cosine 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.
val atanh : unopatanh ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the hyperbolic arc
tangent 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.
val floor : unopfloor ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the floor 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.
val ceil : unopceil ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the ceiling 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.
val round : unopround ?n ?ofsy ?incy ?y ?ofsx ?incx x rounds the 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.
val trunc : unoptrunc ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the truncation of the 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.
val erf : unoperf ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the error function for
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.
val erfc : unoperfc ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the complementary error
function for 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.
val logistic : unoplogistic ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the logistict
function 1/(1 + exp(-a) for 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.
val relu : unoprelu ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the rectified linear
unit function max(x, 0) for 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.
val softplus : unopsoftplus ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the softplus function
log(1 + exp(x) for 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.
val softsign : unopsoftsign ?n ?ofsy ?incy ?y ?ofsx ?incx x computes the softsign function
x / (1 + abs(x)) for 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.
val pow : binoppow ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y computes pow(a, b)
of 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.
val atan2 : binopatan2 ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y computes
atan2(x, y) of 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.
NOTE: WARNING! From a geometric point of view, the atan2 function takes
the y-coordinate in x and the x-coordinate in y. This confusion is
a sad consequence of the C99-standard reversing the argument order for
atan2 for no good reason.
val hypot : binophypot ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y computes
sqrt(x*x + y*y) of 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.
val min2 : binopmin2 ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y computes the
minimum of 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.
val max2 : binopmax2 ?n ?ofsz ?incz ?z ?ofsx ?incx x ?ofsy ?incy y computes the
maximum of 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.
val log_sum_exp : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> floatlog_sum_exp ?n ?ofsx ?incx x computes the logarithm of the sum of
exponentials of the n elements in vector x, separated by incx
incremental steps.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim xofsx : default = 1incx : default = 1val create : int -> Lacaml__S.veccreate n
n rows (not initialized).val make : int -> float -> Lacaml__S.vecmake n x
n rows initialized with value x.val make0 : int -> Lacaml__S.vecmake0 n x
n rows initialized with the zero
element.val init : int -> (int -> float) -> Lacaml__S.vecinit n f
n elements, where each
element at position i is initialized by the result of calling
f i.val of_array : float array -> Lacaml__S.vecof_array ar
ar.val to_array : Lacaml__S.vec -> float arrayto_array v
v.val of_list : float list -> Lacaml__S.vecof_list l
l.val to_list : Lacaml__S.vec -> float listto_list v
v.val append : Lacaml__S.vec -> Lacaml__S.vec -> Lacaml__S.vecappend v1 v2
v2 to v1.val concat : Lacaml__S.vec list -> Lacaml__S.vecconcat vs
vs.val empty : Lacaml__S.vecempty, the empty vector.
val linspace : ?y:Lacaml__S.vec -> float -> float -> int -> Lacaml__S.veclinspace ?z a b n
y overwritten with n
linearly spaced points between and including a and b.y : default = fresh vector of dim nval logspace : ?y:Lacaml__S.vec -> float -> float -> ?base:float -> int -> Lacaml__S.veclogspace ?z a b base n
y overwritten with n
points logarithmically spaced using base b between and including
base ** a and base ** b.y : default = fresh vector of dim nbase : default = 10.0val dim : Lacaml__S.vec -> intdim x
x.val has_zero_dim : Lacaml__S.vec -> boolhas_zero_dim vec checks whether vector vec has a dimension of size
zero. In this case it cannot contain data.
val map : (float -> float) ->
?n:int ->
?ofsy:int ->
?incy:int ->
?y:Lacaml__S.vec -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> Lacaml__S.vecmap f ?n ?ofsx ?incx x
f to each element of x.n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim xy : default = new vector with ofsy+(n-1)(abs incy) rowsofsx : default = 1incx : default = 1val iter : (float -> unit) -> ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> unititer ?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 xofsx : default = 1incx : default = 1val iteri : (int -> float -> unit) ->
?n:int -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> unititeri ?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 -> float -> 'a) ->
'a -> ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> 'afold 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 xofsx : default = 1incx : default = 1val rev : Lacaml__S.vec -> Lacaml__S.vecrev x reverses vector x (non-destructive).
val max : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> floatmax ?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 xofsx : default = 1incx : default = 1val min : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> floatmin ?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 xofsx : default = 1incx : default = 1val sort : ?cmp:(float -> float -> int) ->
?decr:bool ->
?n:int ->
?ofsp:int ->
?incp:int ->
?p:Lacaml__common.int_vec -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> unitsort ?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 xofsp : default = 1incp : default = 1p : 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 = 1incx : default = 1val fill : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> float -> unitfill ?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 xofsx : default = 1incx : default = 1val sum : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> floatsum ?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 xofsx : default = 1incx : default = 1val prod : ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> floatprod ?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 xofsx : default = 1incx : default = 1val add_const : float -> unopadd_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.
val sqr_nrm2 : ?stable:bool -> ?n:int -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> floatsqr_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 = falsen : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim xofsx : default = 1incx : default = 1val ssqr : ?n:int -> ?c:float -> ?ofsx:int -> ?incx:int -> Lacaml__S.vec -> floatssqr ?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__S.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__S.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 xc : default = zeroofsx : default = 1incx : default = 1val neg : unopneg ?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.
val reci : unopreci ?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.
val add : binopadd ?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.
val sub : binopsub ?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.
val mul : binopmul ?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.
val div : binopdiv ?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.
val zpxy : ?n:int ->
?ofsz:int ->
?incz:int ->
Lacaml__S.vec ->
?ofsx:int ->
?incx:int -> Lacaml__S.vec -> ?ofsy:int -> ?incy:int -> Lacaml__S.vec -> unitzpxy ?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. This function is useful for convolutions.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim xofsz : default = 1incz : default = 1ofsx : default = 1incx : default = 1ofsy : default = 1incy : default = 1val zmxy : ?n:int ->
?ofsz:int ->
?incz:int ->
Lacaml__S.vec ->
?ofsx:int ->
?incx:int -> Lacaml__S.vec -> ?ofsy:int -> ?incy:int -> Lacaml__S.vec -> unitzmxy ?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. This function is
useful for convolutions.
n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim xofsz : default = 1incz : default = 1ofsx : default = 1incx : default = 1ofsy : default = 1incy : default = 1val ssqr_diff : ?n:int ->
?ofsx:int ->
?incx:int ->
Lacaml__S.vec -> ?ofsy:int -> ?incy:int -> Lacaml__S.vec -> floatssqr_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 xofsx : default = 1incx : default = 1ofsy : default = 1incy : default = 1