mikera.matrixx
Interface IMatrix
-
- All Superinterfaces:
- java.lang.Cloneable, java.lang.Comparable<INDArray>, INDArray, java.io.Serializable
- All Known Subinterfaces:
- IFastColumns, IFastRows
- All Known Implementing Classes:
- AArrayMatrix, ABandedMatrix, ABlockMatrix, ABooleanMatrix, ADenseArrayMatrix, ADiagonalMatrix, AMatrix, APrimitiveMatrix, ARectangularMatrix, ASingleBandMatrix, ASparseRCMatrix, AStridedMatrix, ATriangularMatrix, AVectorAsMatrixView, AVectorMatrix, BandedMatrix, BaseStridedMatrix, BlockDiagonalMatrix, BroadcastVectorMatrix, BufferMatrix, ColumnMatrix, DenseColumnMatrix, DiagonalMatrix, IdentityMatrix, ImmutableMatrix, LowerTriangularMatrix, Matrix, Matrix11, Matrix22, Matrix33, MatrixBuilder, PermutationMatrix, PermutedMatrix, QuadtreeMatrix, RowMatrix, ScalarMatrix, SparseColumnMatrix, SparseRowMatrix, StridedMatrix, StridedRowMatrix, SubMatrixView, TransposedMatrix, UpperTriangularMatrix, VectorMatrixM3, VectorMatrixMN, WrappedDiagonalMatrix, ZeroMatrix
public interface IMatrix extends INDArray
Interface to specify matrix-specific operations. Matrix implementations should extend AMatrix which implements this interface, contains important functionality implementations, and serves as the abstract base class for all Vectorz matrices.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voidadd2(AMatrix a, AMatrix b)Adds two matrices to this matrix.voidaddAt(int i, int j, double d)Adds a value at a specific position in the matrix, mutating the matrix Does not perform bounds checking - this in an unsafe operationAMatrixaddCopy(AMatrix a)Adds another matrix to this matrix, returning a new matrixAMatrixaddCopy(AVector v)Adds a vector to every row of this matrix, returning a new matrixintcolumnCount()Gets the number of columns in this matrix (dimension 1)doublediagonalProduct()Returns the product of all elements on the leading diagonal of this matrixdoubleget(int row, int column)Gets the element at the specified position in this matrixAVectorgetBand(int band)Gets a band of a matrix The band is defined such that: - 0 is the main diagonal - bands above the main diagonal are 1, 2, 3 etc.AVectorgetColumn(int column)Returns a column of the matrix.AVectorgetColumnClone(int column)Returns a column of the matrix as a new cloned, mutable vector The cloned column may be modified without affecting the original matrix.java.util.List<AVector>getColumns()Gets a List of columns of a matrix.AVectorgetColumnView(int column)Returns a column of the matrix as a vector view.AVectorgetRow(int row)Returns a row of the matrix.AVectorgetRowClone(int row)Returns a row of the matrix as a new cloned, mutable vector.java.util.List<AVector>getRows()Gets a List of rows of a matrix.AVectorgetRowView(int row)Returns a row of the matrix as a vector view.AMatrixgetTranspose()Returns the transpose of this matrix.AMatrixgetTransposeView()Returns a transposed view of this matrix.AMatrixinnerProduct(AMatrix a)Computes the inner product of this matrix with another.AVectorinnerProduct(AVector source)Transforms a source vector into a using matrix multiplication (inner product).VectorinnerProduct(Vector source)Transforms a dense source Vector using matrix multiplication (inner product).AMatrixinverse()Computes the inverse of this matrix.booleanisDiagonal()Returns true iff this matrix is a square diagonal matrixbooleanisIdentity()Checks if this is an identity matrix (i.e.booleanisInvertible()Checks if this is an invertible matrix (i.e.booleanisRectangularDiagonal()Returns true iff this matrix is a diagonal matrix (might not be square)booleanisSquare()Checks if this is a square matrixbooleanisSymmetric()Returns true if this matrix is symmetricintrowCount()Gets the number of rows in this matrix (dimension 0)voidset(int row, int column, double value)Sets the element at the specified position in this matrixAMatrixsubMatrix(int rowStart, int rows, int colStart, int cols)Gets a rectangular submatrix view of part of a matrixdouble[][]toNestedDoubleArrays()Converts this matrix to nested double[][] arraydoubletrace()Computes the trace of a matrix, i.e.voidtransform(AVector source, AVector dest)Transforms a source vector into a destination vector, using matrix multiplication (inner product).voidtransformInPlace(AVector v)voidtransposeInPlace()Transposes a matrix in place, if possible.-
Methods inherited from interface mikera.arrayz.INDArray
abs, absCopy, absDiff, absDiffCopy, add, add, addApplyOp, addAt, addCopy, addCopy, addInnerProduct, addInnerProduct, addMultiple, addMultipleSparse, addOuterProduct, addOuterProductSparse, addPower, addPower, addSparse, addSparse, addToArray, applyOp, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, asVector, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, broadcastLike, clamp, clone, componentCount, copy, dense, denseClone, dimensionality, divide, divide, divideCopy, divideCopy, elementAbsPowSum, elementCount, elementIterator, elementMax, elementMaxAbs, elementMin, elementPowSum, elementProduct, elementsEqual, elementSquaredSum, elementSum, ensureMutable, epsilonEquals, epsilonEquals, equals, equalsArray, equalsArray, exactClone, exp, fill, get, get, get, get, get, get, get, get, getComponent, getComponents, getElement, getElements, getElements, getElements, getElements, getLongShape, getShape, getShape, getShapeClone, getSlices, getSlices, getSliceViews, getTransposeCopy, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, isBoolean, isDense, isElementConstrained, isFullyMutable, isMutable, isSameShape, isSparse, isView, isZero, join, join, log, multiply, multiply, multiplyCopy, multiplyCopy, mutable, negate, negateCopy, nonZeroCount, outerProduct, pow, reciprocal, reciprocalCopy, reduce, reduce, reduceSlices, reduceSlices, reorder, reorder, reshape, rotateView, scale, scaleAdd, scaleAdd, scaleCopy, set, set, set, set, set, set, setApplyOp, setElements, setElements, setElements, setInnerProduct, setMultiple, setMultiple, setSparse, setSparse, signum, signumCopy, slice, slice, sliceCount, sliceValue, sparse, sparseClone, sqrt, square, squareCopy, sub, sub, subArray, subCopy, toDoubleArray, toDoubleBuffer, toSliceArray, toVector, validate, withComponents
-
-
-
-
Method Detail
-
rowCount
int rowCount()
Gets the number of rows in this matrix (dimension 0)- Returns:
-
columnCount
int columnCount()
Gets the number of columns in this matrix (dimension 1)- Returns:
-
get
double get(int row, int column)Gets the element at the specified position in this matrix
-
set
void set(int row, int column, double value)Sets the element at the specified position in this matrix
-
getRow
AVector getRow(int row)
Returns a row of the matrix. May or may not be a view, depending on matrix type. Intended for the fastest possible read access of the row. This often means a view, but might not be (e.g. getRow on a Matrix33 returns a Vector3).
-
getColumn
AVector getColumn(int column)
Returns a column of the matrix. May or may not be a view, depending on matrix type. Intended for the fastest possible read access of the column. This often means a view, but might not be (e.g. getColumn on a Matrix33 returns a Vector3).
-
getRowView
AVector getRowView(int row)
Returns a row of the matrix as a vector view. May be used to modify the original matrix.
-
getColumnView
AVector getColumnView(int column)
Returns a column of the matrix as a vector view. May be used to modify the original matrix.
-
getRowClone
AVector getRowClone(int row)
Returns a row of the matrix as a new cloned, mutable vector. The cloned row may be modified without affecting the original matrix.
-
getColumnClone
AVector getColumnClone(int column)
Returns a column of the matrix as a new cloned, mutable vector The cloned column may be modified without affecting the original matrix.
-
getBand
AVector getBand(int band)
Gets a band of a matrix The band is defined such that: - 0 is the main diagonal - bands above the main diagonal are 1, 2, 3 etc. - bands below the main diagonal are -1, -2, -3 etc.- Parameters:
band-- Returns:
-
getTranspose
AMatrix getTranspose()
Returns the transpose of this matrix. Will be a transposed view by default, but specialised matrix type may override this if they are able to provide a better implementation.- Specified by:
getTransposein interfaceINDArray- Returns:
- the transpose of this matrix
-
getTransposeView
AMatrix getTransposeView()
Returns a transposed view of this matrix.- Specified by:
getTransposeViewin interfaceINDArray- Returns:
- the transpose of this matrix, as a view
-
transposeInPlace
void transposeInPlace()
Transposes a matrix in place, if possible. Throws an exception if this is not possible (e.g. if the matrix is not square or not sufficiently mutable)
-
isSquare
boolean isSquare()
Checks if this is a square matrix- Returns:
- true if square, false otherwise
-
isInvertible
boolean isInvertible()
Checks if this is an invertible matrix (i.e. a square matrix with a non-zero determinant)- Returns:
- true if invertible, false otherwise
-
isIdentity
boolean isIdentity()
Checks if this is an identity matrix (i.e. 1.0 in leading diagonal, 0.0 elsewhere)- Returns:
- true if this matrix is a square identity matrix, false otherwise.
-
innerProduct
AVector innerProduct(AVector source)
Transforms a source vector into a using matrix multiplication (inner product).- Specified by:
innerProductin interfaceINDArray- Parameters:
source- A vector- Returns:
- A new vector
-
innerProduct
Vector innerProduct(Vector source)
Transforms a dense source Vector using matrix multiplication (inner product).- Returns:
- A new dense vector
-
transform
void transform(AVector source, AVector dest)
Transforms a source vector into a destination vector, using matrix multiplication (inner product). The destination vector is overwritten.
-
transformInPlace
void transformInPlace(AVector v)
-
inverse
AMatrix inverse()
Computes the inverse of this matrix.- Returns:
- A matrix which is the inverse of this matrix, or null if the inverse does not exist.
-
trace
double trace()
Computes the trace of a matrix, i.e. the sum of all elements on the leading diagonal- Returns:
-
addCopy
AMatrix addCopy(AMatrix a)
Adds another matrix to this matrix, returning a new matrix- Parameters:
v-- Returns:
-
addCopy
AMatrix addCopy(AVector v)
Adds a vector to every row of this matrix, returning a new matrix- Parameters:
v-- Returns:
-
diagonalProduct
double diagonalProduct()
Returns the product of all elements on the leading diagonal of this matrix- Returns:
-
innerProduct
AMatrix innerProduct(AMatrix a)
Computes the inner product of this matrix with another. Equivalent to matrix x matrix multiplication- Parameters:
a-- Returns:
-
getRows
java.util.List<AVector> getRows()
Gets a List of rows of a matrix. May return either copies or views, depending on the specific matrix type.- Returns:
-
getColumns
java.util.List<AVector> getColumns()
Gets a List of columns of a matrix. May return either copies or views, depending on the specific matrix type.- Returns:
-
isSymmetric
boolean isSymmetric()
Returns true if this matrix is symmetric- Returns:
-
add2
void add2(AMatrix a, AMatrix b)
Adds two matrices to this matrix. May be better optimised than adding both matrices individually.- Parameters:
a-b-
-
isDiagonal
boolean isDiagonal()
Returns true iff this matrix is a square diagonal matrix
-
isRectangularDiagonal
boolean isRectangularDiagonal()
Returns true iff this matrix is a diagonal matrix (might not be square)
-
toNestedDoubleArrays
double[][] toNestedDoubleArrays()
Converts this matrix to nested double[][] array- Returns:
-
subMatrix
AMatrix subMatrix(int rowStart, int rows, int colStart, int cols)
Gets a rectangular submatrix view of part of a matrix
-
addAt
void addAt(int i, int j, double d)Adds a value at a specific position in the matrix, mutating the matrix Does not perform bounds checking - this in an unsafe operation
-
-
DMelt 3.0 © DataMelt by jWork.ORG