Library
Module
Module type
Parameter
Class
Class type
type t = vec
val random :
?rnd_state:Random.State.t ->
?re_from:float ->
?re_range:float ->
?im_from:float ->
?im_range:float ->
int ->
vec
random ?rnd_state ?re_from ?re_range ?im_from ?im_range n
val create : int -> vec
create n
val make0 : int -> vec
make0 n x
val empty : vec
empty
, the empty vector.
val dim : vec -> int
dim 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.
val map :
(Complex.t -> Complex.t) ->
?n:int ->
?ofsy:int ->
?incy:int ->
?y:vec ->
?ofsx:int ->
?incx:int ->
vec ->
vec
map f ?n ?ofsx ?incx x
iter ?n ?ofsx ?incx f x
applies function f
in turn to all elements of vector x
.
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.
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
.
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.
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.
val sort :
?cmp:(Complex.t -> Complex.t -> int) ->
?decr:bool ->
?n:int ->
?ofsp:int ->
?incp:int ->
?p:(int, Bigarray.int_elt, Bigarray.fortran_layout) Bigarray.Array1.t ->
?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
.
fill ?n ?ofsx ?incx x a
fills vector x
with value a
in the designated range.
sum ?n ?ofsx ?incx x
computes the sum of the n
elements in vector x
, separated by incx
incremental steps.
prod ?n ?ofsx ?incx x
computes the product of the n
elements in vector x
, separated by incx
incremental steps.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.