package lacaml

  1. Overview
  2. Docs
type t = vec
Vector operations
type unop = ?n:int -> ?ofsy:int -> ?incy:int -> ?y:vec -> ?ofsx:int -> ?incx:int -> vec -> vec
type binop = ?n:int -> ?ofsz:int -> ?incz:int -> ?z:vec -> ?ofsx:int -> ?incx:int -> vec -> ?ofsy:int -> ?incy:int -> vec -> vec
Creation of vectors
val random : ?rnd_state:Random.State.t -> ?from:float -> ?range:float -> int -> vec

random ?rnd_state ?from ?range n

  • returns

    a vector of size n initialized with random elements sampled uniformly from range starting at from. A random state rnd_state can be passed.

  • parameter rnd_state

    default = Random.get_state ()

  • parameter from

    default = -1.0

  • parameter range

    default = 2.0

Unary vector operations
val abs : unop

abs ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val signum : unop

signum ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val sqr : unop

sqr ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val sqrt : unop

sqrt ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val cbrt : unop

cbrt ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val exp : unop

exp ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val exp2 : unop

exp2 ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val expm1 : unop

expm1 ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val log : unop

log ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val log10 : unop

log10 ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val log2 : unop

log2 ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val log1p : unop

log1p ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val sin : unop

sin ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val cos : unop

cos ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val tan : unop

tan ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val asin : unop

asin ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val acos : unop

acos ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val atan : unop

atan ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val sinh : unop

sinh ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val cosh : unop

cosh ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val tanh : unop

tanh ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val asinh : unop

asinh ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val acosh : unop

cosh ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val atanh : unop

atanh ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val floor : unop

floor ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val ceil : unop

ceil ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val round : unop

round ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val trunc : unop

trunc ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val erf : unop

erf ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val erfc : unop

erfc ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val logistic : unop

logistic ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val relu : unop

relu ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val softplus : unop

softplus ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val softsign : unop

softsign ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

Binary vector operations
val pow : binop

pow ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter z

    default = fresh vector with ofsz+(n - 1)(abs incz) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

val atan2 : binop

atan2 ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter z

    default = fresh vector with ofsz+(n - 1)(abs incz) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

val hypot : binop

hypot ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter z

    default = fresh vector with ofsz+(n - 1)(abs incz) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

val min2 : binop

min2 ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter z

    default = fresh vector with ofsz+(n - 1)(abs incz) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

val max2 : binop

max2 ?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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter z

    default = fresh vector with ofsz+(n - 1)(abs incz) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

Miscellaneous functions
val log_sum_exp : ?n:int -> ?ofsx:int -> ?incx:int -> vec -> float

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

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

Creation/conversion of vectors and dimension accessor
val create : int -> vec

create n

  • returns

    a vector with n rows (not initialized).

val make : int -> float -> vec

make n x

  • returns

    a vector with n rows initialized with value x.

val make0 : int -> vec

make0 n x

  • returns

    a vector with n rows initialized with the zero element.

val init : int -> (int -> float) -> 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 : float array -> vec

of_array ar

  • returns

    a vector initialized from array ar.

val to_array : vec -> float array

to_array v

  • returns

    an array initialized from vector v.

val of_list : float list -> vec

of_list l

  • returns

    a vector initialized from list l.

val to_list : vec -> float list

to_list v

  • returns

    a list initialized from vector v.

val append : vec -> vec -> vec

append v1 v2

  • returns

    the vector resulting from appending vector v2 to v1.

val concat : vec list -> vec

concat vs

  • returns

    the concatenation of vectors vs.

val empty : vec

empty, the empty vector.

val linspace : ?y:vec -> float -> float -> int -> vec

linspace ?z a b n

  • returns

    the vector y overwritten with n linearly spaced points between and including a and b.

  • parameter y

    default = fresh vector of dim n

val logspace : ?y:vec -> float -> float -> ?base:float -> int -> 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.

  • parameter y

    default = fresh vector of dim n

  • parameter base

    default = 10.0

val dim : vec -> int

dim x

  • returns

    the dimension of vector x.

val has_zero_dim : vec -> bool

