mikera.matrixx.impl
Class StridedRowMatrix
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<AVector>
-
- mikera.matrixx.AMatrix
-
- mikera.matrixx.impl.ARectangularMatrix
-
- mikera.matrixx.impl.AArrayMatrix
-
- mikera.matrixx.impl.AStridedMatrix
-
- mikera.matrixx.impl.StridedRowMatrix
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, IStridedArray, INDArray, IMatrix
public final class StridedRowMatrix extends AStridedMatrix
A strided matrix implementation with a column stride of 1 Provides a fast, mutable subMatrix view for the dense Matrix class- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class mikera.matrixx.impl.AArrayMatrix
data
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidapplyOp(Op op)Applies a unary operator to all elements of the array (in-place)AVectorasVector()Returns the matrix values as a single reference Vector in the form [row0 row1 row2....]intcolumnStride()Gets the column stride for this strided matrix.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 arraybooleanequals(AMatrix a)Returns true if this matrix is exactly equal to another 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 i, int j)Returns the double value at the specified position in a 2D matrixintgetArrayOffset()Gets the data array offset for the first element of this strided arrayAStridedVectorgetColumn(int i)Returns a column of the matrix.voidgetElements(double[] dest, int destOffset)Copies all elements of this array a double array at the specified offsetAStridedVectorgetRow(int i)Returns a row of the matrix.AStridedMatrixgetTranspose()Returns the transpose of this array.AStridedMatrixgetTransposeView()Returns a transposed view of the array.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)booleanisPackedArray()Returns true if the data array is fully packed by this matrix in row-major orderdoublerowDotProduct(int row, AVector v)Returns the dot product of a specific row with a vector.introwStride()Gets the row stride for this strided matrix.voidset(int i, int j, double value)Sets a value at a given position in a mutable 2D arrayvoidsetRow(int row, AVector v)Sets a row in a matrix to the value specified by the given vectorAStridedMatrixsubMatrix(int rowStart, int rowCount, int colStart, int colCount)Gets a rectangular submatrix view of part of a matrixdoubleunsafeGet(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.voidunsafeSet(int i, int j, 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.voidvalidate()Validates the internal data structure of the INDArray.static StridedRowMatrixwrap(AStridedMatrix m)static StridedRowMatrixwrap(double[] data, int rows, int columns, int offset, int rowStride)-
Methods inherited from class mikera.matrixx.impl.AStridedMatrix
add, add, addToArray, applyOpCopy, asDoubleArray, clone, diagonalProduct, elementIterator, getBand, getColumnView, getRowView, getStride, getStrides, isZero, reduce, trace
-
Methods inherited from class mikera.matrixx.impl.AArrayMatrix
getArray, getTransposeCopy
-
Methods inherited from class mikera.matrixx.impl.ARectangularMatrix
bandLength, checkColumn, checkRow, checkSquare, columnCount, elementCount, getElement, getShape, getShape, getShapeClone, isSameShape, isSameShape, isSameShape, isSquare, rowCount
-
Methods inherited from class mikera.matrixx.AMatrix
abs, add, add, add2, addAt, addCopy, addCopy, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addMultiple, addOuterProduct, addOuterProduct, addOuterProductSparse, addOuterProductSparse, addRowMultiple, addSparse, addSparse, applyOp, applyOp, applyOp, applyOp, applyOp, asElementList, bandIndex, bandPosition, bandStartColumn, bandStartRow, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, clamp, composeWith, copy, dense, denseClone, determinant, dimensionality, divide, divide, divide, divide, divideCopy, elementsEqual, elementSquaredSum, elementSum, ensureMutable, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, equalsTranspose, exp, fill, get, get, get, get, getBandWrapped, getColumnClone, getColumns, getLeadingDiagonal, getLongShape, getRowClone, getRows, getSlices, getSlices, getSliceViews, hashCode, hasOrthonormalColumns, hasOrthonormalRows, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, inputDimensions, inverse, isBoolean, isDiagonal, isElementConstrained, isHermitian, isIdentity, isInvertible, isLowerTriangular, isOrthogonal, isOrthogonal, isPositiveDefinite, isRectangularDiagonal, isSymmetric, isUpperTriangular, isView, iterator, join, log, lowerBandwidth, lowerBandwidthLimit, mul, multiply, multiply, multiply, multiply, multiplyCopy, multiplyRow, mutable, negate, nonZeroCount, outerProduct, outputDimensions, pow, rank, reciprocal, 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, setSparse, setSparse, signum, slice, slice, sliceCount, sparse, sparseClone, sqrt, square, sub, sub, sub, subArray, subCopy, swapColumns, swapRows, toAffineTransform, toDoubleArray, toDoubleBuffer, toMatrix, toMatrixTranspose, toMutableMatrix, toNestedDoubleArrays, toSliceArray, toString, toStringFull, toVector, transform, transform, transformInPlace, transformInPlace, transposeInnerProduct, transposeInnerProduct, transposeInPlace, upperBandwidth, upperBandwidthLimit
-
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, elementMax, elementMaxAbs, elementMin, 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.impl.IStridedArray
getArray
-
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, applyOp, applyOp, applyOp, asElementList, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, broadcastLike, clamp, componentCount, copy, dense, denseClone, dimensionality, divide, divide, divideCopy, divideCopy, elementAbsPowSum, elementCount, elementMax, elementMaxAbs, elementMin, elementPowSum, elementProduct, elementsEqual, elementSquaredSum, elementSum, ensureMutable, epsilonEquals, epsilonEquals, equals, equalsArray, exp, fill, get, get, get, get, get, get, get, get, getComponent, getComponents, getElement, getElements, getElements, getElements, getLongShape, getShape, getShape, getShapeClone, getSlices, getSlices, getSliceViews, getTransposeCopy, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, innerProduct, isBoolean, isDense, isElementConstrained, isSameShape, isSparse, isView, join, join, log, multiply, multiply, multiplyCopy, multiplyCopy, mutable, negate, negateCopy, nonZeroCount, outerProduct, pow, reciprocal, reciprocalCopy, 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, withComponents
-
-
-
-
Method Detail
-
get
public final double get(int i, int j)Description copied from interface:INDArrayReturns the double value at the specified position in a 2D matrix
-
set
public final void set(int i, int j, double value)Description copied from interface:INDArraySets a value at a given position in a mutable 2D array
-
unsafeGet
public final 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.- Overrides:
unsafeGetin classAArrayMatrix- Returns:
-
unsafeSet
public final void unsafeSet(int i, int j, 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.- Overrides:
unsafeSetin classAArrayMatrix
-
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- Specified by:
isFullyMutablein classAMatrix
-
isMutable
public boolean isMutable()
Description copied from interface:INDArrayReturns true if the INDArray is mutable (at least partially)
-
getRow
public AStridedVector 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).- Specified by:
getRowin interfaceIMatrix- Overrides:
getRowin classAStridedMatrix
-
getColumn
public AStridedVector getColumn(int i)
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- Overrides:
getColumnin classAStridedMatrix
-
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- Specified by:
copyRowToin classAStridedMatrix- Parameters:
row- The index of the selected rowdest- Destination double[] arraydestOffset- Offset into destination 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- Specified by:
copyColumnToin classAStridedMatrixdest- Destination double[] array
-
isPackedArray
public boolean isPackedArray()
Description copied from class:AArrayMatrixReturns true if the data array is fully packed by this matrix in row-major order- Specified by:
isPackedArrayin interfaceIStridedArray- Overrides:
isPackedArrayin classAStridedMatrix- Returns:
-
subMatrix
public AStridedMatrix subMatrix(int rowStart, int rowCount, int colStart, int colCount)
Description copied from interface:IMatrixGets a rectangular submatrix view of part of a matrix- Specified by:
subMatrixin interfaceIMatrix- Overrides:
subMatrixin classAStridedMatrix
-
applyOp
public void applyOp(Op op)
Description copied from interface:INDArrayApplies a unary operator to all elements of the array (in-place)- Specified by:
applyOpin interfaceINDArray- Overrides:
applyOpin classAStridedMatrix
-
getElements
public void getElements(double[] dest, int destOffset)Description copied from interface:INDArrayCopies all elements of this array a double array at the specified offset- Specified by:
getElementsin interfaceINDArray- Overrides:
getElementsin classAMatrix
-
rowDotProduct
public double rowDotProduct(int row, 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 classAStridedMatrix- Returns:
-
setRow
public void setRow(int row, AVector v)Description copied from class:AMatrixSets a row in a matrix to the value specified by the given vector
-
getTranspose
public AStridedMatrix getTranspose()
Description copied from interface:INDArrayReturns the transpose of this array. A transpose of an array is equivalent to reversing the order of dimensions. May or may not return a view depending on the array type.- Specified by:
getTransposein interfaceINDArray- Specified by:
getTransposein interfaceIMatrix- Overrides:
getTransposein classAStridedMatrix- Returns:
- the transpose of this matrix
-
getTransposeView
public AStridedMatrix 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 classAStridedMatrix- Returns:
- the transpose of this matrix, as a view
-
asVector
public AVector asVector()
Description copied from class:AMatrixReturns the matrix values as a single reference Vector in the form [row0 row1 row2....]
-
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
-
wrap
public static StridedRowMatrix wrap(AStridedMatrix m)
-
wrap
public static StridedRowMatrix wrap(double[] data, int rows, int columns, int offset, int rowStride)
-
validate
public void validate()
Description copied from interface:INDArrayValidates the internal data structure of the INDArray. Throws an exception on failure. Failure indicates a serious bug and/or data corruption.
-
equals
public boolean equals(AMatrix a)
Description copied from class:AMatrixReturns true if this matrix is exactly equal to another matrix
-
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:
-
getArrayOffset
public int getArrayOffset()
Description copied from interface:IStridedArrayGets the data array offset for the first element of this strided array- Specified by:
getArrayOffsetin interfaceIStridedArray- Specified by:
getArrayOffsetin classAStridedMatrix- Returns:
-
rowStride
public int rowStride()
Description copied from class:AStridedMatrixGets the row stride for this strided matrix. Each row has this offset in the underlying data array vs. the previous row. May be positive, zero or negative.- Specified by:
rowStridein classAStridedMatrix
-
columnStride
public int columnStride()
Description copied from class:AStridedMatrixGets the column stride for this strided matrix. Each column has this offset in the underlying data array vs. the previous column. May be positive, zero or negative.- Specified by:
columnStridein classAStridedMatrix
-
-
DMelt 3.0 © DataMelt by jWork.ORG