tensor v0.8.0 Matrix
Summary
Functions
Elementwise addition of matrixs matrix_a
and matrix_b
Returns the n
-th column of the matrix as a Vector
Returns the columns of this matrix as a list of Vectors
Creates a square matrix where the diagonal elements are filled with the elements of the given List or Vector.
The second argument is an optional identity
to be used for all elements not part of the diagonal
Elementwise division of matrix_a
and matrix_b
.
Make sure that the identity of matrix_b
isn’t 0 before doing this
Returns the element at index
from matrix
Builds a Matrix up from a list of vectors
Returns the element at index
from matrix
. If index
is out of bounds, returns default
Returns the current identity of matrix matrix
Creates an ‘identity’ matrix
Returns the values in the main diagonal (top left to bottom right) as list
true
if a
is a Matrix
Elementwise multiplication of matrix_a
with matrix_b
Creates a new matrix of dimensions width
x height
Calculates the product of matrix
with matrix
, exponent
times.
If exponent
== 0, then the result will be the identity matrix with the same dimensions as the given matrix
Calculates the Matrix Product. This is a new matrix, obtained by multiplying
taking the m
rows of the m_by_n_matrix
, the p
columns of the n_by_p_matrix
and calculating the dot-product (See Vector.dot_product/2
) of these two n
-length vectors.
The resulting values are stored at position [m][p] in the final matrix
Returns the n
-th row of the matrix as a Vector
Takes a vector, and returns a 1×n
matrix
Returns the rows of this matrix as a list of Vectors
Elementwise subtraction of matrix_b
from matrix_a
True if the matrix is square and the same as its transpose
Returns the sum of the main diagonal of a square matrix
Functions
See Tensor.add/2
.
See Tensor.add_number/2
.
Returns the n
-th column of the matrix as a Vector.
If you’re doing a lot of calls to column
, consider transposing the matrix
and calling rows
on that transposed matrix, as it will be faster.
Creates a square matrix where the diagonal elements are filled with the elements of the given List or Vector.
The second argument is an optional identity
to be used for all elements not part of the diagonal.
See Tensor.div/2
.
Elementwise division of matrix_a
and matrix_b
.
Make sure that the identity of matrix_b
isn’t 0 before doing this.
See Tensor.div_number/2
.
Builds a Matrix up from a list of vectors.
Will only work as long as the vectors have the same length.
Returns the element at index
from matrix
. If index
is out of bounds, returns default
.
Creates an ‘identity’ matrix.
This is a square matrix of size size
that has the diag_identity
value (default: 1
) at the diagonal, and the rest is 0
.
Optionally pass in a third argument, which is the value the rest of the elements in the matrix will be set to.
See Tensor.lift/1
.
See Tensor.map/2
.
See Tensor.merge/3
.
See Tensor.mul/2
.
See Tensor.mul_number/2
.
Creates a new matrix of dimensions width
x height
.
Optionally pass in a fourth argument, which will be the default values the matrix will be filled with. (default: 0
)
See Tensor.pop/3
.
Calculates the product of matrix
with matrix
, exponent
times.
If exponent
== 0, then the result will be the identity matrix with the same dimensions as the given matrix.
This is calculated using the fast exponentiation by squaring algorithm.
Calculates the Matrix Product. This is a new matrix, obtained by multiplying
taking the m
rows of the m_by_n_matrix
, the p
columns of the n_by_p_matrix
and calculating the dot-product (See Vector.dot_product/2
) of these two n
-length vectors.
The resulting values are stored at position [m][p] in the final matrix.
There is no way to perform this operation in a sparse way, so it is performed dense.
The identities of the two matrices cannot be kept; nil
is used as identity of the output Matrix.
See Tensor.sub/2
.
See Tensor.sub_number/2
.
See Tensor.to_list/1
.
Returns the sum of the main diagonal of a square matrix.
Note that this method will fail when called with a non-square matrix