has_zero_dim vec checks whether vector vec has a dimension of size zero. In this case it cannot contain data.

Iterators over vectors
val map : (float -> float) -> ?n:int -> ?ofsy:int -> ?incy:int -> ?y:vec -> ?ofsx:int -> ?incx:int -> vec -> vec

map f ?n ?ofsx ?incx x

  • returns

    a new vector resulting from the application of f to each element of x.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter y

    default = new vector with ofsy+(n-1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val iter : (float -> unit) -> ?n:int -> ?ofsx:int -> ?incx:int -> vec -> unit

iter ?n ?ofsx ?incx f x applies function f in turn to all elements of vector x.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val iteri : (int -> float -> unit) -> ?n:int -> ?ofsx:int -> ?incx:int -> 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 -> float -> 'a) -> 'a -> ?n:int -> ?ofsx:int -> ?incx:int -> 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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

Operations on one vector
val rev : vec -> vec

rev x reverses vector x (non-destructive).

val max : ?n:int -> ?ofsx:int -> ?incx:int -> vec -> float

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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val min : ?n:int -> ?ofsx:int -> ?incx:int -> vec -> float

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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val sort : ?cmp:(float -> float -> int) -> ?decr:bool -> ?n:int -> ?ofsp:int -> ?incp:int -> ?p:Common.int_vec -> ?ofsx:int -> ?incx:int -> vec -> unit

sort ?cmp ?n ?ofsx ?incx x sorts the array x in increasing order according to the comparison function cmp.

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

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

  • parameter decr

    sort in decreasing order (stays fast for the default cmp).

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsp

    default = 1

  • parameter incp

    default = 1

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val fill : ?n:int -> ?ofsx:int -> ?incx:int -> vec -> float -> unit

fill ?n ?ofsx ?incx x a fills vector x with value a in the designated range.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val sum : ?n:int -> ?ofsx:int -> ?incx:int -> vec -> float

sum ?n ?ofsx ?incx x computes the sum of the n elements in vector x, separated by incx incremental steps.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val prod : ?n:int -> ?ofsx:int -> ?incx:int -> vec -> float

prod ?n ?ofsx ?incx x computes the product of the n elements in vector x, separated by incx incremental steps.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val add_const : float -> unop

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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val sqr_nrm2 : ?stable:bool -> ?n:int -> ?ofsx:int -> ?incx:int -> 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.

  • parameter stable

    default = false

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val ssqr : ?n:int -> ?c:float -> ?ofsx:int -> ?incx:int -> vec -> float

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 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 sqr_nrm2 uses the conjugate transpose in the product. The latter will therefore always return a real number.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter c

    default = zero

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val neg : unop

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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

val reci : unop

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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

  • parameter y

    default = fresh vector with ofsy+(n - 1)(abs incy) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

Operations on two vectors
val add : binop

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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter z

    default = fresh vector with ofsz+(n - 1)(abs incz) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

val sub : binop

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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter z

    default = fresh vector with ofsz+(n - 1)(abs incz) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

val mul : binop

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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter z

    default = fresh vector with ofsz+(n - 1)(abs incz) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

val div : binop

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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter z

    default = fresh vector with ofsz+(n - 1)(abs incz) rows

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

val zpxy : ?n:int -> ?ofsz:int -> ?incz:int -> vec -> ?ofsx:int -> ?incx:int -> vec -> ?ofsy:int -> ?incy:int -> vec -> unit

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. This function is useful for convolutions.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

val zmxy : ?n:int -> ?ofsz:int -> ?incz:int -> vec -> ?ofsx:int -> ?incx:int -> vec -> ?ofsy:int -> ?incy:int -> vec -> unit

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. This function is useful for convolutions.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsz

    default = 1

  • parameter incz

    default = 1

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

val ssqr_diff : ?n:int -> ?ofsx:int -> ?incx:int -> vec -> ?ofsy:int -> ?incy:int -> vec -> float

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.

  • parameter n

    default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x

  • parameter ofsx

    default = 1

  • parameter incx

    default = 1

  • parameter ofsy

    default = 1

  • parameter incy

    default = 1

OCaml

Innovation. Community. Security.