Matrix

public class Matrix extends Tensor

Represents real matrix. Matrix class is a subclass of Tensor class.

Parameters

data

must fit into the shape of this matrix.

Constructors

Matrix
Link copied to clipboard
Matrix Matrix(Integer rows2, Integer cols2, LongArray data2)
data can be LongArray.
Matrix
Link copied to clipboard
Matrix Matrix(Integer rows2, Integer cols2, FloatArray data2)
data can be FloatArray.
Matrix
Link copied to clipboard
Matrix Matrix(Integer rows2, Integer cols2, IntArray data2)
data can be IntArray.
Matrix
Link copied to clipboard
Matrix Matrix(Integer rows2, Integer cols2, Function2<Integer, Integer, Number> lambda)
It is possible to set a value using lambda function.
Matrix
Link copied to clipboard
Matrix Matrix(Integer rows, Integer cols, DoubleArray data)
Creates a new matrix.

Types

Companion
Link copied to clipboard
public class Companion

Functions

addRow
Link copied to clipboard
final Matrix addRow(Integer srcRowIndex, Integer dstRowIndex, Number fraction)
Do a row addition transformation; add dstRow multiplied by fraction to srcRow.
adjoint
Link copied to clipboard
final Matrix adjoint()
Calculate adjoint matrix of this matrix.
columnWiseMean
Link copied to clipboard
final RowVector columnWiseMean()
Calculate the mean value of each column.
colVecNormSq
Link copied to clipboard
final RowVector colVecNormSq()
Calculate the squared norm of each column vector.
concat
Link copied to clipboard
final Matrix concat(Matrix other, Integer concatDim)
Concatenate to other matrix.
final Tensor concat(Tensor other, Integer concatDim)
Concatenate to other tensor.
copy
Link copied to clipboard
Matrix copy()
Same as Tensor.copy but returns Matrix
div
Link copied to clipboard
Matrix div(Number other)
eltwiseMul
Link copied to clipboard
final Matrix eltwiseMul(Matrix other)
Element-wise multiplication.
equals
Link copied to clipboard
Boolean equals(Object other)
flatten
Link copied to clipboard
final Tensor flatten()
Reshape to a 1-dimensional tensor.
frobeniusNormSquared
Link copied to clipboard
final Double frobeniusNormSquared()
Calculate squared frobenius norm.
get
Link copied to clipboard
final Double get(IntArray indices)
final Tensor get(Long indexLong)
final Double get(Integer rowIndex, Integer colIndex)
getCols
Link copied to clipboard
final Integer getCols()
number of columns.
getDim
Link copied to clipboard
final Integer getDim()
tensor dimension.
getRows
Link copied to clipboard
final Integer getRows()
number of rows.
getShape
Link copied to clipboard
final IntArray getShape()
tensor shape.
getSubmatrix
Link copied to clipboard
Matrix getSubmatrix(Integer rowIndexStart, Integer rowIndexEnd, Integer colIndexStart, Integer colIndexEnd)
Get a submatrix by slicing this matrix.
map
Link copied to clipboard
Matrix map(Function1<Double, Number> lambda)
Same as Tensor.map but returns Matrix.
minorMatrix
Link copied to clipboard
final Matrix minorMatrix(Integer rowIndex, Integer colIndex)
Get a minor matrix.
minus
Link copied to clipboard
final Matrix minus(Matrix other)
final Tensor minus(Tensor other)
plus
Link copied to clipboard
final Matrix plus(Matrix other)
final Tensor plus(Tensor other)
pow
Link copied to clipboard
final Matrix pow(Integer n)
Calculate the nth power of this matrix.
pseudoEquals
Link copied to clipboard
final Boolean pseudoEquals(Tensor other)
Determines if other is close enough to be said the same.
reshape
Link copied to clipboard
final Tensor reshape(IntArray newShape)
Reshape this tensor.
final Matrix reshape(Integer newRows, Integer newCols)
Reshape this matrix.
rowVecNormSq
Link copied to clipboard
final ColumnVector rowVecNormSq()
Calculate the squared norm of each row vector.
rowWiseMean
Link copied to clipboard
final ColumnVector rowWiseMean()
Calculate the mean value of each row.
set
Link copied to clipboard
final Unit set(IntArray indices, Number value)
final Unit set(Integer rowIndex, Integer colIndex, Number value)
setSubmatrix
Link copied to clipboard
Unit setSubmatrix(Integer rowIndexStart, Integer rowIndexEnd, Integer colIndexStart, Integer colIndexEnd, Matrix other)
Set a submatrix by substituting other to desired position.
sum
Link copied to clipboard
final Double sum()
Calculate the sum of all values in this matrix.
switchRow
Link copied to clipboard
final Matrix switchRow(Integer rowIndex1, Integer rowIndex2)
Do a row switching transformation; exchange rowIndex1th row and rowIndex2th row.
times
Link copied to clipboard
Matrix times(Number other)
final ColumnVector times(ColumnVector other)
Matrix times(Matrix other)
final Tensor times(Tensor other)
toColVector
Link copied to clipboard
final ColumnVector toColVector()
Downcast to ColumnVector class if possible; i.e.
toComplex
Link copied to clipboard
ComplexMatrix toComplex()
Same as Tensor.toComplex but returns ComplexMatrix.
toMatrix
Link copied to clipboard
final Matrix toMatrix()
Downcast to Matrix class, if possible: i.e.
toRowVector
Link copied to clipboard
final RowVector toRowVector()
Downcast to RowVector class if possible; i.e.
toString
Link copied to clipboard
String toString()
trace
Link copied to clipboard
final Double trace()
Calculate the trace of this matrix.
transpose
Link copied to clipboard
Matrix transpose()
Transpose this Matrix.
unaryMinus
Link copied to clipboard
Matrix unaryMinus()
unaryPlus
Link copied to clipboard
Matrix unaryPlus()

Properties

cols
Link copied to clipboard
private final Integer cols
number of columns.
dim
Link copied to clipboard
private final Integer dim
tensor dimension.
rows
Link copied to clipboard
private final Integer rows
number of rows.
shape
Link copied to clipboard
private final IntArray shape
tensor shape.

Inheritors

ColumnVector
Link copied to clipboard
RowVector
Link copied to clipboard

Extensions

determinant
Link copied to clipboard
final Double determinant()
Calculates a determiant using LU decomposition through recursion, O(n^3).
eig
Link copied to clipboard
final Array<ComplexMatrixeig()
Solves eigenvalue problem of a square matrix and finds eigenvectors of each eigenvalue.
inverse
Link copied to clipboard
final Matrix inverse()
Calculates an inverse matrix of a square matrix.
plu
Link copied to clipboard
final Array<Matrixplu()
PLU decomposition of a matrix.
qr
Link copied to clipboard
final Array<Matrixqr()
Calculates QR decomposition of square matrix.
rowEchelonForm
Link copied to clipboard
final Matrix rowEchelonForm()
Calculate reduced row echelon form using Gaussian elimination.
svd
Link copied to clipboard
final Array<ComplexMatrixsvd()
Calculate the singular value decomposition of a matrix.