Vectors and matrices
ns vector-matrix
(:require [fastmath.vector :as v]
(:as mat]
[fastmath.matrix :as codox])) [fastmath.dev.codox
Vectors
Reference
fastmath.vector
Mathematical vector operations.
### Types
- Fixed size (custom types):
- Fixed size
- doubles - double array itself
- Variable size:
- Clojure’s IPersistentVector, creator
[]
- Clojure’s ISeq
- Clojure’s IPersistentVector, creator
VectorProto defines most of the functions.
Vectors implements also:
Sequable
Sequencial
IFn
Counted
Reversible
Indexed
ILookup
equals
andtoString
fromObject
IPersistentVector
Associative
clojure.core.matrix.protocols
IReduce
andIReduceInit
That means that vectors can be destructured, treated as sequence or called as a function. See vec2 for examples.
->ArrayVec
(->ArrayVec array)
Positional factory function for class fastmath.vector.ArrayVec.
->Vec2
(->Vec2 x y)
Positional factory function for class fastmath.vector.Vec2.
->Vec3
(->Vec3 x y z)
Positional factory function for class fastmath.vector.Vec3.
->Vec4
(->Vec4 x y z w)
Positional factory function for class fastmath.vector.Vec4.
abs
(abs v)
Absolute value of vector elements
acos
(acos vector)
Apply acos to vector elements.
acosh
(acosh vector)
Apply acosh to vector elements.
acot
(acot vector)
Apply acot to vector elements.
acoth
(acoth vector)
Apply acoth to vector elements.
acsc
(acsc vector)
Apply acsc to vector elements.
acsch
(acsch vector)
Apply acsch to vector elements.
add
(add v)
(add v1 v2)
Sum of two vectors.
aligned?
(aligned? v1 v2 tol)
(aligned? v1 v2)
Are vectors aligned (have the same direction)?
angle-between
(angle-between v1 v2)
Angle between two vectors
See also relative-angle-between.
applyf DEPRECATED
Deprecated: v1.3.0
Same as fmap. Deprecated.
approx
(approx v)
(approx v d)
Round to 2 (or d
) decimal places
array->vec2
(array->vec2 arr)
Doubles array to Vec2
array->vec3
(array->vec3 arr)
Doubles array to Vec3
array->vec4
(array->vec4 arr)
Doubles array to Vec4
array-vec
(array-vec xs)
Make ArrayVec type based on provided sequence xs
.
as-vec
(as-vec v)
(as-vec v xs)
Create vector from sequence as given type. If there is no sequence fill with 0.0
.
asec
(asec vector)
Apply asec to vector elements.
asech
(asech vector)
Apply asech to vector elements.
asin
(asin vector)
Apply asin to vector elements.
asinh
(asinh vector)
Apply asinh to vector elements.
atan
(atan vector)
Apply atan to vector elements.
atanh
(atanh vector)
Apply atanh to vector elements.
average
(average v)
(average v weights)
Mean or weighted average of the vector
average-vectors
(average-vectors init vs)
(average-vectors vs)
Average / centroid of vectors. Input: initial vector (optional), list of vectors
axis-rotate
(axis-rotate v angle axis)
(axis-rotate v angle axis pivot)
Rotate vector. Only for Vec3
types
base-from
(base-from v)
List of perpendicular vectors (basis). Works only for Vec2
and Vec3
types.
cb
(cb vector)
Apply cb to vector elements.
cbrt
(cbrt vector)
Apply cbrt to vector elements.
ceil
(ceil vector)
Apply ceil to vector elements.
clamp
(clamp v mn mx)
(clamp v)
Clamp elements.
cos
(cos vector)
Apply cos to vector elements.
cosh
(cosh vector)
Apply cosh to vector elements.
cot
(cot vector)
Apply cot to vector elements.
coth
(coth vector)
Apply coth to vector elements.
cross
(cross v1 v2)
Cross product
csc
(csc vector)
Apply csc to vector elements.
csch
(csch vector)
Apply csch to vector elements.
degrees
(degrees vector)
Apply degrees to vector elements.
delta-eq
(delta-eq v1 v2)
(delta-eq v1 v2 abs-tol)
(delta-eq v1 v2 abs-tol rel-tol)
Equality with given absolute (and/or relative) toleance.
dhash-code
(dhash-code state a)
(dhash-code a)
double hashcode
dist
(dist v1 v2)
Euclidean distance between vectors
dist-abs
(dist-abs v1 v2)
Manhattan distance between vectors
dist-ang
(dist-ang v1 v2)
Angular distance
dist-canberra
(dist-canberra v1 v2)
Canberra distance
dist-cheb
(dist-cheb v1 v2)
Chebyshev distance between 2d vectors
dist-discrete
(dist-discrete v1 v2)
Discrete distance between 2d vectors
dist-emd
(dist-emd v1 v2)
Earth Mover’s Distance
dist-sq
(dist-sq v1 v2)
Squared Euclidean distance between vectors
distances
div
(div v1 v)
(div v1)
Vector division or reciprocal.
dot
(dot v1 v2)
Dot product of two vectors.
econstrain
(econstrain v mn mx)
Element-wise constrain
edelta-eq
(edelta-eq v1 v2)
(edelta-eq v1 v2 abs-tol)
(edelta-eq v1 v2 abs-tol rel-tol)
Element-wise equality with given absolute (and/or relative) toleance.
ediv
(ediv v1 v2)
Element-wise division of two vectors.
einterpolate
(einterpolate v1 v2 v)
(einterpolate v1 v2 v f)
Interpolate vector selement-wise, optionally set interpolation fn (default: lerp)
emn
(emn v1 v2)
Element-wise min from two vectors.
emult
(emult v1 v2)
Element-wise vector multiplication (Hadamard product).
emx
(emx v1 v2)
Element-wise max from two vectors.
exp
(exp vector)
Apply exp to vector elements.
expm1
(expm1 vector)
Apply expm1 to vector elements.
faceforward
(faceforward n v)
Flip normal n
to match the same direction as v
.
floor
(floor vector)
Apply floor to vector elements.
fmap
(fmap v f)
Apply function to all vector values (like map but returns the same type).
frac
(frac vector)
Apply frac to vector elements.
from-polar
(from-polar v)
From polar coordinates (2d, 3d only)
generate-vec2
(generate-vec2 f1 f2)
(generate-vec2 f)
Generate Vec2 with fn(s)
generate-vec3
(generate-vec3 f1 f2 f3)
(generate-vec3 f)
Generate Vec3 with fn(s)
generate-vec4
(generate-vec4 f1 f2 f3 f4)
(generate-vec4 f)
Generate Vec4 with fn(s)
heading
(heading v)
Angle between vector and unit vector [1,0,...]
interpolate
(interpolate v1 v2 t)
(interpolate v1 v2 t f)
Interpolate vectors, optionally set interpolation fn (default: lerp)
is-near-zero?
(is-near-zero? v)
(is-near-zero? v abs-tol)
(is-near-zero? v abs-tol rel-tol)
Equality to zero 0
with given absolute (and/or relative) toleance.
is-zero?
(is-zero? v)
Is vector zero?
lerp
(lerp v1 v2 t)
Linear interpolation of vectors
limit
(limit v len)
Limit length of the vector by given value
ln
(ln vector)
Apply ln to vector elements.
log
(log vector)
Apply log to vector elements.
log10
(log10 vector)
Apply log10 to vector elements.
log1mexp
(log1mexp vector)
Apply log1mexp to vector elements.
log1p
(log1p vector)
Apply log1p to vector elements.
log1pexp
(log1pexp vector)
Apply log1pexp to vector elements.
log1pmx
(log1pmx vector)
Apply log1pmx to vector elements.
log1psq
(log1psq vector)
Apply log1psq to vector elements.
log2
(log2 vector)
Apply log2 to vector elements.
logexpm1
(logexpm1 vector)
Apply logexpm1 to vector elements.
logit
(logit vector)
Apply logit to vector elements.
logmeanexp
(logmeanexp v)
logmxp1
(logmxp1 vector)
Apply logmxp1 to vector elements.
logsoftmax
(logsoftmax v)
logsumexp
(logsumexp v)
mag
(mag v)
Length of the vector.
magsq
(magsq v)
Length of the vector squared.
make-vector
(make-vector dims xs)
(make-vector dims)
Returns fixed size vector for given number of dimensions.
Proper type is used.
maxdim
(maxdim v)
Index of maximum value.
mindim
(mindim v)
Index of minimum value.
mn
(mn v)
Minimum value of vector elements
mult
(mult v x)
Multiply vector by number x
.
mx
(mx v)
Maximum value of vector elements
near-zero?
(near-zero? v)
(near-zero? v abs-tol)
(near-zero? v abs-tol rel-tol)
Equality to zero 0
with given absolute (and/or relative) toleance.
nonzero-count
(nonzero-count v)
Count non zero velues in vector
normalize
(normalize v)
Normalize vector (set length = 1.0)
orthogonal-polynomials
(orthogonal-polynomials xs)
Creates orthogonal list of vectors based on xs
, starting from degree 1
orthonormal-polynomials
(orthonormal-polynomials xs)
Creates orthonormal list of vector based on xs
, starting from degree 1
permute
(permute v idxs)
Permute vector elements with given indices.
perpendicular
(perpendicular v)
(perpendicular v1 v2)
Perpendicular vector. Only for Vec2
and Vec3
types.
prod
(prod v)
Product of elements
project
(project v1 v2)
Project v1
onto v2
radians
(radians vector)
Apply radians to vector elements.
reciprocal
(reciprocal v)
Reciprocal of elements.
relative-angle-between
(relative-angle-between v1 v2)
Angle between two vectors relative to each other.
See also angle-between.
rint
(rint vector)
Apply rint to vector elements.
rotate
(rotate v angle)
(rotate v angle-x angle-y angle-z)
Rotate vector. Only for Vec2
and Vec3
types.
round
(round vector)
Apply round to vector elements.
safe-sqrt
(safe-sqrt vector)
Apply safe-sqrt to vector elements.
sec
(sec vector)
Apply sec to vector elements.
sech
(sech vector)
Apply sech to vector elements.
seq->vec2
(seq->vec2 xs)
Any seq to Vec2
seq->vec3
(seq->vec3 xs)
Any seq to Vec3
seq->vec4
(seq->vec4 xs)
Any seq to Vec4
set-mag
(set-mag v len)
Set length of the vector
sfrac
(sfrac vector)
Apply sfrac to vector elements.
sgn
(sgn vector)
Apply sgn to vector elements.
shift
(shift v)
(shift v x)
Add value to every vector element.
sigmoid
(sigmoid vector)
Apply sigmoid to vector elements.
signum
(signum vector)
Apply signum to vector elements.
sim-cos
(sim-cos v1 v2)
Cosine similarity
sin
(sin vector)
Apply sin to vector elements.
sinc
(sinc vector)
Apply sinc to vector elements.
sinh
(sinh vector)
Apply sinh to vector elements.
size
(size v)
Length of the vector.
softmax
(softmax v)
sq
(sq vector)
Apply sq to vector elements.
sqrt
(sqrt vector)
Apply sqrt to vector elements.
sub
(sub v)
(sub v1 v2)
Subtraction of two vectors.
sum
(sum v)
Sum of elements
tan
(tan vector)
Apply tan to vector elements.
tanh
(tanh vector)
Apply tanh to vector elements.
to-polar
(to-polar v)
To polar coordinates (2d, 3d only), first element is length, the rest angle.
to-vec DEPRECATED
Deprecated: v1.5.0
Same as vec->Vec. Deprecated.
transform
(transform v o vx vy)
(transform v o vx vy vz)
Transform vector; map point to coordinate system defined by origin, vx and vy (as bases), Only for Vec2
and Vec3
types.
triple-product
(triple-product a b c)
a o (b x c)
trunc
(trunc vector)
Apply trunc to vector elements.
vec->RealVector
(vec->RealVector v)
Convert to Apache Commons Math RealVector
vec->Vec
(vec->Vec v)
Convert to Clojure primitive vector Vec
.
vec->array
(vec->array v)
Convert to double array
vec->seq
(vec->seq v)
Convert to sequence (same as seq)
vec2
(vec2 x y)
(vec2)
Make 2d vector.
vec3
(vec3 x y z)
(vec3 v z)
(vec3)
Make Vec2 vector
vec4
(vec4 x y z w)
(vec4 v w)
(vec4 v z w)
(vec4)
Make Vec4 vector
xlogx
(xlogx vector)
Apply xlogx to vector elements.
zero-count
(zero-count v)
Count zeros in vector
zero?
(zero? v)
Is vector zero?
Matrices
Reference
fastmath.matrix
Fixed size (2x2, 3x3, 4x4) matrix types.
->Mat2x2
(->Mat2x2 a00 a01 a10 a11)
Positional factory function for class fastmath.matrix.Mat2x2.
->Mat3x3
(->Mat3x3 a00 a01 a02 a10 a11 a12 a20 a21 a22)
Positional factory function for class fastmath.matrix.Mat3x3.
->Mat4x4
(->Mat4x4 a00 a01 a02 a03 a10 a11 a12 a13 a20 a21 a22 a23 a30 a31 a32 a33)
Positional factory function for class fastmath.matrix.Mat4x4.
acos
(acos vector)
Apply acos to matrix elements.
acosh
(acosh vector)
Apply acosh to matrix elements.
acot
(acot vector)
Apply acot to matrix elements.
acoth
(acoth vector)
Apply acoth to matrix elements.
acsc
(acsc vector)
Apply acsc to matrix elements.
acsch
(acsch vector)
Apply acsch to matrix elements.
add
(add A)
(add A B)
Add matrices, C=A+B.
adds
(adds A s)
Add scalar to all matrix elements
asec
(asec vector)
Apply asec to matrix elements.
asech
(asech vector)
Apply asech to matrix elements.
asin
(asin vector)
Apply asin to matrix elements.
asinh
(asinh vector)
Apply asinh to matrix elements.
atan
(atan vector)
Apply atan to matrix elements.
atanh
(atanh vector)
Apply atanh to matrix elements.
cb
(cb vector)
Apply cb to matrix elements.
cbrt
(cbrt vector)
Apply cbrt to matrix elements.
ceil
(ceil vector)
Apply ceil to matrix elements.
cholesky
(cholesky A)
(cholesky A upper?)
Calculate L (lower by default) triangular for where L * L^T = A.
Checks only for symmetry, can return NaNs when A is not positive-definite.
col
(col A c)
Return column as a vector
cols
(cols A)
Return matrix columns
cols->RealMatrix
(cols->RealMatrix cols)
Return Apache Commons Math Array2DRowMatrix from sequence of columns
cols->mat
(cols->mat real-matrix-cols)
(cols->mat [a00 a10] [a01 a11])
(cols->mat [a00 a10 a20] [a01 a11 a21] [a02 a12 a22])
(cols->mat [a00 a10 a20 a30] [a01 a11 a21 a31] [a02 a12 a22 a32] [a03 a13 a23 a33])
Create nxn matrix from nd vectors (columns).
cols->mat2x2
(cols->mat2x2 [a00 a10] [a01 a11])
Create 2x2 matrix from 2d vectors (columns).
cols->mat3x3
(cols->mat3x3 [a00 a10 a20] [a01 a11 a21] [a02 a12 a22])
Create 3x3 matrix from 3d vectors (columns).
cols->mat4x4
(cols->mat4x4 [a00 a10 a20 a30] [a01 a11 a21 a31] [a02 a12 a22 a32] [a03 a13 a23 a33])
Create 4x4 matrix from 4d vectors (columns).
condition
(condition A)
(condition A norm-type)
Condition number calculated for L2 norm by default (see norm for other norm types).
Cond(A) = norm(A) * norm(inv(A))
cos
(cos vector)
Apply cos to matrix elements.
cosh
(cosh vector)
Apply cosh to matrix elements.
cot
(cot vector)
Apply cot to matrix elements.
coth
(coth vector)
Apply coth to matrix elements.
csc
(csc vector)
Apply csc to matrix elements.
csch
(csch vector)
Apply csch to matrix elements.
degrees
(degrees vector)
Apply degrees to matrix elements.
det
(det A)
Return determinant of the matrix.
diag
(diag A)
Return diagonal of the matrix as a vector.
diagonal
(diagonal v)
(diagonal a11 a22)
(diagonal a11 a22 a33)
(diagonal a11 a22 a33 a44)
Create diagonal matrix
eigenvalues
(eigenvalues A)
Return complex eigenvalues for given matrix as a sequence
eigenvalues-matrix
(eigenvalues-matrix A)
Return eigenvalues for given matrix as a diagonal or block diagonal matrix
eigenvectors
(eigenvectors A)
(eigenvectors A normalize?)
Return eigenvectors as a matrix (columns). Vectors can be normalized.
emulm
(emulm A B)
Multiply two matrices element-wise, Hadamard product, C=AoB
entry
(entry A row col)
Get entry at given row and column
exp
(exp vector)
Apply exp to matrix elements.
expm1
(expm1 vector)
Apply expm1 to matrix elements.
eye
(eye size)
Identity matrix for given size
floor
(floor vector)
Apply floor to matrix elements.
fmap
(fmap A f)
Apply a function f
to each matrix element.
frac
(frac vector)
Apply frac to matrix elements.
inverse
(inverse m)
Matrix inversion.
Returns nil
if inversion doesn’t exist.
ln
(ln vector)
Apply ln to matrix elements.
log
(log vector)
Apply log to matrix elements.
log10
(log10 vector)
Apply log10 to matrix elements.
log1mexp
(log1mexp vector)
Apply log1mexp to matrix elements.
log1p
(log1p vector)
Apply log1p to matrix elements.
log1pexp
(log1pexp vector)
Apply log1pexp to matrix elements.
log1pmx
(log1pmx vector)
Apply log1pmx to matrix elements.
log1psq
(log1psq vector)
Apply log1psq to matrix elements.
log2
(log2 vector)
Apply log2 to matrix elements.
logexpm1
(logexpm1 vector)
Apply logexpm1 to matrix elements.
logit
(logit vector)
Apply logit to matrix elements.
logmxp1
(logmxp1 vector)
Apply logmxp1 to matrix elements.
mat
(mat real-matrix-rows)
(mat a00 a01 a10 a11)
(mat a00 a01 a02 a10 a11 a12 a20 a21 a22)
(mat a00 a01 a02 a03 a10 a11 a12 a13 a20 a21 a22 a23 a30 a31 a32 a33)
Create mat2x2, mat3x3 or mat4x4 or RealMatrix from rows
mat->RealMatrix
(mat->RealMatrix A)
Return Apache Commons Math Array2DRowMatrix from a 2x2, 3x3 or 4x4 matrix
mat->array
(mat->array A)
Return flat double array of entries (row order)
mat->array2d
(mat->array2d A)
Return doubles of doubles
mat->float-array
(mat->float-array A)
Return flat float array of entries (row order)
mat->float-array2d
(mat->float-array2d A)
Return doubles of doubles
mat->seq
(mat->seq A)
Return flat sequence of entries (row order)
mat2x2
(mat2x2 v)
(mat2x2 d1 d2)
(mat2x2 a00 a01 a10 a11)
Create 2x2 matrix.
Arity:
- 1 - fills matrix with given value
- 2 - creates diagonal matrix
- 4 - creates row ordered matrix
mat3x3
(mat3x3 v)
(mat3x3 d1 d2 d3)
(mat3x3 a00 a01 a02 a10 a11 a12 a20 a21 a22)
Create 3x3 matrix.
Arity:
- 1 - fills matrix with given value
- 3 - creates diagonal matrix
- 9 - creates row ordered matrix
mat4x4
(mat4x4 v)
(mat4x4 d1 d2 d3 d4)
(mat4x4 a00 a01 a02 a03 a10 a11 a12 a13 a20 a21 a22 a23 a30 a31 a32 a33)
Create 4x4 matrix.
Arity:
- 1 - fills matrix with given value
- 4 - creates diagonal matrix
- 16 - creates row ordered matrix
mulm
(mulm A B)
(mulm A transposeA? B transposeB?)
Multiply two matrices, C=AxB.
Optionally you can request transposition of matrices.
mulmt
(mulmt A B)
Multiply with transposed matrix, C=AxB^T
muls
(muls A s)
Multply matrix by a scalar, C=sA
mulv
(mulv A v)
Multply matrix by vector, x=Av
ncol
(ncol A)
Return number of rows
negate
(negate A)
Negate all matrix elements, C=-A
norm
(norm A)
(norm A norm-type)
Calculate norm of the matrix for given type, default: 1 (maximum absolute column sum).
All norm types are: * 1 - maximum absolute column sum * :inf - maximum absolute row sum * 2 - spectral norm, maximum singular value * :max - maximum absolute value * :frobenius - Frobenius norm * [p,q] - generalized L_pq norm, [2,2] - Frobenius norm, [p,p] - entrywise p-norm * [p] - Shatten p-norm, [1] - nuclear/trace norm
normalize
(normalize A)
(normalize A rows?)
Normalize columns (or rows)
nrow
(nrow A)
Return number of rows
outer
(outer v1 v2)
Outer project for two vectors.
radians
(radians vector)
Apply radians to matrix elements.
rint
(rint vector)
Apply rint to matrix elements.
rotation-matrix-2d
(rotation-matrix-2d theta)
Create rotation matrix for a plane
rotation-matrix-3d
(rotation-matrix-3d [x y z])
(rotation-matrix-3d x y z)
Create rotation matrix for a 3d space. Tait–Bryan angles z-y′-x″
rotation-matrix-3d-x
(rotation-matrix-3d-x a)
Create rotation matrix for a 3d space, x-axis, right hand rule.
rotation-matrix-3d-y
(rotation-matrix-3d-y a)
Create rotation matrix for a 3d space, y-axis, right hand rule.
rotation-matrix-3d-z
(rotation-matrix-3d-z a)
Create rotation matrix for a 3d space, z-axis, right hand rule.
rotation-matrix-axis-3d
(rotation-matrix-axis-3d angle axis)
Create 3d rotation matrix for axis ratation.
round
(round vector)
Apply round to matrix elements.
row
(row A r)
Return row as a vector
rows
(rows A)
Return matrix rows
rows->RealMatrix
(rows->RealMatrix rows)
Return Apache Commons Math Array2DRowMatrix from sequence of rows
rows->mat
(rows->mat real-matrix-rows)
(rows->mat [a00 a01] [a10 a11])
(rows->mat [a00 a01 a02] [a10 a11 a12] [a20 a21 a22])
(rows->mat [a00 a01 a02 a03] [a10 a11 a12 a13] [a20 a21 a22 a23] [a30 a31 a32 a33])
Create nxn matrix from nd vectors (rows).
rows->mat2x2
(rows->mat2x2 [a00 a01] [a10 a11])
Create 2x2 matrix from 2d vectors (rows).
rows->mat3x3
(rows->mat3x3 [a00 a01 a02] [a10 a11 a12] [a20 a21 a22])
Create 3x3 matrix from 3d vectors (rows).
rows->mat4x4
(rows->mat4x4 [a00 a01 a02 a03] [a10 a11 a12 a13] [a20 a21 a22 a23] [a30 a31 a32 a33])
Create 4x4 matrix from 4d vectors (rows).
safe-sqrt
(safe-sqrt vector)
Apply safe-sqrt to matrix elements.
scale-cols
(scale-cols A)
(scale-cols A scale)
Shift columns by a value (default: sqrt(sum(x^2)/(n-1))) or a result of the function
scale-rows
(scale-rows A)
(scale-rows A scale)
Shift rows by a value (default: sqrt(sum(x^2)/(n-1))) or a result of the function
sec
(sec vector)
Apply sec to matrix elements.
sech
(sech vector)
Apply sech to matrix elements.
sfrac
(sfrac vector)
Apply sfrac to matrix elements.
sgn
(sgn vector)
Apply sgn to matrix elements.
shift-cols
(shift-cols A)
(shift-cols A shift)
Shift columns by a value or a result of the function (mean by default)
shift-rows
(shift-rows A)
(shift-rows A shift)
Shift rows by a value or a result of the function (mean by default)
sigmoid
(sigmoid vector)
Apply sigmoid to matrix elements.
signum
(signum vector)
Apply signum to matrix elements.
sin
(sin vector)
Apply sin to matrix elements.
sinc
(sinc vector)
Apply sinc to matrix elements.
singular-values
(singular-values A)
Returun singular values of the matrix as sqrt of eigenvalues of A^T * A matrix.
sinh
(sinh vector)
Apply sinh to matrix elements.
solve
(solve A b)
Solve linear equation Ax=b
sq
(sq vector)
Apply sq to matrix elements.
sqrt
(sqrt vector)
Apply sqrt to matrix elements.
sub
(sub A)
(sub A B)
Subract matrices, C=A-B.
symmetric?
(symmetric? A)
Check if matrix is symmetric
tan
(tan vector)
Apply tan to matrix elements.
tanh
(tanh vector)
Apply tanh to matrix elements.
tmulm
(tmulm A B)
Transpose and multiply, C=A^TxB
tmulmt
(tmulmt A B)
Transpose both and multiply, C=ATxBT
trace
(trace A)
Return trace of the matrix (sum of diagonal elements)
transpose
(transpose A)
Transpose matrix, C=A^T
trunc
(trunc vector)
Apply trunc to matrix elements.
vtmul
(vtmul A v)
Multiply transposed vector by matrix, C=v^T A
xlogx
(xlogx vector)
Apply xlogx to matrix elements.
zero
(zero size)
Zero matrix for given size
source: clay/vector_matrix.clj