mikera.matrixx.impl
Class IdentityMatrix
- java.lang.Object
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, INDArray, ISparse, IMatrix, IFastBands, IFastColumns, IFastRows
public class IdentityMatrix extends ADiagonalMatrix implements IFastRows, IFastColumns
Specialised identity matrix class. Immutable.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description AMatrixaddCopy(AMatrix m)Adds another matrix to this matrix, returning a new matrixstatic IdentityMatrixcreate(int i)doubledeterminant()Calculates the determinant of the matrix.doublediagonalProduct()Computes the product of entries on the main diagonal of a matrixdoubleelementAbsPowSum(double p)Returns the sum of the absolute values of all the elements raised to a specified powerdoubleelementMax()Returns the maximum element value in this array.doubleelementMin()Returns the maximum element value in this array.doubleelementPowSum(double p)Returns the sum of all the elements raised to a specified powerdoubleelementSum()Returns the sum of all elements in this matrixIdentityMatrixexactClone()Creates a deep clone of an array, using the same class implementation as the original arraydoubleget(int i, int j)Returns the double value at the specified position in a 2D matrixAxisVectorgetColumn(int j)Returns a column of the matrix.AxisVectorgetColumnView(int column)Returns a column of the matrix as a vector view.doublegetDiagonalValue(int i)AVectorgetLeadingDiagonal()Returns a vector view of the leading diagonal values of the matrixAxisVectorgetRow(int i)Returns a row of the matrix.AxisVectorgetRowView(int row)Returns a row of the matrix as a vector view.IdentityMatrixgetTransposeView()Returns a transposed view of the array.booleanhasUncountable()Checks to see if any element in the matrix is NaN of Infinite.AMatrixinnerProduct(ADiagonalMatrix a)Computes the inner product of this matrix with another diagonal matrix of the same shape.AMatrixinnerProduct(AMatrix a)Computes the inner product of this matrix with another.AVectorinnerProduct(AVector v)Computes the inner product of this array with a vectorAMatrixinverse()Computes the inverse of a matrix.booleanisBoolean()Returns true if the array is boolean (contains only 0.0 or 1.0 values)booleanisIdentity()Checks if this is an identity matrix (i.e.booleanisMutable()Returns true if the INDArray is mutable (at least partially)booleanisOrthogonal()Check to see if the matrix is orthogonal (default tolerance: 1e-8)booleanisOrthogonal(double tolerance)Check to see if the matrix is orthogonalbooleanisZero()Returns true if the matrix is the zero matrix (all components zero)ScalarMatrixmultiplyCopy(double d)Returns a copy of the array with all elements multiplied by a single constant valuelongnonZeroCount()Returns the number of non-zero elements in the array.intrank()Calculate the rank of a matrix.doublerowDotProduct(int i, AVector v)Returns the dot product of a specific row with a vector.voidset(int row, int column, double value)Sets a value at a given position in a mutable 2D 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(ADenseArrayVector v)voidtransformInPlace(AVector v)doubleunsafeGet(int i, int j)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.doubleunsafeGetDiagonalValue(int i)-
Methods inherited from class mikera.matrixx.impl.ADiagonalMatrix
addOuterProductSparse, addToArray, checkSquare, clone, columnCount, copyColumnTo, copyRowTo, dimensions, elementSquaredSum, equalsTranspose, getBand, getNonZeroBand, getTranspose, isDiagonal, isFullyMutable, isLowerTriangular, isRectangularDiagonal, isSameShape, isSameShape, isSquare, isSymmetric, isUpperTriangular, lowerBandwidthLimit, nonZeroBand, rowCount, setSparse, toDoubleArray, toMatrix, toMatrixTranspose, transform, transposeInnerProduct, transposeInPlace, upperBandwidthLimit, validate
-
Methods inherited from class mikera.matrixx.impl.ASingleBandMatrix
isSparse, subMatrix
-
Methods inherited from class mikera.matrixx.impl.ABandedMatrix
density, fill, lowerBandwidth, multiply, upperBandwidth
-
Methods inherited from class mikera.matrixx.AMatrix
abs, add, add, add, add, add2, addAt, addCopy, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addMultiple, addOuterProduct, addOuterProduct, addOuterProductSparse, addRowMultiple, addSparse, addSparse, applyOp, applyOp, applyOp, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, asVector, bandIndex, bandLength, bandPosition, bandStartColumn, bandStartRow, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, checkColumn, checkRow, clamp, composeWith, copy, dense, denseClone, dimensionality, divide, divide, divide, divide, divideCopy, elementCount, elementIterator, elementsEqual, ensureMutable, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, equals, equalsArray, exp, get, get, get, get, getBandWrapped, getColumnClone, getColumns, getElement, getElements, getLongShape, getRowClone, getRows, getShape, getShape, getShapeClone, getSlices, getSlices, getSliceViews, getTransposeCopy, hashCode, hasOrthonormalColumns, hasOrthonormalRows, immutable, innerProduct, innerProduct, innerProduct, innerProduct, inputDimensions, isElementConstrained, isHermitian, isInvertible, isPositiveDefinite, isSameShape, isView, iterator, join, log, mul, multiply, multiply, multiply, multiplyRow, mutable, negate, outerProduct, outputDimensions, pow, reciprocal, reduce, reduce, reduceSlices, reduceSlices, reorder, reorder, replaceColumn, replaceRow, reshape, reshape, rotateView, 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, swapColumns, swapRows, toAffineTransform, toDoubleBuffer, toMutableMatrix, toNestedDoubleArrays, toSliceArray, toString, toStringFull, toVector, transposeInnerProduct, unsafeSet
-
Methods inherited from class mikera.arrayz.impl.AbstractArray
absCopy, absDiff, absDiffCopy, add, addApplyOp, addAt, addCopy, addInnerProduct, addInnerProduct, addMultipleSparse, addPower, addPower, addSparse, broadcastLike, compareTo, componentCount, divideCopy, elementMaxAbs, elementProduct, epsilonEquals, equals, equalsArray, get, get, get, get, getComponent, getComponents, getElements, getElements, getElements, isDense, join, multiplyCopy, negateCopy, reciprocalCopy, scale, scaleCopy, setElements, setInnerProduct, signumCopy, sliceValue, squareCopy, sub, sub, subCopy, withComponents
-
Methods inherited from interface mikera.matrixx.IMatrix
add2, addAt, addCopy, columnCount, getBand, getColumnClone, getColumns, getRowClone, getRows, getTranspose, innerProduct, isDiagonal, isInvertible, isRectangularDiagonal, isSquare, isSymmetric, rowCount, subMatrix, toNestedDoubleArrays, transposeInPlace
-
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, elementCount, elementIterator, elementMaxAbs, elementProduct, elementsEqual, elementSquaredSum, ensureMutable, epsilonEquals, epsilonEquals, equals, equalsArray, equalsArray, 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, immutable, innerProduct, innerProduct, innerProduct, isDense, isElementConstrained, isFullyMutable, isSameShape, isSparse, isView, join, join, log, multiply, multiply, multiplyCopy, mutable, negate, negateCopy, 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
-
create
public static IdentityMatrix create(int i)
-
isMutable
public boolean isMutable()
Description copied from interface:INDArrayReturns true if the INDArray is mutable (at least partially)- Specified by:
isMutablein interfaceINDArray- Specified by:
isMutablein classADiagonalMatrix
-
isBoolean
public boolean isBoolean()
Description copied from interface:INDArrayReturns true if the array is boolean (contains only 0.0 or 1.0 values)- Specified by:
isBooleanin interfaceINDArray- Overrides:
isBooleanin classADiagonalMatrix
-
isZero
public boolean isZero()
Description copied from class:AMatrixReturns true if the matrix is the zero matrix (all components zero)- Specified by:
isZeroin interfaceINDArray- Overrides:
isZeroin classADiagonalMatrix
-
rowDotProduct
public double rowDotProduct(int i, AVector v)Description copied from class:AMatrixReturns the dot product of a specific row with a vector. Unsafe operation: performs no bounds checking- Overrides:
rowDotProductin classADiagonalMatrix- Returns:
-
get
public double get(int i, int j)Description copied from interface:INDArrayReturns the double value at the specified position in a 2D matrix
-
unsafeGet
public double unsafeGet(int i, int j)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.
-
getRow
public AxisVector getRow(int i)
Description copied from interface:IMatrixReturns 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
public AxisVector getColumn(int j)
Description copied from interface:IMatrixReturns 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).- Specified by:
getColumnin interfaceIMatrix- Specified by:
getColumnin interfaceIFastColumns- Overrides:
getColumnin classADiagonalMatrix
-
getRowView
public AxisVector getRowView(int row)
Description copied from interface:IMatrixReturns a row of the matrix as a vector view. May be used to modify the original matrix.- Specified by:
getRowViewin interfaceIMatrix- Overrides:
getRowViewin classABandedMatrix
-
getColumnView
public AxisVector getColumnView(int column)
Description copied from interface:IMatrixReturns a column of the matrix as a vector view. May be used to modify the original matrix.- Specified by:
getColumnViewin interfaceIMatrix- Overrides:
getColumnViewin classAMatrix
-
getDiagonalValue
public double getDiagonalValue(int i)
- Overrides:
getDiagonalValuein classADiagonalMatrix
-
unsafeGetDiagonalValue
public double unsafeGetDiagonalValue(int i)
- Overrides:
unsafeGetDiagonalValuein classADiagonalMatrix
-
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
-
transform
public void transform(AVector source, AVector dest)
Description copied from interface:IMatrixTransforms a source vector into a destination vector, using matrix multiplication (inner product). The destination vector is overwritten.
-
transformInPlace
public void transformInPlace(AVector v)
- Specified by:
transformInPlacein interfaceIMatrix- Overrides:
transformInPlacein classADiagonalMatrix
-
transformInPlace
public void transformInPlace(ADenseArrayVector v)
- Overrides:
transformInPlacein classADiagonalMatrix
-
getLeadingDiagonal
public AVector getLeadingDiagonal()
Description copied from class:AMatrixReturns a vector view of the leading diagonal values of the matrix- Specified by:
getLeadingDiagonalin classADiagonalMatrix- Returns:
-
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 classADiagonalMatrix- Returns:
- true if this matrix is a square identity matrix, false otherwise.
-
isOrthogonal
public boolean isOrthogonal()
Description copied from class:AMatrixCheck to see if the matrix is orthogonal (default tolerance: 1e-8)- Overrides:
isOrthogonalin classAMatrix- Returns:
-
isOrthogonal
public boolean isOrthogonal(double tolerance)
Description copied from class:AMatrixCheck to see if the matrix is orthogonal- Overrides:
isOrthogonalin classAMatrix- Parameters:
tolerance- inner product of a column with all of the next columns should be less than tolerance- Returns:
-
inverse
public AMatrix 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
-
determinant
public double determinant()
Description copied from class:AMatrixCalculates the determinant of the matrix.- Overrides:
determinantin classADiagonalMatrix
-
rank
public int rank()
Description copied from class:AMatrixCalculate the rank of a matrix. This is equivalent to the maximum number of linearly independent rows or columns.- Overrides:
rankin classADiagonalMatrix
-
nonZeroCount
public long nonZeroCount()
Description copied from interface:INDArrayReturns the number of non-zero elements in the array.- Specified by:
nonZeroCountin interfaceINDArray- Overrides:
nonZeroCountin classADiagonalMatrix
-
elementSum
public double elementSum()
Description copied from class:AMatrixReturns the sum of all elements in this matrix- Specified by:
elementSumin interfaceINDArray- Overrides:
elementSumin classADiagonalMatrix
-
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 classADiagonalMatrix
-
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 classADiagonalMatrix
-
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- Specified by:
tracein interfaceIMatrix- Overrides:
tracein classADiagonalMatrix- Returns:
-
diagonalProduct
public double diagonalProduct()
Description copied from class:AMatrixComputes the product of entries on the main diagonal of a matrix- Specified by:
diagonalProductin interfaceIMatrix- Overrides:
diagonalProductin classADiagonalMatrix- Returns:
-
innerProduct
public AMatrix innerProduct(ADiagonalMatrix a)
Description copied from class:ADiagonalMatrixComputes the inner product of this matrix with another diagonal matrix of the same shape. The result will be a diagnonal matrix of the same shape.- Overrides:
innerProductin classADiagonalMatrix- Returns:
-
innerProduct
public AMatrix innerProduct(AMatrix a)
Description copied from interface:IMatrixComputes the inner product of this matrix with another. Equivalent to matrix x matrix multiplication- Specified by:
innerProductin interfaceIMatrix- Overrides:
innerProductin classADiagonalMatrix- Returns:
-
innerProduct
public AVector innerProduct(AVector v)
Description copied from interface:INDArrayComputes the inner product of this array with a vector- Specified by:
innerProductin interfaceINDArray- Specified by:
innerProductin interfaceIMatrix- Overrides:
innerProductin classAMatrix- Parameters:
v- A vector- Returns:
- A new array representing the inner product
-
multiplyCopy
public ScalarMatrix multiplyCopy(double d)
Description copied from interface:INDArrayReturns a copy of the array with all elements multiplied by a single constant value- Specified by:
multiplyCopyin interfaceINDArray- Overrides:
multiplyCopyin classAMatrix- Parameters:
d- A scalar factor- Returns:
- A new array, with all element values scaled by the given factor
-
addCopy
public AMatrix addCopy(AMatrix m)
Description copied from interface:IMatrixAdds another matrix to this matrix, returning a new matrix- Specified by:
addCopyin interfaceIMatrix- Overrides:
addCopyin classADiagonalMatrix- Returns:
-
getTransposeView
public IdentityMatrix getTransposeView()
Description copied from interface:INDArrayReturns a transposed view of the array. May throw UnsupportedOperationException if the array type does not support this capability- Specified by:
getTransposeViewin interfaceINDArray- Specified by:
getTransposeViewin interfaceIMatrix- Overrides:
getTransposeViewin classADiagonalMatrix- Returns:
- the transpose of this matrix, as a view
-
exactClone
public IdentityMatrix 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 classADiagonalMatrix- Returns:
- A clone of the original array
-
hasUncountable
public boolean hasUncountable()
Description copied from class:AMatrixChecks to see if any element in the matrix is NaN of Infinite.- Specified by:
hasUncountablein interfaceINDArray- Overrides:
hasUncountablein classADiagonalMatrix- Returns:
- True if any element in the matrix is NaN of Infinite.
-
elementPowSum
public double elementPowSum(double p)
Returns the sum of all the elements raised to a specified power- Specified by:
elementPowSumin interfaceINDArray- Overrides:
elementPowSumin classADiagonalMatrix- Returns:
-
elementAbsPowSum
public double elementAbsPowSum(double p)
Returns the sum of the absolute values of all the elements raised to a specified power- Specified by:
elementAbsPowSumin interfaceINDArray- Overrides:
elementAbsPowSumin classADiagonalMatrix- Returns:
-
-
DMelt 3.0 © DataMelt by jWork.ORG