Page
Library
Module
Module type
Parameter
Class
Class type
Source
D.Mat
Sourcerandom ?rnd_state ?from ?range m n
abs ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the absolute value of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
signum ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the sign value (-1
for negative numbers, 0
(or -0
) for zero, 1
for positive numbers, nan
for nan
) of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
sqr ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the square of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
sqrt ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the square root of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
cbrt ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the cubic root of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
exp ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the exponential of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
exp2 ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the base-2 exponential of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
expm1 ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes exp a -. 1.
of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
log ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the logarithm of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
log10 ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the base-10 logarithm of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
log2 ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes base-2 logarithm of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
log1p ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes log (1 + a)
of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
sin ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the sine of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
cos ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the cosine of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
tan ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the tangent of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
asin ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the arc sine of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
acos ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the arc cosine of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
atan ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the arc tangent of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
sinh ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the hyperbolic sine of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
cosh ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the hyperbolic cosine of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
tanh ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the hyperbolic tangent of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
asinh ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the hyperbolic arc sine of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
acosh ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the hyperbolic arc cosine of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
atanh ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the hyperbolic arc tangent of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
floor ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the floor of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
ceil ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the ceiling of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
round ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
rounds the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
trunc ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the truncation of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
erf ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the error function of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
erfc ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the complementary error function of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
logistic ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the logistic function 1/(1 + exp(-a)
of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
relu ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the rectified linear unit function max(a, 0)
of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
softplus ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the softplus function log(1 + exp(x)
of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
softsign ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
computes the softsign function x / (1 + abs(x))
of the elements in the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
. 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.
pow ?patt ?m ?n ?cr ?cc ?c ?ar ?ac a ?br ?bc b
computes pow(a, b)
for the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
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.
atan2 ?patt ?m ?n ?cr ?cc ?c ?ar ?ac a ?br ?bc b
computes atan2(a, b)
for the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
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: WARNING! From a geometric point of view, the atan2
function takes the y-coordinate in a
and the x-coordinate in b
. This confusion is a sad consequence of the C99-standard reversing the argument order for atan2
for no good reason.
hypot ?patt ?m ?n ?cr ?cc ?c ?ar ?ac a ?br ?bc b
computes sqrt(a*a+b*b)
for the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
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.
min2 ?patt ?m ?n ?cr ?cc ?c ?ar ?ac a ?br ?bc b
computes the elementwise minimum of the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
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.
max2 ?patt ?m ?n ?cr ?cc ?c ?ar ?ac a ?br ?bc b
computes the elementwise maximum of the m
by n
sub-matrix of the matrix a
starting in row ar
and column ac
and pattern patt
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 sum_prod :
?patt:patt ->
?m:int ->
?n:int ->
?ar:int ->
?ac:int ->
mat ->
?br:int ->
?bc:int ->
mat ->
float
sum_prod ?patt ?m ?n ?ar ?ac a ?br ?bc b
log_sum_exp ?patt ?m ?n ?ar ?ac a
computes the logarithm of the sum of exponentials of all elements in the m
-by-n
submatrix using pattern patt
, starting at row ar
and column ac
.
val cpab :
?patt:patt ->
?m:int ->
?n:int ->
?cr:int ->
?cc:int ->
mat ->
?ar:int ->
?ac:int ->
mat ->
?br:int ->
?bc:int ->
mat ->
unit
cpab ?patt ?m ?n ?cr ?cc c ?ar ?ac a ?br ?bc b
multiplies designated m
-by-n
range of elements of matrices a
and b
using pattern patt
elementwise and adds the result to and stores it in the specified range in c
. This function is useful for convolutions. Similar to Vec.zpxy
.
val cmab :
?patt:patt ->
?m:int ->
?n:int ->
?cr:int ->
?cc:int ->
mat ->
?ar:int ->
?ac:int ->
mat ->
?br:int ->
?bc:int ->
mat ->
unit
cmab ?patt ?m ?n ?cr ?cc c ?ar ?ac a ?br ?bc b
multiplies designated m
-by-n
range of elements of matrices a
and b
elementwise using pattern patt
and subtracts the result from and stores it in the specified range in c
. This function is useful for convolutions. Similar to Vec.zmxy
.
of_diag ?n ?br ?bc ?b ?ofsx ?incx x
has_zero_dim mat
checks whether matrix mat
has a dimension of size zero
. In this case it cannot contain data.
val swap :
?patt:patt ->
?m:int ->
?n:int ->
?ar:int ->
?ac:int ->
mat ->
?br:int ->
?bc:int ->
mat ->
unit
swap ?patt ?m ?n ?ar ?ac a ?br ?bc b
swaps the contents of (sub-matrices) a
and b
.
val transpose_copy :
?m:int ->
?n:int ->
?br:int ->
?bc:int ->
?b:mat ->
?ar:int ->
?ac:int ->
mat ->
mat
transpose_copy ?m ?n ?br ?bc ?b ?ar ?ac a
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.
fill ?patt ?m ?n ?ar ?ac a x
fills the specified sub-matrix in a
with value x
.
sum ?patt ?m ?n ?ar ?ac a
computes the sum of all elements in the m
-by-n
submatrix using pattern patt
, starting at row ar
and column ac
.
add_const c ?patt ?m ?n ?br ?bc ?b ?ar ?ac a
adds constant c
to the designated m
by n
submatrix in a
using pattern patt
and stores the result in the designated submatrix in b
.
add_const c ?n ?ar ?ac a
adds constant c
to the diagonal of the designated n
by n
submatrix in a
.
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.
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:vec ->
?ar:int ->
?ac:int ->
mat ->
vec
copy_diag ?n ?ofsy ?incy ?y ?ar ?ac a
scal ?patt ?m ?n alpha ?ar ?ac a
BLAS scal
function for (sub-)matrices.
val scal_cols :
?patt:patt ->
?m:int ->
?n:int ->
?ar:int ->
?ac:int ->
mat ->
?ofs:int ->
vec ->
unit
scal_cols ?patt ?m ?n ?ar ?ac a ?ofs alphas
column-wise scal
function for matrices.
val scal_rows :
?patt:patt ->
?m:int ->
?n:int ->
?ofs:int ->
vec ->
?ar:int ->
?ac:int ->
mat ->
unit
scal_rows ?patt ?m ?n ?ofs alphas ?ar ?ac a
row-wise scal
function for matrices.
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.
val syrk_diag :
?n:int ->
?k:int ->
?beta:float ->
?ofsy:int ->
?y:vec ->
?trans:Common.trans2 ->
?alpha:float ->
?ar:int ->
?ac:int ->
mat ->
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.
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.
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.
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
.
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:float ->
?patt:patt ->
?m:int ->
?n:int ->
?xr:int ->
?xc:int ->
mat ->
?yr:int ->
?yc:int ->
mat ->
unit
axpy ?alpha ?patt ?m ?n ?xr ?xc x ?yr ?yc y
BLAS axpy
function for matrices.
val gemm_diag :
?n:int ->
?k:int ->
?beta:float ->
?ofsy:int ->
?y:vec ->
?transa:trans3 ->
?alpha:float ->
?ar:int ->
?ac:int ->
mat ->
?transb:trans3 ->
?br:int ->
?bc:int ->
mat ->
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.
val gemm_trace :
?n:int ->
?k:int ->
?transa:trans3 ->
?ar:int ->
?ac:int ->
mat ->
?transb:trans3 ->
?br:int ->
?bc:int ->
mat ->
float
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.
val symm2_trace :
?n:int ->
?upa:bool ->
?ar:int ->
?ac:int ->
mat ->
?upb:bool ->
?br:int ->
?bc:int ->
mat ->
float
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
.
val ssqr_diff :
?patt:patt ->
?m:int ->
?n:int ->
?ar:int ->
?ac:int ->
mat ->
?br:int ->
?bc:int ->
mat ->
float
ssqr_diff ?patt ?m ?n ?ar ?ac a ?br ?bc b