Module Lacaml__Z.Mat

module Mat: sig .. end

type t = Lacaml__Z.mat 
Matrix operations
Creation of matrices
val random : ?rnd_state:Stdlib.Random.State.t ->
?re_from:float ->
?re_range:float ->
?im_from:float -> ?im_range:float -> int -> int -> Lacaml__Z.mat

random ?rnd_state ?re_from ?re_range ?im_from ?im_range m n

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
type unop = ?m:int ->
?n:int ->
?br:int ->
?bc:int ->
?b:Lacaml__Z.mat -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> Lacaml__Z.mat
type binop = ?m:int ->
?n:int ->
?cr:int ->
?cc:int ->
?c:Lacaml__Z.mat ->
?ar:int ->
?ac:int ->
Lacaml__Z.mat -> ?br:int -> ?bc:int -> Lacaml__Z.mat -> Lacaml__Z.mat
Creation of matrices and accessors
val create : int -> int -> Lacaml__Z.mat

create m n

val make : int -> int -> Stdlib.Complex.t -> Lacaml__Z.mat

make m n x

val make0 : int -> int -> Lacaml__Z.mat

make0 m n x

val of_array : Stdlib.Complex.t array array -> Lacaml__Z.mat

of_array ar

val to_array : Lacaml__Z.mat -> Stdlib.Complex.t array array

to_array mat

val of_list : Stdlib.Complex.t list list -> Lacaml__Z.mat

of_list ls

val to_list : Lacaml__Z.mat -> Stdlib.Complex.t list list

to_array mat

val of_col_vecs : Lacaml__Z.vec array -> Lacaml__Z.mat

of_col_vecs ar

val to_col_vecs : Lacaml__Z.mat -> Lacaml__Z.vec array

to_col_vecs mat

val of_col_vecs_list : Lacaml__Z.vec list -> Lacaml__Z.mat

of_col_vecs_list ar

val to_col_vecs_list : Lacaml__Z.mat -> Lacaml__Z.vec list

to_col_vecs_list mat

val as_vec : Lacaml__Z.mat -> Lacaml__Z.vec

as_vec mat

val init_rows : int -> int -> (int -> int -> Stdlib.Complex.t) -> Lacaml__Z.mat

init_cols m n f

val init_cols : int -> int -> (int -> int -> Stdlib.Complex.t) -> Lacaml__Z.mat

init_cols m n f

val create_mvec : int -> Lacaml__Z.mat

create_mvec m

val make_mvec : int -> Stdlib.Complex.t -> Lacaml__Z.mat

make_mvec m x

val mvec_of_array : Stdlib.Complex.t array -> Lacaml__Z.mat

mvec_of_array ar

val mvec_to_array : Lacaml__Z.mat -> Stdlib.Complex.t array

mvec_to_array mat

val from_col_vec : Lacaml__Z.vec -> Lacaml__Z.mat

from_col_vec v

val from_row_vec : Lacaml__Z.vec -> Lacaml__Z.mat

from_row_vec v

val empty : Lacaml__Z.mat

empty, the empty matrix.

val identity : int -> Lacaml__Z.mat

identity n

val of_diag : ?n:int ->
?br:int ->
?bc:int ->
?b:Lacaml__Z.mat -> ?ofsx:int -> ?incx:int -> Lacaml__Z.vec -> Lacaml__Z.mat

of_diag ?n ?br ?bc ?b ?ofsx ?incx x

n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim x
br : default = 1
bc : default = 1
b : default = minimal fresh matrix consistent with n, br, and bc
ofsx : default = 1
incx : default = 1
val dim1 : Lacaml__Z.mat -> int

dim1 m

val dim2 : Lacaml__Z.mat -> int

dim2 m

val has_zero_dim : Lacaml__Z.mat -> bool

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

val col : Lacaml__Z.mat -> int -> Lacaml__Z.vec

col m n

