mikera.matrixx.impl
Class ADenseArrayMatrix
- 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.ADenseArrayMatrix
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, IDense, IDenseArray, IStridedArray, INDArray, IMatrix, IFastRows
- Direct Known Subclasses:
- Matrix
public abstract class ADenseArrayMatrix extends AStridedMatrix implements IFastRows, IDenseArray
Abstract base class for matrices wrapping a dense (rows*cols) subset of a double[] array- 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(ADenseArrayMatrix a, ADenseArrayMatrix b)voidadd(AMatrix a)Adds another matrix to this matrix.voidadd(AVector v)Adds a vector to every row of this matrix.voidaddOuterProduct(AVector a, AVector b)Adds the outer product of two vectors to this matrixvoidaddToArray(double[] data, int offset)Adds all the elements of this array to a double array at the specified offset, in row-major orderADenseArrayVectorasVector()Returns the matrix values as a single reference Vector in the form [row0 row1 row2....]intcolumnStride()Gets the column stride for this strided matrix.voidcopyRowTo(int row, double[] dest, int destOffset)Copies the elements in a selected row of this matrix to a double arraydoubleelementMax()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 matrixbooleanequals(AMatrix a)Returns true if this matrix is exactly equal to another matrixbooleanequals(INDArray a)Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTobooleanequalsArray(double[] data, int offset)Returns true if the elements in this array exactly match the elements in the given array, in row-major orderabstract intgetArrayOffset()Gets the data array offset for the first element of this strided arrayAStridedVectorgetColumn(int i)Returns a column of the matrix.ADenseArrayVectorgetRow(int i)Returns a row of the matrix.booleanisLowerTriangular()Returns true if a matrix is lower triangular.booleanisPackedArray()Returns true if the data array is fully packed by this matrix in row-major orderbooleanisUpperTriangular()Returns true if a matrix is upper triangular An upper triangular matrix is defined as having all elements equal to 0.0 where i > jbooleanisZero()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.introwStride()Gets the row stride for this strided matrix.voidset(AMatrix m)Sets this matrix with the element values from another matrix.voidset(AVector v)Sets every row of this matrix with the element values from a vector.voidsetElements(double[] values, int offset)Sets all elements in an array using the given double valuesvoidsetElements(int pos, double[] values, int offset, int length)Sets elements in an array using the given double values.voidsetRow(int i, AVector row)Sets a row in a matrix to the value specified by the given vectorvoidtransform(AVector source, AVector dest)Transforms a source vector into a destination vector, using matrix multiplication (inner product).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.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.-
Methods inherited from class mikera.matrixx.impl.AStridedMatrix
applyOp, applyOpCopy, asDoubleArray, clone, copyColumnTo, diagonalProduct, elementIterator, getBand, getColumnView, getRowView, getStride, getStrides, getTranspose, getTransposeView, subMatrix, trace
-
Methods inherited from class mikera.matrixx.impl.AArrayMatrix
get, 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, 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, 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, ensureMutable, epsilonEquals, epsilonEquals, epsilonEquals, equals, 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, isMutable, isOrthogonal, isOrthogonal, isPositiveDefinite, isRectangularDiagonal, isSymmetric, 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, setApplyOp, setApplyOp, setColumn, 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, 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, setInnerProduct, setSparse, signumCopy, sliceValue, squareCopy, sub, sub, subCopy, withComponents
-
Methods inherited from interface mikera.matrixx.IMatrix
add2, addAt, addCopy, addCopy, columnCount, diagonalProduct, get, getBand, getColumnClone, getColumns, getColumnView, getRowClone, getRows, getRowView, getTranspose, getTransposeView, innerProduct, innerProduct, innerProduct, inverse, isDiagonal, isIdentity, isInvertible, isRectangularDiagonal, isSquare, isSymmetric, rowCount, set, subMatrix, toNestedDoubleArrays, trace, transformInPlace, 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, applyOp, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, broadcastLike, clamp, clone, componentCount, copy, dense, denseClone, dimensionality, divide, divide, divideCopy, divideCopy, elementAbsPowSum, elementCount, elementIterator, elementMaxAbs, elementPowSum, elementProduct, elementsEqual, ensureMutable, epsilonEquals, epsilonEquals, equalsArray, exactClone, 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, hasUncountable, immutable, 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, setApplyOp, 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
-
Methods inherited from interface mikera.arrayz.impl.IDenseArray
getArray
-
Methods inherited from interface mikera.arrayz.impl.IStridedArray
getArray
-
-
-
-
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 interfaceIDenseArray- Specified by:
getArrayOffsetin interfaceIStridedArray- Specified by:
getArrayOffsetin classAStridedMatrix- Returns:
-
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:
-
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 classAStridedMatrix
-
isUpperTriangular
public boolean isUpperTriangular()
Description copied from class:AMatrixReturns true if a matrix is upper triangular An upper triangular matrix is defined as having all elements equal to 0.0 where i > j- Overrides:
isUpperTriangularin classAMatrix
-
isLowerTriangular
public boolean isLowerTriangular()
Description copied from class:AMatrixReturns true if a matrix is lower triangular. A lower triangular matrix is defined as having all elements equal to 0.0 where i < j- Overrides:
isLowerTriangularin classAMatrix
-
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
-
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.- Overrides:
unsafeGetin classAArrayMatrix- Returns:
-
set
public void set(AVector v)
Description copied from class:AMatrixSets every row of this matrix with the element values from a vector.
-
set
public void set(AMatrix m)
Description copied from class:AMatrixSets this matrix with the element values from another matrix. Source matrix must have the same shape.
-
setElements
public void setElements(double[] values, int offset)Description copied from interface:INDArraySets all elements in an array using the given double values- Specified by:
setElementsin interfaceINDArray- Overrides:
setElementsin classAMatrix- Parameters:
values- Element values in a double[] array. There must be at least as many element values as elements in this array.offset- Position in the values array from which to start taking values.
-
setElements
public void setElements(int pos, double[] values, int offset, int length)Description copied from interface:INDArraySets elements in an array using the given double values. The source array must contain at least the specified length in terms of number of elements- Specified by:
setElementsin interfaceINDArray- Overrides:
setElementsin classAbstractArray<AVector>- Parameters:
pos- Offset into this array, expressed in terms of number of elements in row major ordervalues- Element values in a double[] array. There must be at least as many element values as elements in this array.offset- Position in the values array from which to start taking values.length- Number of elements to set.
-
getRow
public ADenseArrayVector 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).- Specified by:
getColumnin interfaceIMatrix- Overrides:
getColumnin classAStridedMatrix
-
setRow
public void setRow(int i, AVector row)Description copied from class:AMatrixSets a row in a matrix to the value specified by the given vector
-
elementSum
public double elementSum()
Description copied from class:AMatrixReturns the sum of all elements in this matrix- Specified by:
elementSumin interfaceINDArray- Overrides:
elementSumin classAMatrix
-
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
-
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>
-
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
-
unsafeSet
public 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
-
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.
-
add
public void add(AVector v)
Description copied from class:AMatrixAdds a vector to every row of this matrix.- Overrides:
addin classAStridedMatrix
-
add
public void add(AMatrix a)
Description copied from class:AMatrixAdds another matrix to this matrix. Matrices must be the same size.- Overrides:
addin classAStridedMatrix
-
add
public void add(ADenseArrayMatrix a, ADenseArrayMatrix b)
-
addToArray
public void addToArray(double[] data, int offset)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 classAStridedMatrix
-
addOuterProduct
public void addOuterProduct(AVector a, AVector b)
Description copied from class:AMatrixAdds the outer product of two vectors to this matrix- Overrides:
addOuterProductin 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.- Specified by:
reducein interfaceINDArray- Overrides:
reducein classAStridedMatrix
-
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 classAStridedMatrix- Returns:
-
equals
public boolean equals(AMatrix a)
Description copied from class:AMatrixReturns true if this matrix is exactly equal to another matrix
-
equals
public boolean equals(INDArray a)
Description copied from interface:INDArrayChecks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTo
-
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:
-
-
DMelt 3.0 © DataMelt by jWork.ORG