mikera.matrixx.impl
Class QuadtreeMatrix
- java.lang.Object
-
- mikera.arrayz.impl.AbstractArray<AVector>
-
- mikera.matrixx.AMatrix
-
- mikera.matrixx.impl.ARectangularMatrix
-
- mikera.matrixx.impl.ABlockMatrix
-
- mikera.matrixx.impl.QuadtreeMatrix
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, INDArray, ISparse, IMatrix
public class QuadtreeMatrix extends ABlockMatrix implements ISparse
A matrix implemented as a quadtree of submatrices. Useful for large matrices with heirarchical structure where large regions are either fully sparse or of a specialised subtype (e.g. a diagonal matrix).- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(AVector v)Adds a vector to every row of this matrix.voidadd(double v)Adds a double value to all elements in this array.voidaddAt(int row, int column, double value)Adds a value at a specific position in the matrix, mutating the matrix Does not perform bounds checking - this in an unsafe operationintcolumnBlockCount()voidcopyColumnTo(int col, double[] data, int offset)Copies the elements in a selected row of this matrix to a double arrayvoidcopyRowTo(int row, double[] data, int offset)Copies the elements in a selected row of this matrix to a double arraystatic QuadtreeMatrixcreate(AMatrix c00, AMatrix c01, AMatrix c10, AMatrix c11)doubledensity()Computes the density ratio of this sparse array (proportion of non-zero elements)doubleelementMax()Returns the maximum element value in this array.doubleelementMin()Returns the maximum element value in this array.doubleelementSum()Returns the sum of all elements in this matrixAMatrixexactClone()Creates a deep clone of an array, using the same class implementation as the original arrayvoidfill(double v)Fills this array with a single double value.doubleget(int row, int column)Returns the double value at the specified position in a 2D matrixAMatrixgetBlock(int rowBlock, int colBlock)intgetBlockColumnCount(int colBlock)intgetBlockColumnStart(int colBlock)intgetBlockRowCount(int rowBlock)intgetBlockRowStart(int rowBlock)intgetColumnBlockIndex(int col)AVectorgetColumnView(int col)Returns a column of the matrix as a vector view.intgetRowBlockIndex(int row)AVectorgetRowView(int row)Returns a row of the matrix as a vector view.booleanisDiagonal()Returns true iff this matrix is a square diagonal matrixbooleanisFullyMutable()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)booleanisZero()Returns true if the matrix is the zero matrix (all components zero)longnonZeroCount()Returns the number of non-zero elements in the array.introwBlockCount()voidset(int row, int column, double value)Sets a value at a given position in a mutable 2D arraydoubleunsafeGet(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.voidunsafeSet(int row, int column, 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 QuadtreeMatrixwrap(AMatrix c00, AMatrix c01, AMatrix c10, AMatrix c11)-
Methods inherited from class mikera.matrixx.impl.ABlockMatrix
componentCount, getComponent, isBoolean
-
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, addCopy, addCopy, addCopy, addCopy, addCopy, addInnerProduct, addInnerProduct, addInnerProduct, addMultiple, addMultiple, addMultiple, addOuterProduct, addOuterProduct, addOuterProductSparse, addOuterProductSparse, addRowMultiple, addSparse, addSparse, addToArray, applyOp, applyOp, applyOp, applyOp, applyOp, applyOp, applyOpCopy, asDoubleArray, asElementList, asVector, bandIndex, bandPosition, bandStartColumn, bandStartRow, broadcast, broadcastCloneLike, broadcastCopyLike, broadcastLike, broadcastLike, clamp, clone, composeWith, copy, dense, denseClone, determinant, diagonalProduct, dimensionality, divide, divide, divide, divide, divideCopy, elementIterator, elementsEqual, elementSquaredSum, ensureMutable, epsilonEquals, epsilonEquals, epsilonEquals, equals, equals, equals, equalsArray, equalsTranspose, exp, get, get, get, get, getBand, getBandWrapped, getColumn, getColumnClone, getColumns, getElements, getLeadingDiagonal, getLongShape, getRow, getRowClone, getRows, getSlices, getSlices, getSliceViews, getTranspose, getTransposeCopy, getTransposeView, hashCode, hasOrthonormalColumns, hasOrthonormalRows, hasUncountable, immutable, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, innerProduct, inputDimensions, inverse, 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, outerProduct, outputDimensions, pow, rank, reciprocal, reduce, reduce, reduceSlices, reduceSlices, reorder, reorder, replaceColumn, replaceRow, reshape, reshape, rotateView, rowDotProduct, 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, subMatrix, swapColumns, swapRows, toAffineTransform, toDoubleArray, toDoubleBuffer, toMatrix, toMatrixTranspose, toMutableMatrix, toNestedDoubleArrays, toSliceArray, toString, toStringFull, toVector, trace, 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, divideCopy, elementAbsPowSum, elementMaxAbs, elementPowSum, elementProduct, epsilonEquals, equals, equalsArray, get, get, get, get, 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.INDArray
absCopy, absDiff, absDiffCopy, addApplyOp, addAt, addInnerProduct, addMultipleSparse, addPower, addPower, addSparse, broadcastLike, divideCopy, elementAbsPowSum, elementMaxAbs, elementPowSum, elementProduct, epsilonEquals, equalsArray, get, get, get, get, getComponents, getElements, getElements, getElements, isDense, isSparse, join, multiplyCopy, negateCopy, reciprocalCopy, scale, scaleCopy, setElements, setInnerProduct, setSparse, signumCopy, sliceValue, squareCopy, sub, subCopy, withComponents
-
-
-
-
Method Detail
-
wrap
public static QuadtreeMatrix wrap(AMatrix c00, AMatrix c01, AMatrix c10, AMatrix c11)
-
create
public static QuadtreeMatrix create(AMatrix c00, AMatrix c01, AMatrix c10, AMatrix c11)
-
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)
-
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 classABlockMatrix
-
isDiagonal
public boolean isDiagonal()
Description copied from interface:IMatrixReturns true iff this matrix is a square diagonal matrix- Specified by:
isDiagonalin interfaceIMatrix- Overrides:
isDiagonalin classAMatrix
-
get
public double get(int row, int column)Description copied from interface:INDArrayReturns the double value at the specified position in a 2D matrix
-
set
public void set(int row, int column, double value)Description copied from interface:INDArraySets a value at a given position in a mutable 2D array
-
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.
-
unsafeSet
public void unsafeSet(int row, int column, 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.
-
addAt
public void addAt(int row, int column, double value)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
-
copyRowTo
public void copyRowTo(int row, double[] data, int offset)Description copied from class:AMatrixCopies the elements in a selected row of this matrix to a double array- Overrides:
copyRowToin classABlockMatrix- Parameters:
row- The index of the selected rowdata- Destination double[] arrayoffset- Offset into destination array
-
copyColumnTo
public void copyColumnTo(int col, double[] data, int offset)Description copied from class:AMatrixCopies the elements in a selected row of this matrix to a double array- Overrides:
copyColumnToin classABlockMatrixdata- Destination double[] array
-
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
-
elementSum
public double elementSum()
Description copied from class:AMatrixReturns the sum of all elements in this matrix- Specified by:
elementSumin interfaceINDArray- Overrides:
elementSumin classAMatrix
-
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>
-
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>
-
fill
public void fill(double v)
Description copied from interface:INDArrayFills this array with a single double value. Requires the array to be mutable.
-
add
public void add(double v)
Description copied from interface:INDArrayAdds a double value to all elements in this array. Implementations may optimize the case of 0.0
-
add
public void add(AVector v)
Description copied from class:AMatrixAdds a vector to every row of this matrix.
-
getRowView
public AVector getRowView(int row)
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 classABlockMatrix
-
getColumnView
public AVector getColumnView(int col)
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 classABlockMatrix
-
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
-
density
public double density()
Description copied from interface:ISparseComputes the density ratio of this sparse array (proportion of non-zero elements)- Specified by:
densityin interfaceISparse- Overrides:
densityin classAbstractArray<AVector>- Returns:
-
getBlock
public AMatrix getBlock(int rowBlock, int colBlock)
- Specified by:
getBlockin classABlockMatrix
-
getBlockColumnStart
public int getBlockColumnStart(int colBlock)
- Specified by:
getBlockColumnStartin classABlockMatrix
-
getBlockRowStart
public int getBlockRowStart(int rowBlock)
- Specified by:
getBlockRowStartin classABlockMatrix
-
getBlockColumnCount
public int getBlockColumnCount(int colBlock)
- Specified by:
getBlockColumnCountin classABlockMatrix
-
getBlockRowCount
public int getBlockRowCount(int rowBlock)
- Specified by:
getBlockRowCountin classABlockMatrix
-
getColumnBlockIndex
public int getColumnBlockIndex(int col)
- Specified by:
getColumnBlockIndexin classABlockMatrix
-
getRowBlockIndex
public int getRowBlockIndex(int row)
- Specified by:
getRowBlockIndexin classABlockMatrix
-
columnBlockCount
public int columnBlockCount()
- Specified by:
columnBlockCountin classABlockMatrix
-
rowBlockCount
public int rowBlockCount()
- Specified by:
rowBlockCountin classABlockMatrix
-
-
DMelt 3.0 © DataMelt by jWork.ORG