val copy_row : ?vec:Lacaml__Z.vec -> Lacaml__Z.mat -> int -> Lacaml__Z.vec

copy_row ?vec mat int

vec : default = fresh vector of length dim2 mat
Matrix transformations
val swap : ?uplo:[ `L | `U ] ->
?m:int ->
?n:int ->
?ar:int ->
?ac:int -> Lacaml__Z.mat -> ?br:int -> ?bc:int -> Lacaml__Z.mat -> unit

swap ?m ?n ?ar ?ac a ?br ?bc b swaps the contents of (sub-matrices) a and b.

m : default = greater n s.t. ar + m - 1 <= dim1 a
n : default = greater n s.t. ac + n - 1 <= dim2 a
ar : default = 1
ac : default = 1
br : default = 1
bc : default = 1
val transpose_copy : unop

transpose_copy ?m ?n ?br ?bc ?b ?ar ?ac a

val detri : ?up:bool -> ?n:int -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> unit

detri ?up ?n ?ar ?ac a takes a triangular (sub-)matrix a, i.e. one where only the upper (iff up is true) or lower triangle is defined, and makes it a symmetric matrix by mirroring the defined triangle along the diagonal.

up : default = true
n : default = Mat.dim1 a
ar : default = 1
ac : default = 1
val packed : ?up:bool -> ?n:int -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> Lacaml__Z.vec

packed ?up ?n ?ar ?ac a

up : default = true
n : default = Mat.dim2 a
ar : default = 1
ac : default = 1
val unpacked : ?up:bool -> ?n:int -> Lacaml__Z.vec -> Lacaml__Z.mat

unpacked ?up x

up : default = true
n : default = Vec.dim x
Operations on one matrix
val fill : ?m:int ->
?n:int -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> Stdlib.Complex.t -> unit

fill ?m ?n ?ar ?ac a x fills the specified sub-matrix in a with value x.

val sum : ?m:int -> ?n:int -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> Stdlib.Complex.t

sum ?m ?n ?ar ?ac a computes the sum of all elements in the m-by-n submatrix starting at row ar and column ac.

val add_const : Stdlib.Complex.t -> unop

add_const c ?m ?n ?br ?bc ?b ?ar ?ac a adds constant c to the designated m by n submatrix in a and stores the result in the designated submatrix in b.

val neg : unop

neg ?m ?n ?br ?bc ?b ?ar ?ac a computes the negative of the elements in the m by n (sub-)matrix of the matrix a starting in row ar and column ac. If b is given, the result will be stored in there using offsets br and bc, otherwise a fresh matrix will be used. The resulting matrix is returned.

val reci : unop

reci ?m ?n ?br ?bc ?b ?ar ?ac a computes the reciprocal of the elements in the m by n (sub-)matrix of the matrix a starting in row ar and column ac. If b is given, the result will be stored in there using offsets br and bc, otherwise a fresh matrix will be used. The resulting matrix is returned.

val copy_diag : ?n:int ->
?ofsy:int ->
?incy:int ->
?y:Lacaml__Z.vec -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> Lacaml__Z.vec

copy_diag ?n ?ofsy ?incy ?y ?ar ?ac a

n : default = greatest n that does not exceed matrix dimensions
ofsy : default = 1
incy : default = 1
y : default = fresh vector of length n
ar : default = 1
ac : default = 1
val trace : Lacaml__Z.mat -> Stdlib.Complex.t

trace m

val scal : ?m:int ->
?n:int -> Stdlib.Complex.t -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> unit

scal ?m ?n alpha ?ar ?ac a BLAS scal function for (sub-)matrices.

val scal_cols : ?m:int ->
?n:int ->
?ar:int -> ?ac:int -> Lacaml__Z.mat -> ?ofs:int -> Lacaml__Z.vec -> unit

scal_cols ?m ?n ?ar ?ac a ?ofs alphas column-wise scal function for matrices.

val scal_rows : ?m:int ->
?n:int ->
?ofs:int -> Lacaml__Z.vec -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> unit

