mikera.matrixx.impl
Class AStridedMatrix
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<AVector>
-
- mikera.matrixx.AMatrix
-
- mikera.matrixx.impl.ARectangularMatrix
-
- mikera.matrixx.impl.AArrayMatrix
-
- mikera.matrixx.impl.AStridedMatrix
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, IStridedArray, INDArray, IMatrix
- Direct Known Subclasses:
- ADenseArrayMatrix, BaseStridedMatrix, DenseColumnMatrix, StridedRowMatrix
public abstract class AStridedMatrix extends AArrayMatrix implements IStridedArray
Abstract base class for arbitrary strided matrices- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class mikera.matrixx.impl.AArrayMatrix
data
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidadd(AMatrix m)Adds another matrix to this matrix.voidadd(AVector v)Adds a vector to every row of this matrix.voidaddToArray(double[] dest, int destOffset)Adds all the elements of this array to a double array at the specified offset, in row-major ordervoidapplyOp(Op op)Applies a unary operator to all elements of the array (in-place)MatrixapplyOpCopy(Op op)Applies a unary operator to all elements of the array (creating a new array)double[]asDoubleArray()Returns the underlying double array representing the densely packed elements of this array.Matrixclone()Returns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original.abstract intcolumnStride()Gets the column stride for this strided matrix.abstract voidcopyColumnTo(int col, double[] dest, int destOffset)Copies the elements in a selected row of this matrix to a double arrayabstract voidcopyRowTo(int row, double[] dest, int destOffset)Copies the elements in a selected row of this matrix to a double arraydoublediagonalProduct()Computes the product of entries on the main diagonal of a matrixjava.util.Iterator<java.lang.Double>elementIterator()Returns an iterator over all elements in this array, in row-major orderabstract intgetArrayOffset()Gets the data array offset for the first element of this strided arrayAStridedVectorgetBand(int i)Gets a specific band of the matrix, as a view vector.AStridedVectorgetColumn(int i)Returns a column of the matrix.AStridedVectorgetColumnView(int i)Returns a column of the matrix as a vector view.AStridedVectorgetRow(int i)Returns a row of the matrix.AStridedVectorgetRowView(int i)Returns a row of the matrix as a vector view.intgetStride(int dimension)Gets the stide for a specific dimension in this strided array.int[]getStrides()Gets the strides for each dimension of this strided array.AStridedMatrixgetTranspose()Returns the transpose of this array.AStridedMatrixgetTransposeView()Returns a transposed view of the array.booleanisPackedArray()Returns true if the data array is fully packed by this matrix in row-major orderbooleanisZero()Returns true if the matrix is the zero matrix (all components zero)doublereduce(Op2 op, double init)Reduces over all elements of the array in row-major order.doublerowDotProduct(int i, AVector a)Returns the dot product of a specific row with a vector.abstract introwStride()Gets the row stride for this strided matrix.AStridedMatrixsubMatrix(int rowStart, int rowCount, int colStart, int colCount)Gets a rectangular submatrix view of part of a matrixdoubletrace()Computes the trace of a matrix, i.e.-
Methods inherited from class mikera.matrixx.impl.AArrayMatrix
get, getArray, getTransposeCopy, unsafeGet, unsafeSet
-
Methods inherited from class mikera.matrixx.impl.ARectangularMatrix
bandLength, checkColumn, checkRow, checkSquare, columnCount, elementCount, getElement, getShape, getShape, getShapeClone, isSameShape, isSameShape, isSameShape, isSquare, rowCount, set
-
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, asVector, 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, equals, equalsArray, equalsTranspose, exactClone, exp, fill, get, get, get, get, getBandWrapped, getColumnClone, getColumns, getElements, getLeadingDiagonal, getLongShape, getRowClone, getRows, getSlices, getSlices, getSliceViews, hashCode, hasOrthonormalColumns, hasOrthonormalRows, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, inputDimensions, inverse, isBoolean, isDiagonal, isElementConstrained, isFullyMutable, isHermitian, isIdentity, isInvertible, isLowerTriangular, isMutable, 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, setRow, 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, 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, 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, asVector, 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, equalsArray, exactClone, exp, fill, get, 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, innerProduct, isBoolean, isDense, isElementConstrained, isFullyMutable, isMutable, 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, 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
-
getArrayOffset
public abstract int getArrayOffset()
Description copied from interface:IStridedArrayGets the data array offset for the first element of this strided array- Specified by:
getArrayOffsetin interfaceIStridedArray- Returns:
-
rowStride
public abstract int rowStride()
Gets 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.
-
columnStride
public abstract int columnStride()
Gets 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.
-
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
-
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).
-
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).
-
getRowView
public AStridedVector getRowView(int i)
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 classAMatrix
-
getColumnView
public final AStridedVector getColumnView(int i)
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
-
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 classAMatrix- Returns:
-
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
-
getBand
public AStridedVector getBand(int i)
Description copied from class:AMatrixGets a specific band of the matrix, as a view vector. The band is truncated at the edges of the matrix, i.e. it does not wrap around the matrix.
-
add
public void add(AVector v)
Description copied from class:AMatrixAdds a vector to every row of this matrix.
-
addToArray
public void addToArray(double[] dest, int destOffset)Description copied from interface:INDArrayAdds all the elements of this array to a double array at the specified offset, in row-major order- Specified by:
addToArrayin interfaceINDArray- Overrides:
addToArrayin classAMatrix
-
applyOp
public void applyOp(Op op)
Description copied from interface:INDArrayApplies a unary operator to all elements of the array (in-place)
-
applyOpCopy
public final Matrix applyOpCopy(Op op)
Description copied from interface:INDArrayApplies a unary operator to all elements of the array (creating a new array)- Specified by:
applyOpCopyin interfaceINDArray- Overrides:
applyOpCopyin classAMatrix
-
reduce
public double reduce(Op2 op, double init)
Description copied from interface:INDArrayReduces over all elements of the array in row-major order. Applies the operator to the initial/previous result at each step. Returns the final result.
-
rowDotProduct
public double rowDotProduct(int i, AVector a)Description copied from class:AMatrixReturns the dot product of a specific row with a vector. Unsafe operation: performs no bounds checking- Overrides:
rowDotProductin classAMatrix- Returns:
-
add
public void add(AMatrix m)
Description copied from class:AMatrixAdds another matrix to this matrix. Matrices must be the same size.
-
copyRowTo
public abstract 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 abstract 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
-
getStrides
public int[] getStrides()
Description copied from interface:IStridedArrayGets the strides for each dimension of this strided array. The returned array should not be modified- Specified by:
getStridesin interfaceIStridedArray- Returns:
-
getStride
public int getStride(int dimension)
Description copied from interface:IStridedArrayGets the stide for a specific dimension in this strided array.- Specified by:
getStridein interfaceIStridedArray- Returns:
-
elementIterator
public java.util.Iterator<java.lang.Double> elementIterator()
Description copied from interface:INDArrayReturns an iterator over all elements in this array, in row-major order- Specified by:
elementIteratorin interfaceINDArray- Overrides:
elementIteratorin classAMatrix
-
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 classAMatrix- 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 classAMatrix- Returns:
- the transpose of this matrix, as a view
-
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- Specified by:
isPackedArrayin classAArrayMatrix- Returns:
-
asDoubleArray
public double[] asDoubleArray()
Description copied from interface:INDArrayReturns the underlying double array representing the densely packed elements of this array. Modifications to this double array will change the original array. Returns null if there is no such array.- Specified by:
asDoubleArrayin interfaceINDArray- Overrides:
asDoubleArrayin classAMatrix
-
isZero
public boolean isZero()
Description copied from class:AMatrixReturns true if the matrix is the zero matrix (all components zero)
-
clone
public final Matrix clone()
Description copied from interface:INDArrayReturns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original. Clone should attempt to return the most efficient possible array type. Clone should preserve sparsity property where possible, but this is not guaranteed.
-
-
DMelt 3.0 © DataMelt by jWork.ORG