mikera.matrixx.impl
Class ScalarMatrix
- java.lang.Object
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, INDArray, ISparse, IMatrix, IFastBands
public class ScalarMatrix extends ADiagonalMatrix
Immutable scalar matrix class - a diagonal matrix with an identical value along the leading diagonal. When used to transform a vector, multiplies every component by a constant factor- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description ScalarMatrix(int dimensions, double scale)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static ScalarMatrixcreate(int dimensions, double scale)doublediagonalProduct()Computes the product of entries on the main diagonal of a matrixdoubleelementSum()Returns the sum of all elements in this matrixScalarMatrixexactClone()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 matrixRepeatedElementVectorgetLeadingDiagonal()Returns a vector view of the leading diagonal values of the matrixAMatrixinnerProduct(AMatrix m)Computes the inner product of this matrix with another.booleanisFullyMutable()If this method returns true, the INDArray is guaranteed to be fully mutable in all positions i.e.booleanisMutable()Returns true if the INDArray is mutable (at least partially)AMatrixmultiplyCopy(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.doubletrace()Computes the trace of a matrix, i.e.voidtransformInPlace(ADenseArrayVector v)voidtransformInPlace(AVector v)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.-
Methods inherited from class mikera.matrixx.impl.ADiagonalMatrix
addCopy, addOuterProductSparse, addToArray, checkSquare, clone, columnCount, copyColumnTo, copyRowTo, determinant, dimensions, elementAbsPowSum, elementMax, elementMin, elementPowSum, elementSquaredSum, equalsTranspose, getBand, getColumn, getDiagonalValue, getNonZeroBand, getRow, getTranspose, getTransposeView, hasUncountable, innerProduct, isBoolean, isDiagonal, isIdentity, isLowerTriangular, isRectangularDiagonal, isSameShape, isSameShape, isSquare, isSymmetric, isUpperTriangular, isZero, lowerBandwidthLimit, nonZeroBand, rank, rowCount, rowDotProduct, set, setSparse, toDoubleArray, toMatrix, toMatrixTranspose, transform, transposeInnerProduct, transposeInPlace, unsafeGetDiagonalValue, upperBandwidthLimit, validate
-
Methods inherited from class mikera.matrixx.impl.ASingleBandMatrix
isSparse, subMatrix
-
Methods inherited from class mikera.matrixx.impl.ABandedMatrix
density, fill, getRowView, 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, getColumnView, getElement, getElements, getLongShape, getRowClone, getRows, getShape, getShape, getShapeClone, getSlices, getSlices, getSliceViews, getTransposeCopy, hashCode, hasOrthonormalColumns, hasOrthonormalRows, immutable, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, inputDimensions, inverse, isElementConstrained, isHermitian, isInvertible, isOrthogonal, isOrthogonal, 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, transform, 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.arrayz.INDArray
absCopy, absDiff, absDiffCopy, addApplyOp, addAt, addInnerProduct, addMultipleSparse, addPower, addPower, addSparse, broadcastLike, componentCount, divideCopy, elementMaxAbs, elementProduct, epsilonEquals, equalsArray, get, get, get, get, getComponent, getComponents, getElements, getElements, getElements, isDense, join, multiplyCopy, negateCopy, reciprocalCopy, scale, scaleCopy, setElements, setInnerProduct, signumCopy, sliceValue, squareCopy, sub, subCopy, withComponents
-
-
-
-
Method Detail
-
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
-
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
-
isFullyMutable
public boolean isFullyMutable()
Description copied from interface:INDArrayIf this method returns true, the INDArray is guaranteed to be fully mutable in all positions i.e. every position can store any valid double value- Specified by:
isFullyMutablein interfaceINDArray- Overrides:
isFullyMutablein classADiagonalMatrix
-
innerProduct
public AMatrix innerProduct(AMatrix m)
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:
-
get
public double get(int row, int column)Description copied from interface:INDArrayReturns the double value at the specified position in a 2D matrix
-
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.
-
getLeadingDiagonal
public RepeatedElementVector getLeadingDiagonal()
Description copied from class:AMatrixReturns a vector view of the leading diagonal values of the matrix- Specified by:
getLeadingDiagonalin classADiagonalMatrix- Returns:
-
create
public static ScalarMatrix create(int dimensions, double scale)
-
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:
-
multiplyCopy
public AMatrix 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
-
transformInPlace
public void transformInPlace(AVector v)
- Specified by:
transformInPlacein interfaceIMatrix- Overrides:
transformInPlacein classADiagonalMatrix
-
transformInPlace
public void transformInPlace(ADenseArrayVector v)
- Overrides:
transformInPlacein classADiagonalMatrix
-
exactClone
public ScalarMatrix 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
-
-
DMelt 3.0 © DataMelt by jWork.ORG