scal_rows ?m ?n ?ofs alphas ?ar ?ac a row-wise scal function for matrices.

val syrk_trace : ?n:int -> ?k:int -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> Stdlib.Complex.t

syrk_trace ?n ?k ?ar ?ac a computes the trace of either a' * a or a * a', whichever is more efficient (results are identical), of the (sub-)matrix a multiplied by its own transpose. This is the same as the square of the Frobenius norm of a matrix. n is the number of rows to consider in a, and k the number of columns to consider.

n : default = number of rows of a
k : default = number of columns of a
ar : default = 1
ac : default = 1
val syrk_diag : ?n:int ->
?k:int ->
?beta:Stdlib.Complex.t ->
?ofsy:int ->
?y:Lacaml__Z.vec ->
?trans:Lacaml__common.trans2 ->
?alpha:Stdlib.Complex.t ->
?ar:int -> ?ac:int -> Lacaml__Z.mat -> Lacaml__Z.vec

syrk_diag ?n ?k ?beta ?ofsy ?y ?trans ?alpha ?ar ?ac a computes the diagonal of the symmetric rank-k product of the (sub-)matrix a, multiplying it with alpha and adding beta times y, storing the result in y starting at the specified offset. n elements of the diagonal will be computed, and k elements of the matrix will be part of the dot product associated with each diagonal element.

