mikera.matrixx
Class Matrix11
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<AVector>
-
- mikera.matrixx.AMatrix
-
- mikera.matrixx.impl.APrimitiveMatrix
-
- mikera.matrixx.Matrix11
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, INDArray, IMatrix
public final class Matrix11 extends APrimitiveMatrix
Optimised 1x1 matrix implementation- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description Matrix11()Matrix11(AMatrix m)Matrix11(double value)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddAt(int i, int j, double value)Adds a value at a specific position in the matrix, mutating the matrix Does not perform bounds checking - this in an unsafe operationvoidapplyOp(Op op)Applies a unary operator to all elements of the array (in-place)intcheckSquare()Checks if a matrix is square.intcolumnCount()Gets the number of columns in this matrix (dimension 1)voidcopyColumnTo(int col, double[] dest, int destOffset)Copies the elements in a selected row of this matrix to a double arrayvoidcopyRowTo(int row, double[] dest, int destOffset)Copies the elements in a selected row of this matrix to a double arraydoubledeterminant()Calculates the determinant of the matrix.longelementCount()Returns the total number of elements in this array.doubleelementMax()Returns the maximum element value in this array.doubleelementMin()Returns the maximum element value in this array.doubleelementSquaredSum()Returns the squared sum of all elements in this matrixdoubleelementSum()Returns the sum of all elements in this matrixbooleanequalsArray(double[] data, int offset)Returns true if the elements in this array exactly match the elements in the given array, in row-major orderAMatrixexactClone()Creates a deep clone of an array, using the same class implementation as the original arraydoubleget(int row, int column)Returns the double value at the specified position in a 2D matrixVector1getColumnClone(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.voidgetElements(double[] data, int offset)Copies all elements of this array a double array at the specified offsetVector1getRowClone(int row)Returns a row of the matrix as a new cloned, mutable vector.Matrix11inverse()Computes the inverse of a matrix.booleanisDiagonal()Returns true iff this matrix is a square diagonal matrixbooleanisIdentity()Checks if this is an identity matrix (i.e.booleanisZero()Returns true if the matrix is the zero matrix (all components zero)voidmultiply(double factor)Multiplies all elements of the array in place by a given double valuelongnonZeroCount()Returns the number of non-zero elements in the array.introwCount()Gets the number of rows in this matrix (dimension 0)voidset(int row, int column, double value)Sets a value at a given position in a mutable 2D arraydouble[]toDoubleArray()Copies the elements of this array to a new double[] array.doubletrace()Computes the trace of a matrix, i.e.doubleunsafeGet(int row, int column)Gets an element in the matrix in an unsafe fashion, without performing bound checks The result is undefined if the row and column are out of bounds.voidunsafeSet(int row, int column, double value)Sets an element value in the matrix in an unsafe fashion, without performing bound checks The result is undefined if the row and column are out of bounds.-
Methods inherited from class mikera.matrixx.impl.APrimitiveMatrix
copy, getColumn, getRow, isFullyMutable, isSquare
-
Methods inherited from class mikera.matrixx.AMatrix
abs, add, add, add, add, add2, addCopy, addCopy, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addMultiple, addOuterProduct, addOuterProduct, addOuterProductSparse, addOuterProductSparse, addRowMultiple, addSparse, addSparse, addToArray, applyOp, applyOp, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, asVector, bandIndex, bandLength, bandPosition, bandStartColumn, bandStartRow, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, checkColumn, checkRow, clamp, clone, composeWith, dense, denseClone, diagonalProduct, dimensionality, divide, divide, divide, divide, divideCopy, elementIterator, elementsEqual, ensureMutable, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, equals, equalsTranspose, exp, fill, get, get, get, get, getBand, getBandWrapped, getColumns, getColumnView, getElement, getLeadingDiagonal, getLongShape, getRows, getRowView, getShape, getShape, getShapeClone, getSlices, getSlices, getSliceViews, getTranspose, getTransposeCopy, getTransposeView, hashCode, hasOrthonormalColumns, hasOrthonormalRows, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, inputDimensions, isBoolean, isElementConstrained, isHermitian, isInvertible, isLowerTriangular, isMutable, isOrthogonal, isOrthogonal, isPositiveDefinite, isRectangularDiagonal, isSameShape, isSameShape, isSymmetric, isUpperTriangular, isView, iterator, join, log, lowerBandwidth, lowerBandwidthLimit, mul, multiply, multiply, multiply, multiplyCopy, multiplyRow, mutable, negate, outerProduct, outputDimensions, pow, rank, reciprocal, reduce, reduce, reduceSlices, reduceSlices, reorder, reorder, replaceColumn, replaceRow, reshape, reshape, rotateView, rowDotProduct, scaleAdd, scaleAdd, set, set, set, set, set, set, set, set, setApplyOp, setApplyOp, setColumn, setElements, setElements, setMultiple, setMultiple, setMultiple, setMultiple, setMultiple, setRow, setSparse, setSparse, signum, slice, slice, sliceCount, sparse, sparseClone, sqrt, square, sub, sub, sub, subArray, subCopy, subMatrix, swapColumns, swapRows, toAffineTransform, toDoubleBuffer, toMatrix, toMatrixTranspose, toMutableMatrix, toNestedDoubleArrays, toSliceArray, toString, toStringFull, toVector, transform, transform, transformInPlace, transformInPlace, transposeInnerProduct, transposeInnerProduct, transposeInPlace, upperBandwidth, upperBandwidthLimit, validate
-
Methods inherited from class mikera.arrayz.impl.AbstractArray
absCopy, absDiff, absDiffCopy, add, addApplyOp, addAt, addCopy, addInnerProduct, addInnerProduct, addMultipleSparse, addPower, addPower, addSparse, broadcastLike, compareTo, componentCount, density, divideCopy, elementAbsPowSum, elementMaxAbs, elementPowSum, elementProduct, epsilonEquals, equals, equalsArray, get, get, get, get, getComponent, getComponents, getElements, getElements, getElements, isDense, isSparse, join, multiplyCopy, negateCopy, reciprocalCopy, scale, scaleCopy, setElements, setInnerProduct, setSparse, signumCopy, sliceValue, squareCopy, sub, sub, subCopy, withComponents
-
Methods inherited from interface mikera.arrayz.INDArray
absCopy, absDiff, absDiffCopy, addApplyOp, addAt, addInnerProduct, addMultipleSparse, addPower, addPower, addSparse, broadcastLike, componentCount, divideCopy, elementAbsPowSum, elementMaxAbs, elementPowSum, elementProduct, epsilonEquals, equalsArray, get, get, get, get, getComponent, getComponents, getElements, getElements, getElements, isDense, isSparse, join, multiplyCopy, negateCopy, reciprocalCopy, scale, scaleCopy, setElements, setInnerProduct, setSparse, signumCopy, sliceValue, squareCopy, sub, subCopy, withComponents
-
-
-
-
Constructor Detail
-
Matrix11
public Matrix11()
-
Matrix11
public Matrix11(double value)
-
Matrix11
public Matrix11(AMatrix m)
-
-
Method Detail
-
rowCount
public int rowCount()
Description copied from interface:IMatrixGets the number of rows in this matrix (dimension 0)- Returns:
-
columnCount
public int columnCount()
Description copied from interface:IMatrixGets the number of columns in this matrix (dimension 1)- Returns:
-
checkSquare
public int checkSquare()
Description copied from class:AMatrixChecks if a matrix is square. Returns the size if true, throws an exception otherwise;- Specified by:
checkSquarein classAPrimitiveMatrix- Returns:
-
determinant
public double determinant()
Description copied from class:AMatrixCalculates the determinant of the matrix.- Overrides:
determinantin classAMatrix
-
elementSum
public double elementSum()
Description copied from class:AMatrixReturns the sum of all elements in this matrix- Specified by:
elementSumin interfaceINDArray- Overrides:
elementSumin classAMatrix
-
elementMax
public double elementMax()
Description copied from interface:INDArrayReturns the maximum element value in this array. Throws an error if there are no elements.- Specified by:
elementMaxin interfaceINDArray- Overrides:
elementMaxin classAbstractArray<AVector>
-
elementMin
public double elementMin()
Description copied from interface:INDArrayReturns the maximum element value in this array. Throws an error if there are no elements.- Specified by:
elementMinin interfaceINDArray- Overrides:
elementMinin classAbstractArray<AVector>
-
elementSquaredSum
public double elementSquaredSum()
Description copied from class:AMatrixReturns the squared sum of all elements in this matrix- Specified by:
elementSquaredSumin interfaceINDArray- Overrides:
elementSquaredSumin classAMatrix
-
nonZeroCount
public long nonZeroCount()
Description copied from interface:INDArrayReturns the number of non-zero elements in the array.- Specified by:
nonZeroCountin interfaceINDArray- Overrides:
nonZeroCountin classAMatrix
-
elementCount
public long elementCount()
Description copied from interface:INDArrayReturns the total number of elements in this array. Equivalent to the product of all dimension sizes.- Specified by:
elementCountin interfaceINDArray- Overrides:
elementCountin classAMatrix
-
isDiagonal
public boolean isDiagonal()
Description copied from interface:IMatrixReturns true iff this matrix is a square diagonal matrix- Specified by:
isDiagonalin interfaceIMatrix- Overrides:
isDiagonalin classAMatrix
-
isZero
public boolean isZero()
Description copied from class:AMatrixReturns true if the matrix is the zero matrix (all components zero)
-
isIdentity
public boolean isIdentity()
Description copied from interface:IMatrixChecks if this is an identity matrix (i.e. 1.0 in leading diagonal, 0.0 elsewhere)- Specified by:
isIdentityin interfaceIMatrix- Overrides:
isIdentityin classAMatrix- Returns:
- true if this matrix is a square identity matrix, false otherwise.
-
inverse
public Matrix11 inverse()
Description copied from class:AMatrixComputes the inverse of a matrix. Returns null if the matrix is singular. Throws an Exception is the matrix is not square
-
trace
public double trace()
Description copied from interface:IMatrixComputes the trace of a matrix, i.e. the sum of all elements on the leading diagonal
-
get
public double get(int row, int column)Description copied from interface:INDArrayReturns the double value at the specified position in a 2D matrix
-
set
public void set(int row, int column, double value)Description copied from interface:INDArraySets a value at a given position in a mutable 2D array
-
unsafeGet
public double unsafeGet(int row, int column)Description copied from class:AMatrixGets an element in the matrix in an unsafe fashion, without performing bound checks The result is undefined if the row and column are out of bounds.
-
unsafeSet
public void unsafeSet(int row, int column, double value)Description copied from class:AMatrixSets an element value in the matrix in an unsafe fashion, without performing bound checks The result is undefined if the row and column are out of bounds.
-
addAt
public void addAt(int i, int j, double value)Description copied from interface:IMatrixAdds a value at a specific position in the matrix, mutating the matrix Does not perform bounds checking - this in an unsafe operation
-
applyOp
public void applyOp(Op op)
Description copied from interface:INDArrayApplies a unary operator to all elements of the array (in-place)
-
multiply
public void multiply(double factor)
Description copied from interface:INDArrayMultiplies all elements of the array in place by a given double value
-
getRowClone
public Vector1 getRowClone(int row)
Description copied from interface:IMatrixReturns a row of the matrix as a new cloned, mutable vector. The cloned row may be modified without affecting the original matrix.- Specified by:
getRowClonein interfaceIMatrix- Overrides:
getRowClonein classAMatrix
-
getColumnClone
public Vector1 getColumnClone(int column)
Description copied from interface:IMatrixReturns a column of the matrix as a new cloned, mutable vector The cloned column may be modified without affecting the original matrix.- Specified by:
getColumnClonein interfaceIMatrix- Overrides:
getColumnClonein classAMatrix
-
getElements
public void getElements(double[] data, int offset)Description copied from interface:INDArrayCopies all elements of this array a double array at the specified offset- Specified by:
getElementsin interfaceINDArray- Overrides:
getElementsin classAMatrix
-
copyRowTo
public void copyRowTo(int row, double[] dest, int destOffset)Description copied from class:AMatrixCopies the elements in a selected row of this matrix to a double array
-
copyColumnTo
public void copyColumnTo(int col, double[] dest, int destOffset)Description copied from class:AMatrixCopies the elements in a selected row of this matrix to a double array- Overrides:
copyColumnToin classAMatrixdest- Destination double[] array
-
exactClone
public AMatrix exactClone()
Description copied from interface:INDArrayCreates a deep clone of an array, using the same class implementation as the original array- Specified by:
exactClonein interfaceINDArray- Specified by:
exactClonein classAMatrix- Returns:
- A clone of the original array
-
equalsArray
public boolean equalsArray(double[] data, int offset)Description copied from interface:INDArrayReturns true if the elements in this array exactly match the elements in the given array, in row-major order- Specified by:
equalsArrayin interfaceINDArray- Overrides:
equalsArrayin classAMatrix- Parameters:
data- Array of double element values to check for equalityoffset- Offset into the data array- Returns:
-
toDoubleArray
public double[] toDoubleArray()
Description copied from interface:INDArrayCopies the elements of this array to a new double[] array.- Specified by:
toDoubleArrayin interfaceINDArray- Overrides:
toDoubleArrayin classAMatrix
-
-
DMelt 3.0 © DataMelt by jWork.ORG