module Mat:sig..end
typet =Lacaml__Z.mat
val random : ?rnd_state:Stdlib.Random.State.t ->
?re_from:float ->
?re_range:float ->
?im_from:float -> ?im_range:float -> int -> int -> Lacaml__Z.matrandom ?rnd_state ?re_from ?re_range ?im_from ?im_range m n
mxn matrix 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.0re_range : default = 2.0im_from : default = -1.0im_range : default = 2.0typeunop =?m:int ->
?n:int ->
?br:int ->
?bc:int ->
?b:Lacaml__Z.mat -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> Lacaml__Z.mat
typebinop =?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
val create : int -> int -> Lacaml__Z.matcreate m n
m rows and n columns.val make : int -> int -> Stdlib.Complex.t -> Lacaml__Z.matmake m n x
m rows and n columns
initialized with value x.val make0 : int -> int -> Lacaml__Z.matmake0 m n x
m rows and n columns
initialized with the zero element.val of_array : Stdlib.Complex.t array array -> Lacaml__Z.matof_array ar
ar. It is assumed that the OCaml matrix is in row major order
(standard).val to_array : Lacaml__Z.mat -> Stdlib.Complex.t array arrayto_array mat
mat.val of_list : Stdlib.Complex.t list list -> Lacaml__Z.matof_list ls
ls. Each sublist of ls represents a row of the desired matrix,
and must be of the same length.val to_list : Lacaml__Z.mat -> Stdlib.Complex.t list listto_array mat
mat in row major order as lists.val of_col_vecs : Lacaml__Z.vec array -> Lacaml__Z.matof_col_vecs ar
ar. The vectors must be of same length.val to_col_vecs : Lacaml__Z.mat -> Lacaml__Z.vec arrayto_col_vecs mat
mat.val of_col_vecs_list : Lacaml__Z.vec list -> Lacaml__Z.matof_col_vecs_list ar
ar. The vectors must be of same length.val to_col_vecs_list : Lacaml__Z.mat -> Lacaml__Z.vec listto_col_vecs_list mat
mat.val as_vec : Lacaml__Z.mat -> Lacaml__Z.vecas_vec mat
val init_rows : int -> int -> (int -> int -> Stdlib.Complex.t) -> Lacaml__Z.matinit_cols m n f
m rows and n
columns, where each element at row and col is initialized by the
result of calling f row col. The elements are passed row-wise.val init_cols : int -> int -> (int -> int -> Stdlib.Complex.t) -> Lacaml__Z.matinit_cols m n f
m rows and n
columns, where each element at row and col is initialized by the
result of calling f row col. The elements are passed column-wise.val create_mvec : int -> Lacaml__Z.matcreate_mvec m
m rows.val make_mvec : int -> Stdlib.Complex.t -> Lacaml__Z.matmake_mvec m x
m rows
initialized with value x.val mvec_of_array : Stdlib.Complex.t array -> Lacaml__Z.matmvec_of_array ar
ar.val mvec_to_array : Lacaml__Z.mat -> Stdlib.Complex.t arraymvec_to_array mat
mat.val from_col_vec : Lacaml__Z.vec -> Lacaml__Z.matfrom_col_vec v
v.
The data is shared.val from_row_vec : Lacaml__Z.vec -> Lacaml__Z.matfrom_row_vec v
v.
The data is shared.val empty : Lacaml__Z.matempty, the empty matrix.
val identity : int -> Lacaml__Z.matidentity n
nxn identity matrix.val of_diag : ?n:int ->
?br:int ->
?bc:int ->
?b:Lacaml__Z.mat -> ?ofsx:int -> ?incx:int -> Lacaml__Z.vec -> Lacaml__Z.matof_diag ?n ?br ?bc ?b ?ofsx ?incx x
b with diagonal
elements in the designated sub-matrix coming from the designated sub-vector
in x.n : default = greater n s.t. ofsx+(n-1)(abs incx) <= dim xbr : default = 1bc : default = 1b : default = minimal fresh matrix consistent with n, br, and bcofsx : default = 1incx : default = 1val dim1 : Lacaml__Z.mat -> intdim1 m
m (number of rows).val dim2 : Lacaml__Z.mat -> intdim2 m
m (number of columns).val has_zero_dim : Lacaml__Z.mat -> boolhas_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.veccol m n
nth column of matrix m as a vector.
The data is shared.val copy_row : ?vec:Lacaml__Z.vec -> Lacaml__Z.mat -> int -> Lacaml__Z.veccopy_row ?vec mat int
nth row of matrix m
in vector vec.vec : default = fresh vector of length dim2 matval swap : ?uplo:[ `L | `U ] ->
?m:int ->
?n:int ->
?ar:int ->
?ac:int -> Lacaml__Z.mat -> ?br:int -> ?bc:int -> Lacaml__Z.mat -> unitswap ?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 an : default = greater n s.t. ac + n - 1 <= dim2 aar : default = 1ac : default = 1br : default = 1bc : default = 1val transpose_copy : unoptranspose_copy ?m ?n ?br ?bc ?b ?ar ?ac a
a. If b is given, the result will be stored in there
using offsets br and bc, otherwise a fresh matrix will be used.
NOTE: this operations does _not_ support in-place transposes!val detri : ?up:bool -> ?n:int -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> unitdetri ?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 = truen : default = Mat.dim1 aar : default = 1ac : default = 1val packed : ?up:bool -> ?n:int -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> Lacaml__Z.vecpacked ?up ?n ?ar ?ac a
a in packed
storage format.up : default = truen : default = Mat.dim2 aar : default = 1ac : default = 1val unpacked : ?up:bool -> ?n:int -> Lacaml__Z.vec -> Lacaml__Z.matunpacked ?up x
up)
triangular matrix from packed representation vec. The other
triangle of the matrix will be filled with zeros.up : default = truen : default = Vec.dim xval fill : ?m:int ->
?n:int -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> Stdlib.Complex.t -> unitfill ?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.tsum ?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 -> unopadd_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 : unopneg ?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 : unopreci ?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.veccopy_diag ?n ?ofsy ?incy ?y ?ar ?ac a
a in a (sub-)vector.n : default = greatest n that does not exceed matrix dimensionsofsy : default = 1incy : default = 1y : default = fresh vector of length nar : default = 1ac : default = 1val trace : Lacaml__Z.mat -> Stdlib.Complex.ttrace m
m. If m is not a
square matrix, the sum of the longest possible sequence of
diagonal elements will be returned.val scal : ?m:int ->
?n:int -> Stdlib.Complex.t -> ?ar:int -> ?ac:int -> Lacaml__Z.mat -> unitscal ?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 -> unitscal_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 -> unitscal_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.tsyrk_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 ak : default = number of columns of aar : default = 1ac : default = 1val 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.vecsyrk_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 = 0ofsy : default = 1y : default = fresh vector of size n + ofsy - 1trans : default = `Nalpha : default = 1ar : default = 1ac : default = 1val add : binopadd ?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 : binopsub ?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 : binopmul ?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 : binopdiv ?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 -> unitaxpy ?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.vecgemm_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 = 0ofsy : default = 1y : default = fresh vector of size n + ofsy - 1transa : default = `Nalpha : default = 1ar : default = 1ac : default = 1transb : default = `Nbr : default = 1bc : default = 1val 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.tgemm_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 = `Nar : default = 1ac : default = 1transb : default = `Nbr : default = 1bc : default = 1val symm2_trace : ?n:int ->
?upa:bool ->
?ar:int ->
?ac:int ->
Lacaml__Z.mat ->
?upb:bool -> ?br:int -> ?bc:int -> Lacaml__Z.mat -> Stdlib.Complex.tsymm2_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 bupa : default = true (upper triangular portion of a is accessed)ar : default = 1ac : default = 1upb : default = true (upper triangular portion of b is accessed)br : default = 1bc : default = 1val ssqr_diff : ?m:int ->
?n:int ->
?ar:int ->
?ac:int ->
Lacaml__Z.mat -> ?br:int -> ?bc:int -> Lacaml__Z.mat -> Stdlib.Complex.tssqr_diff ?m ?n ?ar ?ac a ?br ?bc b
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.m : default = greater n s.t. ar + m - 1 <= dim1 an : default = greater n s.t. ac + n - 1 <= dim2 aar : default = 1ac : default = 1br : default = 1bc : default = 1val 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.matmap f ?m ?n ?br ?bc ?b ?ar ?ac a
f applied to each element of a.m : default = number of rows of an : default = number of columns of ab : default = fresh matrix of size m by nval fold_cols : ('a -> Lacaml__Z.vec -> 'a) -> ?n:int -> ?ac:int -> 'a -> Lacaml__Z.mat -> 'afold_cols f ?n ?ac acc a
n : default = number of columns of aac : default = 1