n : default = number of rows of a (or tra)
k : default = number of columns of a (or tra)
beta : default = 0
ofsy : default = 1
y : default = fresh vector of size n + ofsy - 1
trans : default = `N
alpha : default = 1
ar : default = 1
ac : default = 1
Operations on two matrices
val add : binop

add ?m ?n ?cr ?cc ?c ?ar ?ac a ?br ?bc b computes the sum of the m by n sub-matrix of the matrix a starting in row ar and column ac with the corresponding sub-matrix of the matrix b starting in row br and column bc. If c is given, the result will be stored in there starting in row cr and column cc, otherwise a fresh matrix will be used. The resulting matrix is returned.

val sub : binop

sub ?m ?n ?cr ?cc ?c ?ar ?ac a ?br ?bc b computes the difference of the m by n sub-matrix of the matrix a starting in row ar and column ac with the corresponding sub-matrix of the matrix b starting in row br and column bc. If c is given, the result will be stored in there starting in row cr and column cc, otherwise a fresh matrix will be used. The resulting matrix is returned.

val mul : binop

mul ?m ?n ?cr ?cc ?c ?ar ?ac a ?br ?bc b computes the element-wise product of the m by n sub-matrix of the matrix a starting in row ar and column ac with the corresponding sub-matrix of the matrix b starting in row br and column bc. If c is given, the result will be stored in there starting in row cr and column cc, otherwise a fresh matrix will be used. The resulting matrix is returned.

NOTE: please do not confuse this function with matrix multiplication! The LAPACK-function for matrix multiplication is called gemm, e.g. Lacaml.D.gemm.

val div : binop

div ?m ?n ?cr ?cc ?c ?ar ?ac a ?br ?bc b computes the division of the m by n sub-matrix of the matrix a starting in row ar and column ac with the corresponding sub-matrix of the matrix b starting in row br and column bc. If c is given, the result will be stored in there starting in row cr and column cc, otherwise a fresh matrix will be used. The resulting matrix is returned.

val axpy : ?alpha:Stdlib.Complex.t ->
?m:int ->
?n:int ->
?xr:int ->
?xc:int -> Lacaml__Z.mat -> ?yr:int -> ?yc:int -> Lacaml__Z.mat -> unit

axpy ?alpha ?m ?n ?xr ?xc x ?yr ?yc y BLAS axpy function for matrices.

val gemm_diag : ?n:int ->
?k:int ->
?beta:Stdlib.Complex.t ->
?ofsy:int ->
?y:Lacaml__Z.vec ->
?transa:Lacaml__Z.trans3 ->
?alpha:Stdlib.Complex.t ->
?ar:int ->
?ac:int ->
Lacaml__Z.mat ->
?transb:Lacaml__Z.trans3 ->
?br:int -> ?bc:int -> Lacaml__Z.mat -> Lacaml__Z.vec

gemm_diag ?n ?k ?beta ?ofsy ?y ?transa ?transb ?alpha ?ar ?ac a ?br ?bc b computes the diagonal of the product of the (sub-)matrices a and b (taking into account potential transposing), multiplying it with alpha and adding beta times y, storing the result in y starting at the specified offset. n elements of the diagonal will be computed, and k elements of the matrices will be part of the dot product associated with each diagonal element.

n : default = number of rows of a (or tr a) and number of columns of b (or tr b)
k : default = number of columns of a (or tr a) and number of rows of b (or tr b)
beta : default = 0
ofsy : default = 1
y : default = fresh vector of size n + ofsy - 1
transa : default = `N
alpha : default = 1
ar : default = 1
ac : default = 1
transb : default = `N
br : default = 1
bc : default = 1
val gemm_trace : ?n:int ->
?k:int ->
?transa:Lacaml__Z.trans3 ->
?ar:int ->
?ac:int ->
Lacaml__Z.mat ->
?transb:Lacaml__Z.trans3 ->
?br:int -> ?bc:int -> Lacaml__Z.mat -> Stdlib.Complex.t

gemm_trace ?n ?k ?transa ?ar ?ac a ?transb ?br ?bc b computes the trace of the product of the (sub-)matrices a and b (taking into account potential transposing). When transposing a, this yields the so-called Frobenius product of a and b. n is the number of rows (columns) to consider in a and the number of columns (rows) in b. k is the inner dimension to use for the product.

n : default = number of rows of a (or tr a) and number of columns of b (or tr b)
k : default = number of columns of a (or tr a) and number of rows of b (or tr b)
transa : default = `N
ar : default = 1
ac : default = 1
transb : default = `N
br : default = 1
bc : default = 1
val symm2_trace : ?n:int ->
?upa:bool ->
?ar:int ->
?ac:int ->
Lacaml__Z.mat ->
?upb:bool -> ?br:int -> ?bc:int -> Lacaml__Z.mat -> Stdlib.Complex.t

symm2_trace ?n ?upa ?ar ?ac a ?upb ?br ?bc b computes the trace of the product of the symmetric (sub-)matrices a and b. n is the number of rows and columns to consider in a and b.

n : default = dimensions of a and b
upa : default = true (upper triangular portion of a is accessed)
ar : default = 1
ac : default = 1
upb : default = true (upper triangular portion of b is accessed)
br : default = 1
bc : default = 1
val ssqr_diff : ?m:int ->
?n:int ->
?ar:int ->
?ac:int ->
Lacaml__Z.mat -> ?br:int -> ?bc:int -> Lacaml__Z.mat -> Stdlib.Complex.t

ssqr_diff ?m ?n ?ar ?ac a ?br ?bc b

m : default = greater n s.t. ar + m - 1 <= dim1 a
n : default = greater n s.t. ac + n - 1 <= dim2 a
ar : default = 1
ac : default = 1
br : default = 1
bc : default = 1
Iterators over matrices
val map : (Stdlib.Complex.t -> Stdlib.Complex.t) ->
?m:int ->
?n:int ->
?br:int ->
?bc:int ->
?b:Lacaml__Z.mat -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> Lacaml__Z.mat

map f ?m ?n ?br ?bc ?b ?ar ?ac a

m : default = number of rows of a
n : default = number of columns of a
b : default = fresh matrix of size m by n
val fold_cols : ('a -> Lacaml__Z.vec -> 'a) -> ?n:int -> ?ac:int -> 'a -> Lacaml__Z.mat -> 'a

fold_cols f ?n ?ac acc a

n : default = number of columns of a
ac : default = 1