mikera.matrixx.impl
Class DenseColumnMatrix
- 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.DenseColumnMatrix
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, IDense, IStridedArray, INDArray, IMatrix, IFastColumns
public final class DenseColumnMatrix extends AStridedMatrix implements IFastColumns, IDense
A densely packed matrix organised in column-major format. Transposes to/from a regular dense Matrix This class is useful if your main performance requirement is fast access to columns of a matrix. This is frequently true when the matrix is used as the *second* argument in matrix/matrix operations.- 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 voidabs()Replaces all elements of this array with their absolute values, according to Math.abs(double)voidadd(double d)Adds a double value to all elements in this array.voidaddAt(int i, int j, double d)Adds a value at a specific position in the matrix, mutating the matrix Does not perform bounds checking - this in an unsafe operationvoidaddMultiple(AMatrix m, double factor)Adds a scalar multiple of another matrix to this matrixvoidaddOuterProduct(AVector a, AVector b)Adds the outer product of two vectors to this matrixvoidapplyOp(Op op)Applies a unary operator to all elements of the array (in-place)voidclamp(double min, double max)Clamps all the elements of this array within the specified [min,max] rangeintcolumnStride()Gets the column stride for this strided matrix.DenseColumnMatrixcopy()Returns a defensive copy of the array data.voidcopyColumnTo(int j, double[] dest, int destOffset)Copies the elements in a selected row of this matrix to a double arrayvoidcopyRowTo(int i, double[] dest, int destOffset)Copies the elements in a selected row of this matrix to a double arraystatic DenseColumnMatrixcreate(AMatrix m)DenseColumnMatrixdense()Coerces this INDArray to a dense format, without changing its element values.doubleelementMax()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 matrixDenseColumnMatrixexactClone()Creates a deep clone of an array, using the same class implementation as the original arrayvoidexp()Computes the function e^x (in-place) for all array elementsvoidfill(double value)Fills this array with a single double value.doubleget(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 arrayArraySubVectorgetColumn(int j)Returns a column of the matrix.MatrixgetTranspose()Returns the transpose of this array.MatrixgetTransposeView()Returns a transposed view of the array.booleanisBoolean()Returns true if the array is boolean (contains only 0.0 or 1.0 values)booleanisFullyMutable()If this method returns true, the INDArray is guaranteed to be fully mutable in all positions i.e.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)voidlog()Computes the natural logarithm (in-place) for all array elementsvoidmultiply(double factor)Multiplies all elements of the array in place by a given double valuelongnonZeroCount()Returns the number of non-zero elements in the array.voidreciprocal()Replaces all elements in the array with their reciprocalintrowStride()Gets the row stride for this strided matrix.voidset(AMatrix m)Sets this matrix with the element values from another matrix.voidset(int i, int j, double value)Sets a value at a given position in a mutable 2D arrayvoidsetColumn(int j, AVector col)Sets a column in a matrix.voidsetRow(int i, AVector row)Sets a row in a matrix to the value specified by the given vectorvoidsignum()Calculates the signum of all elements of this mutable array Sets each component of the array to its sign value (-1, 0 or 1)voidsquare()Squares all elements of the array in placeMatrixtoMatrixTranspose()Coerces the transpose of a matrix to the standard mutable Matrix type in row major order.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.static DenseColumnMatrixwrap(int rows, int cols, double[] data)-
Methods inherited from class mikera.matrixx.impl.AStridedMatrix
add, add, addToArray, applyOpCopy, asDoubleArray, clone, diagonalProduct, elementIterator, getBand, getColumnView, getRow, getRowView, getStride, getStrides, reduce, rowDotProduct, subMatrix, 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
add, add2, addCopy, addCopy, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addOuterProduct, addOuterProductSparse, addOuterProductSparse, addRowMultiple, addSparse, addSparse, applyOp, applyOp, applyOp, applyOp, applyOp, asElementList, asVector, bandIndex, bandPosition, bandStartColumn, bandStartRow, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, composeWith, denseClone, determinant, dimensionality, divide, divide, divide, divide, divideCopy, elementsEqual, ensureMutable, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, equals, equalsArray, equalsTranspose, 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, isDiagonal, isElementConstrained, isHermitian, isIdentity, isInvertible, isLowerTriangular, isMutable, isOrthogonal, isOrthogonal, isPositiveDefinite, isRectangularDiagonal, isSymmetric, isUpperTriangular, isView, iterator, join, lowerBandwidth, lowerBandwidthLimit, mul, multiply, multiply, multiply, multiplyCopy, multiplyRow, mutable, negate, outerProduct, outputDimensions, pow, rank, reduce, reduceSlices, reduceSlices, reorder, reorder, replaceColumn, replaceRow, reshape, reshape, rotateView, scaleAdd, scaleAdd, set, set, set, set, set, set, set, setApplyOp, setApplyOp, setElements, setElements, setMultiple, setMultiple, setMultiple, setMultiple, setMultiple, setSparse, setSparse, slice, slice, sliceCount, sparse, sparseClone, sqrt, sub, sub, sub, subArray, subCopy, swapColumns, swapRows, toAffineTransform, toDoubleArray, toDoubleBuffer, toMatrix, 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, elementMaxAbs, 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.matrixx.IMatrix
add2, addCopy, addCopy, columnCount, diagonalProduct, getBand, getColumnClone, getColumns, getColumnView, getRow, getRowClone, getRows, getRowView, innerProduct, innerProduct, innerProduct, inverse, isDiagonal, isIdentity, isInvertible, isRectangularDiagonal, isSquare, isSymmetric, rowCount, subMatrix, toNestedDoubleArrays, trace, transform, transformInPlace, transposeInPlace
-
Methods inherited from interface mikera.arrayz.INDArray
absCopy, absDiff, absDiffCopy, add, addApplyOp, addAt, addCopy, addCopy, addInnerProduct, addInnerProduct, addMultiple, addMultipleSparse, addOuterProduct, addOuterProductSparse, addPower, addPower, addSparse, addSparse, addToArray, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, asVector, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, broadcastLike, clone, componentCount, denseClone, dimensionality, divide, divide, divideCopy, divideCopy, elementAbsPowSum, elementCount, elementIterator, elementMaxAbs, elementPowSum, elementProduct, elementsEqual, ensureMutable, epsilonEquals, epsilonEquals, equals, equalsArray, equalsArray, 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, isDense, isElementConstrained, isMutable, isSameShape, isSparse, isView, join, join, multiply, multiplyCopy, multiplyCopy, mutable, negate, negateCopy, outerProduct, pow, 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, signumCopy, slice, slice, sliceCount, sliceValue, sparse, sparseClone, sqrt, squareCopy, sub, sub, subArray, subCopy, toDoubleArray, toDoubleBuffer, toSliceArray, toVector, validate, withComponents
-
Methods inherited from interface mikera.arrayz.impl.IStridedArray
getArray
-
-
-
-
Method Detail
-
wrap
public static DenseColumnMatrix wrap(int rows, int cols, double[] data)
-
create
public static DenseColumnMatrix create(AMatrix m)
-
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
-
getColumn
public ArraySubVector 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 classAStridedMatrix
-
copyRowTo
public void copyRowTo(int i, 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:
i- The index of the selected rowdest- Destination double[] arraydestOffset- Offset into destination array
-
copyColumnTo
public void copyColumnTo(int j, 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
-
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
-
setColumn
public void setColumn(int j, AVector col)Description copied from class:AMatrixSets a column in a matrix.
-
addMultiple
public void addMultiple(AMatrix m, double factor)
Description copied from class:AMatrixAdds a scalar multiple of another matrix to this matrix- Overrides:
addMultiplein classAMatrix
-
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
-
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.
-
get
public double get(int i, int j)Description copied from interface:INDArrayReturns the double value at the specified position in a 2D matrix
-
set
public void set(int i, int j, double value)Description copied from interface:INDArraySets a value at a given position in a mutable 2D 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
-
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:
-
addAt
public void addAt(int i, int j, double d)Description copied from interface:IMatrixAdds a value at a specific position in the matrix, mutating the matrix Does not perform bounds checking - this in an unsafe operation
-
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
-
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:
-
isBoolean
public boolean isBoolean()
Description copied from interface:INDArrayReturns true if the array is boolean (contains only 0.0 or 1.0 values)
-
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
-
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>
-
abs
public void abs()
Description copied from interface:INDArrayReplaces all elements of this array with their absolute values, according to Math.abs(double)
-
signum
public void signum()
Description copied from interface:INDArrayCalculates the signum of all elements of this mutable array Sets each component of the array to its sign value (-1, 0 or 1)
-
square
public void square()
Description copied from interface:INDArraySquares all elements of the array in place
-
exp
public void exp()
Description copied from interface:INDArrayComputes the function e^x (in-place) for all array elements
-
log
public void log()
Description copied from interface:INDArrayComputes the natural logarithm (in-place) for all array elements
-
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
-
nonZeroCount
public long nonZeroCount()
Description copied from interface:INDArrayReturns the number of non-zero elements in the array.- Specified by:
nonZeroCountin interfaceINDArray- Overrides:
nonZeroCountin classAMatrix
-
add
public void add(double d)
Description copied from interface:INDArrayAdds a double value to all elements in this array. Implementations may optimize the case of 0.0
-
multiply
public void multiply(double factor)
Description copied from interface:INDArrayMultiplies all elements of the array in place by a given double value
-
fill
public void fill(double value)
Description copied from interface:INDArrayFills this array with a single double value. Requires the array to be mutable.
-
reciprocal
public void reciprocal()
Description copied from interface:INDArrayReplaces all elements in the array with their reciprocal- Specified by:
reciprocalin interfaceINDArray- Overrides:
reciprocalin classAMatrix
-
clamp
public void clamp(double min, double max)Description copied from interface:INDArrayClamps all the elements of this array within the specified [min,max] range
-
getTranspose
public Matrix 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 Matrix 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
-
exactClone
public DenseColumnMatrix 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
-
dense
public DenseColumnMatrix dense()
Description copied from interface:INDArrayCoerces this INDArray to a dense format, without changing its element values. May return the same INDArray if already dense. May also mutate the internal structure of the original NDArray, or create a view over parts of the original INDArray. You should take a defensive copy of the original NDArray if any of this concerns you. The returned dense array may not be fully mutable in all elements.
-
copy
public DenseColumnMatrix copy()
Description copied from interface:INDArrayReturns a defensive copy of the array data. Use this if the original array might change and you need a defensive copy. May return the same array if the original was immutable, otherwise will return a defensive copy.
-
toMatrixTranspose
public Matrix toMatrixTranspose()
Description copied from class:AMatrixCoerces the transpose of a matrix to the standard mutable Matrix type in row major order. Performs a copy if necessary.- Overrides:
toMatrixTransposein classAMatrix
-
-
DMelt 3.0 © DataMelt by jWork.ORG