Class MatrixBlock
- java.lang.Object
- 
- org.apache.sysds.runtime.matrix.data.MatrixValue
- 
- org.apache.sysds.runtime.matrix.data.MatrixBlock
 
 
- 
- All Implemented Interfaces:
- Externalizable,- Serializable,- Comparable,- org.apache.hadoop.io.Writable,- org.apache.hadoop.io.WritableComparable,- CacheBlock
 - Direct Known Subclasses:
- CompressedMatrixBlock
 
 public class MatrixBlock extends MatrixValue implements CacheBlock, Externalizable - See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classMatrixBlock.SparsityEstimate- 
Nested classes/interfaces inherited from class org.apache.sysds.runtime.matrix.data.MatrixValueMatrixValue.CellIndex
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static booleanCONVERT_MCSR_TO_CSR_ON_DEEP_SERIALIZEstatic SparseBlock.TypeDEFAULT_INPLACE_SPARSEBLOCKstatic SparseBlock.TypeDEFAULT_SPARSEBLOCKstatic intHEADER_SIZEstatic doubleMAX_SHALLOW_SERIALIZE_OVERHEADstatic doubleSPARSITY_TURN_POINTstatic intULTRA_SPARSE_BLOCK_NNZstatic doubleULTRA_SPARSITY_TURN_POINTstatic doubleULTRA_SPARSITY_TURN_POINT2
 - 
Constructor SummaryConstructors Constructor Description MatrixBlock()MatrixBlock(double val)MatrixBlock(int rl, int cl, boolean sp)MatrixBlock(int rl, int cl, boolean sp, long estnnz)MatrixBlock(int rl, int cl, double val)MatrixBlock(int rl, int cl, double[] vals)MatrixBlock(int rl, int cl, long estnnz)MatrixBlock(int rl, int cl, long nnz, SparseBlock sblock)Constructs a sparseMatrixBlockwith a given instance of aSparseBlockMatrixBlock(int rl, int cl, DenseBlock dBlock)MatrixBlock(MatrixBlock that)MatrixBlock(MatrixBlock that, boolean sp)MatrixBlock(MatrixBlock that, SparseBlock.Type stype, boolean deep)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MatrixBlockaggregateBinaryOperations(MatrixBlock m1, MatrixBlock m2, MatrixBlock ret, AggregateBinaryOperator op)MatrixBlockaggregateBinaryOperations(MatrixBlock m1, MatrixBlock m2, AggregateBinaryOperator op)MatrixBlockaggregateTernaryOperations(MatrixBlock m1, MatrixBlock m2, MatrixBlock m3, MatrixBlock ret, AggregateTernaryOperator op, boolean inCP)MatrixBlockaggregateUnaryOperations(AggregateUnaryOperator op, MatrixValue result, int blen, MatrixIndexes indexesIn)MatrixBlockaggregateUnaryOperations(AggregateUnaryOperator op, MatrixValue result, int blen, MatrixIndexes indexesIn, boolean inCP)voidallocateAndResetSparseBlock(boolean clearNNZ, SparseBlock.Type stype)MatrixBlockallocateBlock()Future<MatrixBlock>allocateBlockAsync()MatrixBlockallocateDenseBlock()booleanallocateDenseBlock(boolean clearNNZ)voidallocateDenseBlockUnsafe(int rl, int cl)This should be called only in the read and write functions for CP This function should be called before calling any setValueDenseUnsafe()booleanallocateSparseRowsBlock()booleanallocateSparseRowsBlock(boolean clearNNZ)MatrixBlockappend(MatrixBlock[] that, MatrixBlock result, boolean cbind)MatrixBlockappend(MatrixBlock that, MatrixBlock ret)MatrixBlockappend(MatrixBlock that, MatrixBlock ret, boolean cbind)voidappend(MatrixValue v2, ArrayList<IndexedMatrixValue> outlist, int blen, boolean cbind, boolean m2IsLast, int nextNCol)voidappendRow(int r, SparseRow row)voidappendRow(int r, SparseRow row, boolean deep)voidappendRowToSparse(SparseBlock dest, MatrixBlock src, int i, int rowoffset, int coloffset, boolean deep)voidappendToSparse(MatrixBlock that, int rowoffset, int coloffset)voidappendValue(int r, int c, double v)Append value is only used when values are appended at the end of each row for the sparse representation This can only be called, when the caller knows the access pattern of the blockvoidappendValuePlain(int r, int c, double v)MatrixBlockbinaryOperations(BinaryOperator op, MatrixValue thatValue)MatrixBlockbinaryOperations(BinaryOperator op, MatrixValue thatValue, MatrixValue result)MatrixBlockbinaryOperationsInPlace(BinaryOperator op, MatrixValue thatValue)MatrixBlockchainMatrixMultOperations(MatrixBlock v, MatrixBlock w, MatrixBlock out, MapMultChain.ChainType ctype)MatrixBlockchainMatrixMultOperations(MatrixBlock v, MatrixBlock w, MatrixBlock out, MapMultChain.ChainType ctype, int k)static voidcheckCMOperations(MatrixBlock mb, CMOperator op)voidcheckDimensionsForAppend(MatrixBlock[] in, boolean cbind)voidcheckNaN()Checks for existing NaN values in the matrix block.voidcheckNonZeros()Basic debugging primitive to check correctness of nnz.voidcheckSparseRows()voidcheckSparseRows(int rl, int ru)Basic debugging primitive to check sparse block column ordering.voidcleanupBlock(boolean dense, boolean sparse)Allows to cleanup all previously allocated sparserows or denseblocks.CM_COV_ObjectcmOperations(CMOperator op)CM_COV_ObjectcmOperations(CMOperator op, MatrixBlock weights)MatrixBlockcolMax()Wrapper method for reduceall-colMin of a matrix.MatrixBlockcolMin()Wrapper method for reduceall-colMin of a matrix.MatrixBlockcolSum()Wrapper method for single threaded reduceall-colSum of a matrix.voidcompactEmptyBlock()Free unnecessarily allocated empty block.intcompareTo(Object arg0)static doublecomputeIQMCorrection(double sum, double sum_wt, double q25Part, double q25Val, double q75Part, double q75Val)booleancontainsValue(double pattern)voidcopy(int rl, int ru, int cl, int cu, MatrixBlock src, boolean awareDestNZ)In-place copy of matrix src into the index range of the existing current matrix.voidcopy(MatrixValue thatValue)Copy that MatrixValue into this MatrixValue.voidcopy(MatrixValue thatValue, boolean sp)Copy that MatrixValue into this MatrixValue.MatrixBlockcopyShallow(MatrixBlock that)CM_COV_ObjectcovOperations(COVOperator op, MatrixBlock that)CM_COV_ObjectcovOperations(COVOperator op, MatrixBlock that, MatrixBlock weights)voidctableOperations(Operator op, double scalarThat, double scalarThat2, CTableMap resultMap, MatrixBlock resultBlock)D = ctable(A,v2,w) this <- A; scalar_that <- v2; scalar_that2 <- w; result <- D (i1,j1,v1) from input1 (this) (v2) from sclar_input2 (scalarThat) (w) from scalar_input3 (scalarThat2)voidctableOperations(Operator op, double scalarThat, MatrixValue that2Val, CTableMap resultMap, MatrixBlock resultBlock)D = ctable(A,v2,W) this <- A; scalarThat <- v2; that2 <- W; result <- D (i1,j1,v1) from input1 (this) (v2) from sclar_input2 (scalarThat) (i3,j3,w) from input3 (that2)voidctableOperations(Operator op, MatrixIndexes ix1, double scalarThat, boolean left, int blen, CTableMap resultMap, MatrixBlock resultBlock)Specific ctable case of ctable(seq(...),X), where X is the only matrix input.voidctableOperations(Operator op, MatrixValue thatVal, double scalarThat2, boolean ignoreZeros, CTableMap resultMap, MatrixBlock resultBlock)D = ctable(A,B,w) this <- A; that <- B; scalar_that2 <- w; result <- D (i1,j1,v1) from input1 (this) (i1,j1,v2) from input2 (that) (w) from scalar_input3 (scalarThat2) NOTE: This method supports both vectors and matrices.voidctableOperations(Operator op, MatrixValue thatVal, MatrixValue that2Val, CTableMap resultMap)D = ctable(A,B,W) this <- A; that <- B; that2 <- W; result <- D (i1,j1,v1) from input1 (this) (i1,j1,v2) from input2 (that) (i1,j1,w) from input3 (that2)voidctableOperations(Operator op, MatrixValue thatVal, MatrixValue that2Val, CTableMap resultMap, MatrixBlock resultBlock)MatrixBlockctableSeqOperations(MatrixValue thatMatrix, double thatScalar, MatrixBlock resultBlock)D = ctable(seq,A,w) this <- seq; thatMatrix <- A; thatScalar <- w; result <- D (i1,j1,v1) from input1 (this) (i1,j1,v2) from input2 (that) (w) from scalar_input3 (scalarThat2)MatrixBlockctableSeqOperations(MatrixValue thatMatrix, double thatScalar, MatrixBlock ret, boolean updateClen)voiddenseToSparse(boolean allowCSR)voiddropLastRowsOrColumns(Types.CorrectionLocationType correctionLocation)booleanequals(Object arg0)longestimateSizeDenseInMemory()static longestimateSizeDenseInMemory(long nrows, long ncols)longestimateSizeInMemory()static longestimateSizeInMemory(long nrows, long ncols, double sparsity)longestimateSizeOnDisk()static longestimateSizeOnDisk(long nrows, long ncols, long nnz)longestimateSizeSparseInMemory()static longestimateSizeSparseInMemory(long nrows, long ncols, double sparsity)static longestimateSizeSparseInMemory(long nrows, long ncols, double sparsity, boolean allowCSR)static longestimateSizeSparseInMemory(long nrows, long ncols, double sparsity, SparseBlock.Type stype)longestimateSizeSparseInMemory(SparseBlock.Type stype)booleanevalSparseFormatInMemory()Evaluates if this matrix block should be in sparse format in memory.booleanevalSparseFormatInMemory(boolean allowCSR)static booleanevalSparseFormatInMemory(long nrows, long ncols, long nnz)Evaluates if a matrix block with the given characteristics should be in sparse format in memory.static booleanevalSparseFormatInMemory(long nrows, long ncols, long nnz, boolean allowCSR)static booleanevalSparseFormatInMemory(DataCharacteristics dc)booleanevalSparseFormatOnDisk()Evaluates if this matrix block should be in sparse format on disk.static booleanevalSparseFormatOnDisk(long nrows, long ncols, long nnz)Evaluates if a matrix block with the given characteristics should be in sparse format on disk (or in any other serialized representation).voidexamSparsity()Evaluates if this matrix block should be in sparse format in memory.voidexamSparsity(boolean allowCSR)Evaluates if this matrix block should be in sparse format in memory.MatrixBlockextractTriangular(MatrixBlock ret, boolean lower, boolean diag, boolean values)DataCharacteristicsgetDataCharacteristics()DenseBlockgetDenseBlock()double[]getDenseBlockValues()doublegetDouble(int r, int c)Returns the double value at the passed row and column.doublegetDoubleNaN(int r, int c)Returns the double value at the passed row and column.longgetExactSerializedSize()Get the exact serialized size in bytes of the cache block.longgetExactSizeOnDisk()NOTE: The used estimates must be kept consistent with the respective write functions.static longgetHeaderSize()longgetInMemorySize()Get the in-memory size in bytes of the cache block.longgetLength()longgetNonZeros()intgetNumColumns()intgetNumRows()SparseBlockgetSparseBlock()Iterator<IJV>getSparseBlockIterator()Iterator<IJV>getSparseBlockIterator(int rl, int ru)doublegetSparsity()StringgetString(int r, int c)Returns the string of the value at the passed row and column.doublegetValue(int r, int c)doublegetValueDenseUnsafe(int r, int c)MatrixBlockgroupedAggOperations(MatrixValue tgt, MatrixValue wghts, MatrixValue ret, int ngroups, Operator op)Invocation from CP instructions.MatrixBlockgroupedAggOperations(MatrixValue tgt, MatrixValue wghts, MatrixValue ret, int ngroups, Operator op, int k)inthashCode()voidincrementalAggregate(AggregateOperator aggOp, MatrixValue newWithCorrection)voidincrementalAggregate(AggregateOperator aggOp, MatrixValue correction, MatrixValue newWithCorrection, boolean deep)voidinit(double[][] arr, int r, int c)NOTE: This method is designed only for dense representation.voidinit(double[] arr, int r, int c)NOTE: This method is designed only for dense representation.doubleinterQuartileMean()booleanisAllocated()booleanisEmpty()booleanisEmptyBlock()booleanisEmptyBlock(boolean safe)booleanisInSparseFormat()Returns the current representation (true for sparse).booleanisShallowSerialize()Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.booleanisShallowSerialize(boolean inclConvert)Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.booleanisSparsePermutationMatrix()booleanisThreadSafe()Indicates if concurrent modifications of disjoint rows are thread-safe.static booleanisThreadSafe(boolean sparse)Indicates if concurrent modifications of disjoint rows are thread-safe.booleanisUltraSparse()booleanisUltraSparse(boolean checkNnz)booleanisVector()MatrixBlockleftIndexingOperations(ScalarObject scalar, int rl, int cl, MatrixBlock ret, MatrixObject.UpdateType update)Explicitly allow left indexing for scalars.MatrixBlockleftIndexingOperations(MatrixBlock rhsMatrix, int rl, int ru, int cl, int cu, MatrixBlock ret, MatrixObject.UpdateType update)MatrixBlockleftIndexingOperations(MatrixBlock rhsMatrix, IndexRange ixrange, MatrixBlock ret, MatrixObject.UpdateType update)doublemax()Wrapper method for reduceall-max of a matrix.doublemean()Wrapper method for reduceall-mean of a matrix.doublemedian()voidmerge(CacheBlock that, boolean appendOnly)Merge the given block into the current block.voidmerge(MatrixBlock that, boolean appendOnly)Merge disjoint: merges all non-zero values of the given input into the current matrix block.voidmerge(MatrixBlock that, boolean appendOnly, boolean par)voidmerge(MatrixBlock that, boolean appendOnly, boolean par, boolean deep)doublemin()Wrapper method for reduceall-min of a matrix.doubleminNonZero()Utility function for computing the min non-zero value.static MatrixBlocknaryOperations(Operator op, MatrixBlock[] matrices, ScalarObject[] scalars, MatrixBlock ret)voidpermutationMatrixMultOperations(MatrixValue m2Val, MatrixValue out1Val, MatrixValue out2Val)voidpermutationMatrixMultOperations(MatrixValue m2Val, MatrixValue out1Val, MatrixValue out2Val, int k)doublepickValue(double quantile)doublepickValue(double quantile, boolean average)MatrixBlockpickValues(MatrixValue quantiles, MatrixValue ret)MatrixBlockprepareAggregateUnaryOutput(AggregateUnaryOperator op, MatrixValue result, int blen)doubleprod()Wrapper method for reduceall-product of a matrix.voidputInto(MatrixBlock target, int rowOffset, int colOffset, boolean sparseCopyShallow)Method for copying this matrix into a target matrix.MatrixBlockquaternaryOperations(QuaternaryOperator qop, MatrixBlock um, MatrixBlock vm, MatrixBlock wm, MatrixBlock out)MatrixBlockquaternaryOperations(QuaternaryOperator qop, MatrixBlock U, MatrixBlock V, MatrixBlock wm, MatrixBlock out, int k)doublequickGetValue(int r, int c)doublequickGetValueThreadSafe(int r, int c)voidquickSetValue(int r, int c, double v)static MatrixBlockrandOperations(int rows, int cols, double sparsity, double min, double max, String pdf, long seed)Function to generate the random matrix with specified dimensions (block sizes are not specified).static MatrixBlockrandOperations(int rows, int cols, double sparsity, double min, double max, String pdf, long seed, int k)Function to generate the random matrix with specified dimensions (block sizes are not specified).static MatrixBlockrandOperations(RandomMatrixGenerator rgen, long seed)Function to generate the random matrix with specified dimensions and block dimensions.static MatrixBlockrandOperations(RandomMatrixGenerator rgen, long seed, int k)Function to generate the random matrix with specified dimensions and block dimensions.MatrixBlockrandOperationsInPlace(RandomMatrixGenerator rgen, org.apache.commons.math3.random.Well1024a bigrand, long bSeed)Function to generate a matrix of random numbers.MatrixBlockrandOperationsInPlace(RandomMatrixGenerator rgen, org.apache.commons.math3.random.Well1024a bigrand, long bSeed, int k)Function to generate a matrix of random numbers.voidreadExternal(ObjectInput is)Redirects the default java serialization via externalizable to our default hadoop writable serialization for efficient broadcast/rdd deserialization.voidreadFields(DataInput in)longrecomputeNonZeros()Recomputes and materializes the number of non-zero values of the entire matrix block.longrecomputeNonZeros(int rl, int ru)longrecomputeNonZeros(int rl, int ru, int cl, int cu)Recomputes the number of non-zero values of a specified range of the matrix block.MatrixBlockremoveEmptyOperations(MatrixBlock ret, boolean rows, boolean emptyReturn)MatrixBlockremoveEmptyOperations(MatrixBlock ret, boolean rows, boolean emptyReturn, MatrixBlock select)MatrixBlockreorgOperations(ReorgOperator op, MatrixValue ret, int startRow, int startColumn, int length)MatrixBlockreplaceOperations(MatrixValue result, double pattern, double replacement)voidreset()voidreset(int rl, int cl)voidreset(int rl, int cl, boolean sp)voidreset(int rl, int cl, boolean sp, long estnnz)voidreset(int rl, int cl, boolean sp, long estnnz, double val)Internal canonical reset of dense and sparse matrix blocks.voidreset(int rl, int cl, double val)voidreset(int rl, int cl, long estnnz)MatrixBlockrexpandOperations(MatrixBlock ret, double max, boolean rows, boolean cast, boolean ignore, int k)MatrixBlockrowSum()Wrapper method for single threaded reduceall-rowSum of a matrix.MatrixBlockrowSum(int k)Wrapper method for multi threaded reduceall-rowSum of a matrix.static MatrixBlocksampleOperations(long range, int size, boolean replace, long seed)MatrixBlockscalarOperations(ScalarOperator op, MatrixValue result)static MatrixBlockseqOperations(double from, double to, double incr)Method to generate a sequence according to the given parameters.MatrixBlockseqOperationsInPlace(double from, double to, double incr)longsetAllNonZeros()voidsetDenseBlock(DenseBlock dblock)longsetNonZeros(long nnz)voidsetNumColumns(int c)voidsetNumRows(int r)NOTE: setNumRows() and setNumColumns() are used only in ternaryInstruction (for contingency tables) and pmm for meta corrections.voidsetSparseBlock(SparseBlock sblock)voidsetValue(int r, int c, double v)MatrixBlockslice(int rl, int ru)Slice out a row blockMatrixBlockslice(int rl, int ru, boolean deep)MatrixBlockslice(int rl, int ru, int cl, int cu)MatrixBlockslice(int rl, int ru, int cl, int cu, boolean deep)Slice out a row blockMatrixBlockslice(int rl, int ru, int cl, int cu, boolean deep, CacheBlock ret)Method to perform rightIndex operation for a given lower and upper bounds in row and column dimensions.MatrixBlockslice(int rl, int ru, int cl, int cu, CacheBlock ret)Slice a sub block out of the current block and write into the given output block.voidslice(ArrayList<IndexedMatrixValue> outlist, IndexRange range, int rowCut, int colCut, int blen, int boundaryRlen, int boundaryClen)Slice out up to 4 matrixBlocks that are separated by the row and col Cuts.MatrixBlockslice(IndexRange ixrange, MatrixBlock ret)MatrixBlocksortOperations()MatrixBlocksortOperations(MatrixValue weights)MatrixBlocksortOperations(MatrixValue weights, MatrixBlock result)MatrixBlocksortOperations(MatrixValue weights, MatrixBlock result, int k)voidsortSparseRows()Sorts all existing sparse rows by column indexes.voidsortSparseRows(int rl, int ru)Sorts all existing sparse rows in range [rl,ru) by column indexes.voidsparseToDense()doublesum()Wrapper method for reduceall-sum of a matrix.doublesumSq()Wrapper method for reduceall-sumSq of a matrix.doublesumWeightForQuantile()In a given two column matrix, the second column denotes weights.MatrixBlockternaryOperations(TernaryOperator op, MatrixBlock m2, MatrixBlock m3, MatrixBlock ret)voidtoShallowSerializeBlock()Converts a cache block that is not shallow serializable into a form that is shallow serializable.StringtoString()MatrixBlocktransposeSelfMatrixMultOperations(MatrixBlock out, MMTSJ.MMTSJType tstype)MatrixBlocktransposeSelfMatrixMultOperations(MatrixBlock out, MMTSJ.MMTSJType tstype, int k)MatrixBlockuaggouterchainOperations(MatrixBlock mbLeft, MatrixBlock mbRight, MatrixBlock mbOut, BinaryOperator bOp, AggregateUnaryOperator uaggOp)MatrixBlockunaryOperations(UnaryOperator op, MatrixValue result)voidwrite(DataOutput out)voidwriteExternal(ObjectOutput os)Redirects the default java serialization via externalizable to our default hadoop writable serialization for efficient broadcast/rdd serialization.MatrixBlockzeroOutOperations(MatrixValue result, IndexRange range, boolean complementary)
 
- 
- 
- 
Field Detail- 
SPARSITY_TURN_POINTpublic static final double SPARSITY_TURN_POINT - See Also:
- Constant Field Values
 
 - 
ULTRA_SPARSITY_TURN_POINTpublic static final double ULTRA_SPARSITY_TURN_POINT - See Also:
- Constant Field Values
 
 - 
ULTRA_SPARSITY_TURN_POINT2public static final double ULTRA_SPARSITY_TURN_POINT2 - See Also:
- Constant Field Values
 
 - 
ULTRA_SPARSE_BLOCK_NNZpublic static final int ULTRA_SPARSE_BLOCK_NNZ - See Also:
- Constant Field Values
 
 - 
DEFAULT_SPARSEBLOCKpublic static final SparseBlock.Type DEFAULT_SPARSEBLOCK 
 - 
DEFAULT_INPLACE_SPARSEBLOCKpublic static final SparseBlock.Type DEFAULT_INPLACE_SPARSEBLOCK 
 - 
MAX_SHALLOW_SERIALIZE_OVERHEADpublic static final double MAX_SHALLOW_SERIALIZE_OVERHEAD - See Also:
- Constant Field Values
 
 - 
CONVERT_MCSR_TO_CSR_ON_DEEP_SERIALIZEpublic static final boolean CONVERT_MCSR_TO_CSR_ON_DEEP_SERIALIZE - See Also:
- Constant Field Values
 
 - 
HEADER_SIZEpublic static final int HEADER_SIZE - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
MatrixBlockpublic MatrixBlock() 
 - 
MatrixBlockpublic MatrixBlock(int rl, int cl, boolean sp)
 - 
MatrixBlockpublic MatrixBlock(int rl, int cl, long estnnz)
 - 
MatrixBlockpublic MatrixBlock(int rl, int cl, boolean sp, long estnnz)
 - 
MatrixBlockpublic MatrixBlock(MatrixBlock that) 
 - 
MatrixBlockpublic MatrixBlock(MatrixBlock that, boolean sp) 
 - 
MatrixBlockpublic MatrixBlock(double val) 
 - 
MatrixBlockpublic MatrixBlock(int rl, int cl, double val)
 - 
MatrixBlockpublic MatrixBlock(int rl, int cl, long nnz, SparseBlock sblock)Constructs a sparseMatrixBlockwith a given instance of aSparseBlock- Parameters:
- rl- number of rows
- cl- number of columns
- nnz- number of non zeroes
- sblock- sparse block
 
 - 
MatrixBlockpublic MatrixBlock(MatrixBlock that, SparseBlock.Type stype, boolean deep) 
 - 
MatrixBlockpublic MatrixBlock(int rl, int cl, DenseBlock dBlock)
 - 
MatrixBlockpublic MatrixBlock(int rl, int cl, double[] vals)
 
- 
 - 
Method Detail- 
resetpublic final void reset() - Specified by:
- resetin class- MatrixValue
 
 - 
resetpublic final void reset(int rl, int cl)- Specified by:
- resetin class- MatrixValue
 
 - 
resetpublic final void reset(int rl, int cl, long estnnz)
 - 
resetpublic final void reset(int rl, int cl, boolean sp)- Specified by:
- resetin class- MatrixValue
 
 - 
resetpublic final void reset(int rl, int cl, boolean sp, long estnnz)- Specified by:
- resetin class- MatrixValue
 
 - 
resetpublic final void reset(int rl, int cl, double val)- Specified by:
- resetin class- MatrixValue
 
 - 
resetpublic void reset(int rl, int cl, boolean sp, long estnnz, double val)Internal canonical reset of dense and sparse matrix blocks.- Parameters:
- rl- number of rows
- cl- number of columns
- sp- sparse representation
- estnnz- estimated number of non-zeros
- val- initialization value
 
 - 
initpublic void init(double[][] arr, int r, int c)NOTE: This method is designed only for dense representation.- Parameters:
- arr- 2d double array matrix
- r- number of rows
- c- number of columns
 
 - 
initpublic void init(double[] arr, int r, int c)NOTE: This method is designed only for dense representation.- Parameters:
- arr- double array matrix
- r- number of rows
- c- number of columns
 
 - 
isAllocatedpublic boolean isAllocated() 
 - 
allocateDenseBlockpublic final MatrixBlock allocateDenseBlock() 
 - 
allocateBlockAsyncpublic Future<MatrixBlock> allocateBlockAsync() 
 - 
allocateBlockpublic final MatrixBlock allocateBlock() 
 - 
allocateDenseBlockpublic boolean allocateDenseBlock(boolean clearNNZ) 
 - 
allocateSparseRowsBlockpublic final boolean allocateSparseRowsBlock() 
 - 
allocateSparseRowsBlockpublic boolean allocateSparseRowsBlock(boolean clearNNZ) 
 - 
allocateAndResetSparseBlockpublic void allocateAndResetSparseBlock(boolean clearNNZ, SparseBlock.Type stype)
 - 
allocateDenseBlockUnsafepublic final void allocateDenseBlockUnsafe(int rl, int cl)This should be called only in the read and write functions for CP This function should be called before calling any setValueDenseUnsafe()- Parameters:
- rl- number of rows
- cl- number of columns
 
 - 
cleanupBlockpublic final void cleanupBlock(boolean dense, boolean sparse)Allows to cleanup all previously allocated sparserows or denseblocks. This is for example required in reading a matrix with many empty blocks via distributed cache into in-memory list of blocks - not cleaning blocks from non-empty blocks would significantly increase the total memory consumption.- Parameters:
- dense- if true, set dense block to null
- sparse- if true, set sparse block to null
 
 - 
getNumRowspublic final int getNumRows() - Specified by:
- getNumRowsin interface- CacheBlock
- Specified by:
- getNumRowsin class- MatrixValue
 
 - 
setNumRowspublic final void setNumRows(int r) NOTE: setNumRows() and setNumColumns() are used only in ternaryInstruction (for contingency tables) and pmm for meta corrections.- Parameters:
- r- number of rows
 
 - 
getNumColumnspublic final int getNumColumns() - Specified by:
- getNumColumnsin interface- CacheBlock
- Specified by:
- getNumColumnsin class- MatrixValue
 
 - 
setNumColumnspublic final void setNumColumns(int c) 
 - 
getNonZerospublic final long getNonZeros() - Specified by:
- getNonZerosin class- MatrixValue
 
 - 
setNonZerospublic final long setNonZeros(long nnz) 
 - 
setAllNonZerospublic final long setAllNonZeros() 
 - 
getSparsitypublic final double getSparsity() 
 - 
getDataCharacteristicspublic final DataCharacteristics getDataCharacteristics() - Specified by:
- getDataCharacteristicsin interface- CacheBlock
 
 - 
isVectorpublic final boolean isVector() 
 - 
getLengthpublic final long getLength() 
 - 
isEmptypublic final boolean isEmpty() - Specified by:
- isEmptyin class- MatrixValue
 
 - 
isEmptyBlockpublic final boolean isEmptyBlock() 
 - 
isEmptyBlockpublic boolean isEmptyBlock(boolean safe) 
 - 
getDenseBlockpublic DenseBlock getDenseBlock() 
 - 
setDenseBlockpublic void setDenseBlock(DenseBlock dblock) 
 - 
getDenseBlockValuespublic double[] getDenseBlockValues() 
 - 
getSparseBlockpublic SparseBlock getSparseBlock() 
 - 
setSparseBlockpublic void setSparseBlock(SparseBlock sblock) 
 - 
getValuepublic double getValue(int r, int c)- Specified by:
- getValuein class- MatrixValue
 
 - 
setValuepublic void setValue(int r, int c, double v)- Specified by:
- setValuein class- MatrixValue
 
 - 
quickGetValuepublic double quickGetValue(int r, int c)
 - 
quickSetValuepublic void quickSetValue(int r, int c, double v)
 - 
quickGetValueThreadSafepublic double quickGetValueThreadSafe(int r, int c)
 - 
getValueDenseUnsafepublic double getValueDenseUnsafe(int r, int c)
 - 
containsValuepublic boolean containsValue(double pattern) 
 - 
appendValuepublic void appendValue(int r, int c, double v)Append value is only used when values are appended at the end of each row for the sparse representation This can only be called, when the caller knows the access pattern of the block- Parameters:
- r- row
- c- column
- v- value
 
 - 
appendValuePlainpublic void appendValuePlain(int r, int c, double v)
 - 
appendRowpublic void appendRow(int r, SparseRow row)
 - 
appendRowpublic void appendRow(int r, SparseRow row, boolean deep)
 - 
appendToSparsepublic void appendToSparse(MatrixBlock that, int rowoffset, int coloffset) 
 - 
appendRowToSparsepublic void appendRowToSparse(SparseBlock dest, MatrixBlock src, int i, int rowoffset, int coloffset, boolean deep) 
 - 
sortSparseRowspublic void sortSparseRows() Sorts all existing sparse rows by column indexes.
 - 
sortSparseRowspublic void sortSparseRows(int rl, int ru)Sorts all existing sparse rows in range [rl,ru) by column indexes.- Parameters:
- rl- row lower bound, inclusive
- ru- row upper bound, exclusive
 
 - 
minNonZeropublic double minNonZero() Utility function for computing the min non-zero value.- Returns:
- minimum non-zero value
 
 - 
prodpublic double prod() Wrapper method for reduceall-product of a matrix.- Returns:
- the product sum of the matrix content
 
 - 
meanpublic double mean() Wrapper method for reduceall-mean of a matrix.- Returns:
- the mean value of all values in the matrix
 
 - 
minpublic double min() Wrapper method for reduceall-min of a matrix.- Returns:
- the minimum value of all values in the matrix
 
 - 
colMinpublic MatrixBlock colMin() Wrapper method for reduceall-colMin of a matrix.- Returns:
- A new MatrixBlock containing the column mins of this matrix
 
 - 
colMaxpublic MatrixBlock colMax() Wrapper method for reduceall-colMin of a matrix.- Returns:
- A new MatrixBlock containing the column mins of this matrix
 
 - 
maxpublic double max() Wrapper method for reduceall-max of a matrix.- Returns:
- the maximum value of all values in the matrix
 
 - 
sumpublic double sum() Wrapper method for reduceall-sum of a matrix.- Returns:
- Sum of the values in the matrix.
 
 - 
colSumpublic MatrixBlock colSum() Wrapper method for single threaded reduceall-colSum of a matrix.- Returns:
- A new MatrixBlock containing the column sums of this matrix.
 
 - 
rowSumpublic final MatrixBlock rowSum() Wrapper method for single threaded reduceall-rowSum of a matrix.- Returns:
- A new MatrixBlock containing the row sums of this matrix.
 
 - 
rowSumpublic final MatrixBlock rowSum(int k) Wrapper method for multi threaded reduceall-rowSum of a matrix.- Parameters:
- k- the number of threads allowed to be used.
- Returns:
- A new MatrixBlock containing the row sums of this matrix.
 
 - 
sumSqpublic double sumSq() Wrapper method for reduceall-sumSq of a matrix.- Returns:
- Sum of the squared values in the matrix.
 
 - 
isInSparseFormatpublic boolean isInSparseFormat() Returns the current representation (true for sparse).- Specified by:
- isInSparseFormatin class- MatrixValue
- Returns:
- true if sparse
 
 - 
isUltraSparsepublic boolean isUltraSparse() 
 - 
isUltraSparsepublic boolean isUltraSparse(boolean checkNnz) 
 - 
isSparsePermutationMatrixpublic boolean isSparsePermutationMatrix() 
 - 
evalSparseFormatInMemorypublic boolean evalSparseFormatInMemory() Evaluates if this matrix block should be in sparse format in memory. Note that this call does not change the representation - for this please call examSparsity.- Returns:
- true if matrix block should be in sparse format in memory
 
 - 
evalSparseFormatInMemorypublic boolean evalSparseFormatInMemory(boolean allowCSR) 
 - 
evalSparseFormatOnDiskpublic boolean evalSparseFormatOnDisk() Evaluates if this matrix block should be in sparse format on disk. This applies to any serialized matrix representation, i.e., when writing to in-memory buffer pool pages or writing to local fs or hdfs.- Returns:
- true if matrix block should be in sparse format on disk
 
 - 
examSparsitypublic void examSparsity() Evaluates if this matrix block should be in sparse format in memory. Depending on the current representation, the state of the matrix block is changed to the right representation if necessary. Note that this consumes for the time of execution memory for both representations. Allowing CSR format is default for this operation.
 - 
examSparsitypublic void examSparsity(boolean allowCSR) Evaluates if this matrix block should be in sparse format in memory. Depending on the current representation, the state of the matrix block is changed to the right representation if necessary. Note that this consumes for the time of execution memory for both representations.- Parameters:
- allowCSR- allow CSR format on dense to sparse conversion
 
 - 
evalSparseFormatInMemorypublic static boolean evalSparseFormatInMemory(DataCharacteristics dc) 
 - 
evalSparseFormatInMemorypublic static boolean evalSparseFormatInMemory(long nrows, long ncols, long nnz)Evaluates if a matrix block with the given characteristics should be in sparse format in memory.- Parameters:
- nrows- number of rows
- ncols- number of columns
- nnz- number of non-zeros
- Returns:
- true if matrix block shold be in sparse format in memory
 
 - 
evalSparseFormatInMemorypublic static boolean evalSparseFormatInMemory(long nrows, long ncols, long nnz, boolean allowCSR)
 - 
evalSparseFormatOnDiskpublic static boolean evalSparseFormatOnDisk(long nrows, long ncols, long nnz)Evaluates if a matrix block with the given characteristics should be in sparse format on disk (or in any other serialized representation).- Parameters:
- nrows- number of rows
- ncols- number of columns
- nnz- number of non-zeros
- Returns:
- true if matrix block shold be in sparse format on disk
 
 - 
denseToSparsepublic void denseToSparse(boolean allowCSR) 
 - 
sparseToDensepublic void sparseToDense() 
 - 
recomputeNonZerospublic long recomputeNonZeros() Recomputes and materializes the number of non-zero values of the entire matrix block.- Returns:
- number of non-zeros
 
 - 
recomputeNonZerospublic long recomputeNonZeros(int rl, int ru)
 - 
recomputeNonZerospublic long recomputeNonZeros(int rl, int ru, int cl, int cu)Recomputes the number of non-zero values of a specified range of the matrix block. NOTE: This call does not materialize the compute result in any form.- Parameters:
- rl- row lower index, 0-based, inclusive
- ru- row upper index, 0-based, inclusive
- cl- column lower index, 0-based, inclusive
- cu- column upper index, 0-based, inclusive
- Returns:
- the number of non-zero values
 
 - 
checkNonZerospublic void checkNonZeros() Basic debugging primitive to check correctness of nnz. This method is not intended for production use.
 - 
checkSparseRowspublic void checkSparseRows() 
 - 
checkSparseRowspublic void checkSparseRows(int rl, int ru)Basic debugging primitive to check sparse block column ordering. This method is not intended for production use.- Parameters:
- rl- row lower bound (inclusive)
- ru- row upper bound (exclusive)
 
 - 
copypublic void copy(MatrixValue thatValue) Description copied from class:MatrixValueCopy that MatrixValue into this MatrixValue. If the MatrixValue is a MatrixBlock evaluate the sparsity of the original matrix, and copy into either a sparse or a dense matrix.- Specified by:
- copyin class- MatrixValue
- Parameters:
- thatValue- object to copy the values into.
 
 - 
copypublic void copy(MatrixValue thatValue, boolean sp) Description copied from class:MatrixValueCopy that MatrixValue into this MatrixValue. But select sparse destination block depending on boolean parameter.- Specified by:
- copyin class- MatrixValue
- Parameters:
- thatValue- object to copy the values into.
- sp- boolean specifying if output should be forced sparse or dense. (only applicable if the 'that' is a MatrixBlock)
 
 - 
copyShallowpublic MatrixBlock copyShallow(MatrixBlock that) 
 - 
putIntopublic void putInto(MatrixBlock target, int rowOffset, int colOffset, boolean sparseCopyShallow) Method for copying this matrix into a target matrix. Note that this method does not maintain number of non zero values. The method should output into the allocated block type of the target, therefore before any calls an appropriate block must be allocated. CSR sparse format is not supported. If allocating into a sparse matrix MCSR block the rows have to be sorted afterwards with a call to target.sortSparseRows()- Parameters:
- target- Target MatrixBlock, that can be allocated dense or sparse
- rowOffset- The Row offset to allocate into.
- colOffset- The column offset to allocate into.
- sparseCopyShallow- If the output is sparse, and shallow copy of rows is allowed from this block
 
 - 
copypublic void copy(int rl, int ru, int cl, int cu, MatrixBlock src, boolean awareDestNZ)In-place copy of matrix src into the index range of the existing current matrix. Note that removal of existing nnz in the index range and nnz maintenance is only done if 'awareDestNZ=true',- Parameters:
- rl- row lower index, 0-based
- ru- row upper index, 0-based, inclusive
- cl- column lower index, 0-based
- cu- column upper index, 0-based, inclusive
- src- matrix block
- awareDestNZ- true, forces (1) to remove existing non-zeros in the index range of the destination if not present in src and (2) to internally maintain nnz false, assume empty index range in destination and do not maintain nnz (the invoker is responsible to recompute nnz after all copies are done)
 
 - 
mergepublic void merge(CacheBlock that, boolean appendOnly) Description copied from interface:CacheBlockMerge the given block into the current block. Both blocks needs to be of equal dimensions and contain disjoint non-zero cells.- Specified by:
- mergein interface- CacheBlock
- Parameters:
- that- cache block
- appendOnly- ?
 
 - 
mergepublic void merge(MatrixBlock that, boolean appendOnly) Merge disjoint: merges all non-zero values of the given input into the current matrix block. Note that this method does NOT check for overlapping entries; it's the callers reponsibility of ensuring disjoint matrix blocks. The appendOnly parameter is only relevant for sparse target blocks; if true, we only append values and do not sort sparse rows for each call; this is useful whenever we merge iterators of matrix blocks into one target block.- Parameters:
- that- matrix block
- appendOnly- ?
 
 - 
mergepublic void merge(MatrixBlock that, boolean appendOnly, boolean par) 
 - 
mergepublic void merge(MatrixBlock that, boolean appendOnly, boolean par, boolean deep) 
 - 
readFieldspublic void readFields(DataInput in) throws IOException - Specified by:
- readFieldsin interface- org.apache.hadoop.io.Writable
- Throws:
- IOException
 
 - 
writepublic void write(DataOutput out) throws IOException - Specified by:
- writein interface- org.apache.hadoop.io.Writable
- Throws:
- IOException
 
 - 
readExternalpublic void readExternal(ObjectInput is) throws IOException Redirects the default java serialization via externalizable to our default hadoop writable serialization for efficient broadcast/rdd deserialization.- Specified by:
- readExternalin interface- Externalizable
- Parameters:
- is- object input
- Throws:
- IOException- if IOException occurs
 
 - 
writeExternalpublic void writeExternal(ObjectOutput os) throws IOException Redirects the default java serialization via externalizable to our default hadoop writable serialization for efficient broadcast/rdd serialization.- Specified by:
- writeExternalin interface- Externalizable
- Parameters:
- os- object output
- Throws:
- IOException- if IOException occurs
 
 - 
getExactSizeOnDiskpublic long getExactSizeOnDisk() NOTE: The used estimates must be kept consistent with the respective write functions.- Returns:
- exact size on disk
 
 - 
getHeaderSizepublic static long getHeaderSize() 
 - 
estimateSizeInMemorypublic long estimateSizeInMemory() 
 - 
estimateSizeInMemorypublic static long estimateSizeInMemory(long nrows, long ncols, double sparsity)
 - 
estimateSizeDenseInMemorypublic long estimateSizeDenseInMemory() 
 - 
estimateSizeDenseInMemorypublic static long estimateSizeDenseInMemory(long nrows, long ncols)
 - 
estimateSizeSparseInMemorypublic long estimateSizeSparseInMemory() 
 - 
estimateSizeSparseInMemorypublic static long estimateSizeSparseInMemory(long nrows, long ncols, double sparsity)
 - 
estimateSizeSparseInMemorypublic static long estimateSizeSparseInMemory(long nrows, long ncols, double sparsity, boolean allowCSR)
 - 
estimateSizeSparseInMemorypublic long estimateSizeSparseInMemory(SparseBlock.Type stype) 
 - 
estimateSizeSparseInMemorypublic static long estimateSizeSparseInMemory(long nrows, long ncols, double sparsity, SparseBlock.Type stype)
 - 
estimateSizeOnDiskpublic long estimateSizeOnDisk() 
 - 
estimateSizeOnDiskpublic static long estimateSizeOnDisk(long nrows, long ncols, long nnz)
 - 
getInMemorySizepublic long getInMemorySize() Description copied from interface:CacheBlockGet the in-memory size in bytes of the cache block.- Specified by:
- getInMemorySizein interface- CacheBlock
- Returns:
- in-memory size in bytes of cache block
 
 - 
getExactSerializedSizepublic long getExactSerializedSize() Description copied from interface:CacheBlockGet the exact serialized size in bytes of the cache block.- Specified by:
- getExactSerializedSizein interface- CacheBlock
- Returns:
- exact serialized size in bytes of cache block
 
 - 
isShallowSerializepublic boolean isShallowSerialize() Description copied from interface:CacheBlockIndicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.- Specified by:
- isShallowSerializein interface- CacheBlock
- Returns:
- true if shallow serialized
 
 - 
isShallowSerializepublic boolean isShallowSerialize(boolean inclConvert) Description copied from interface:CacheBlockIndicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.- Specified by:
- isShallowSerializein interface- CacheBlock
- Parameters:
- inclConvert- if true report blocks as shallow serialize that are currently not amenable but can be brought into an amenable form via- toShallowSerializeBlock.
- Returns:
- true if shallow serialized
 
 - 
toShallowSerializeBlockpublic void toShallowSerializeBlock() Description copied from interface:CacheBlockConverts a cache block that is not shallow serializable into a form that is shallow serializable. This methods has no affect if the given cache block is not amenable.- Specified by:
- toShallowSerializeBlockin interface- CacheBlock
 
 - 
compactEmptyBlockpublic void compactEmptyBlock() Description copied from interface:CacheBlockFree unnecessarily allocated empty block.- Specified by:
- compactEmptyBlockin interface- CacheBlock
 
 - 
scalarOperationspublic MatrixBlock scalarOperations(ScalarOperator op, MatrixValue result) - Specified by:
- scalarOperationsin class- MatrixValue
 
 - 
unaryOperationspublic MatrixBlock unaryOperations(UnaryOperator op, MatrixValue result) - Specified by:
- unaryOperationsin class- MatrixValue
 
 - 
binaryOperationspublic final MatrixBlock binaryOperations(BinaryOperator op, MatrixValue thatValue) 
 - 
binaryOperationspublic MatrixBlock binaryOperations(BinaryOperator op, MatrixValue thatValue, MatrixValue result) - Specified by:
- binaryOperationsin class- MatrixValue
 
 - 
binaryOperationsInPlacepublic MatrixBlock binaryOperationsInPlace(BinaryOperator op, MatrixValue thatValue) - Specified by:
- binaryOperationsInPlacein class- MatrixValue
 
 - 
ternaryOperationspublic MatrixBlock ternaryOperations(TernaryOperator op, MatrixBlock m2, MatrixBlock m3, MatrixBlock ret) 
 - 
incrementalAggregatepublic void incrementalAggregate(AggregateOperator aggOp, MatrixValue correction, MatrixValue newWithCorrection, boolean deep) - Specified by:
- incrementalAggregatein class- MatrixValue
 
 - 
incrementalAggregatepublic void incrementalAggregate(AggregateOperator aggOp, MatrixValue newWithCorrection) - Specified by:
- incrementalAggregatein class- MatrixValue
 
 - 
reorgOperationspublic MatrixBlock reorgOperations(ReorgOperator op, MatrixValue ret, int startRow, int startColumn, int length) - Specified by:
- reorgOperationsin class- MatrixValue
 
 - 
appendpublic final MatrixBlock append(MatrixBlock that, MatrixBlock ret) 
 - 
appendpublic final MatrixBlock append(MatrixBlock that, MatrixBlock ret, boolean cbind) 
 - 
appendpublic MatrixBlock append(MatrixBlock[] that, MatrixBlock result, boolean cbind) 
 - 
checkDimensionsForAppendpublic void checkDimensionsForAppend(MatrixBlock[] in, boolean cbind) 
 - 
naryOperationspublic static MatrixBlock naryOperations(Operator op, MatrixBlock[] matrices, ScalarObject[] scalars, MatrixBlock ret) 
 - 
transposeSelfMatrixMultOperationspublic MatrixBlock transposeSelfMatrixMultOperations(MatrixBlock out, MMTSJ.MMTSJType tstype) 
 - 
transposeSelfMatrixMultOperationspublic MatrixBlock transposeSelfMatrixMultOperations(MatrixBlock out, MMTSJ.MMTSJType tstype, int k) 
 - 
chainMatrixMultOperationspublic MatrixBlock chainMatrixMultOperations(MatrixBlock v, MatrixBlock w, MatrixBlock out, MapMultChain.ChainType ctype) 
 - 
chainMatrixMultOperationspublic MatrixBlock chainMatrixMultOperations(MatrixBlock v, MatrixBlock w, MatrixBlock out, MapMultChain.ChainType ctype, int k) 
 - 
permutationMatrixMultOperationspublic void permutationMatrixMultOperations(MatrixValue m2Val, MatrixValue out1Val, MatrixValue out2Val) 
 - 
permutationMatrixMultOperationspublic void permutationMatrixMultOperations(MatrixValue m2Val, MatrixValue out1Val, MatrixValue out2Val, int k) 
 - 
leftIndexingOperationspublic final MatrixBlock leftIndexingOperations(MatrixBlock rhsMatrix, IndexRange ixrange, MatrixBlock ret, MatrixObject.UpdateType update) 
 - 
leftIndexingOperationspublic MatrixBlock leftIndexingOperations(MatrixBlock rhsMatrix, int rl, int ru, int cl, int cu, MatrixBlock ret, MatrixObject.UpdateType update) 
 - 
leftIndexingOperationspublic MatrixBlock leftIndexingOperations(ScalarObject scalar, int rl, int cl, MatrixBlock ret, MatrixObject.UpdateType update) Explicitly allow left indexing for scalars. Note: This operation is now 0-based. * Operations to be performed: 1) result=this; 2) result[row,column] = scalar.getDoubleValue();- Parameters:
- scalar- scalar object
- rl- row lower
- cl- column lower
- ret- ?
- update- ?
- Returns:
- matrix block
 
 - 
slicepublic MatrixBlock slice(IndexRange ixrange, MatrixBlock ret) 
 - 
slicepublic final MatrixBlock slice(int rl, int ru) Slice out a row block- Parameters:
- rl- The row lower to start from
- ru- The row lower to end at
- Returns:
- The sliced out matrix block.
 
 - 
slicepublic final MatrixBlock slice(int rl, int ru, boolean deep) 
 - 
slicepublic final MatrixBlock slice(int rl, int ru, int cl, int cu) 
 - 
slicepublic final MatrixBlock slice(int rl, int ru, int cl, int cu, CacheBlock ret) Description copied from interface:CacheBlockSlice a sub block out of the current block and write into the given output block. This method returns the passed instance if not null.- Specified by:
- slicein interface- CacheBlock
- Parameters:
- rl- row lower
- ru- row upper
- cl- column lower
- cu- column upper
- ret- cache block
- Returns:
- sub-block of cache block
 
 - 
slicepublic final MatrixBlock slice(int rl, int ru, int cl, int cu, boolean deep) Slice out a row block- Parameters:
- rl- The row lower to start from
- ru- The row lower to end at
- cl- The col lower to start from
- cu- The col lower to end at
- deep- Deep copy or not
- Returns:
- The sliced out matrix block.
 
 - 
slicepublic MatrixBlock slice(int rl, int ru, int cl, int cu, boolean deep, CacheBlock ret) Method to perform rightIndex operation for a given lower and upper bounds in row and column dimensions. Extracted submatrix is returned as "result". Note: This operation is now 0-based. This means that if you call with rl == ru then you get 1 row output.- Specified by:
- slicein interface- CacheBlock
- Parameters:
- rl- row lower if this value is below 0 or above the number of rows contained in the matrix an exception is thrown
- ru- row upper if this value is below rl or above the number of rows contained in the matrix an exception is thrown
- cl- column lower if this value us below 0 or above the number of columns contained in the matrix an exception is thrown
- cu- column upper if this value us below cl or above the number of columns contained in the matrix an exception is thrown
- deep- should perform deep copy, this is relevant in cases where the matrix is in sparse format, or the entire matrix is sliced out
- ret- output sliced out matrix block
- Returns:
- matrix block output matrix block
 
 - 
slicepublic void slice(ArrayList<IndexedMatrixValue> outlist, IndexRange range, int rowCut, int colCut, int blen, int boundaryRlen, int boundaryClen) Description copied from class:MatrixValueSlice out up to 4 matrixBlocks that are separated by the row and col Cuts. This is used in the context of spark execution to distributed sliced out matrix blocks of correct block size.- Specified by:
- slicein class- MatrixValue
- Parameters:
- outlist- The output matrix blocks that is extracted from the matrix
- range- An index range containing overlapping information.
- rowCut- The row to cut and split the matrix.
- colCut- The column to cut ans split the matrix.
- blen- The Block size of the output matrices.
- boundaryRlen- The row length of the edge case matrix block, used for the final blocks that does not have enough rows to construct a full block.
- boundaryClen- The col length of the edge case matrix block, used for the final blocks that does not have enough cols to construct a full block.
 
 - 
appendpublic void append(MatrixValue v2, ArrayList<IndexedMatrixValue> outlist, int blen, boolean cbind, boolean m2IsLast, int nextNCol) - Specified by:
- appendin class- MatrixValue
 
 - 
zeroOutOperationspublic MatrixBlock zeroOutOperations(MatrixValue result, IndexRange range, boolean complementary) - Specified by:
- zeroOutOperationsin class- MatrixValue
 
 - 
aggregateUnaryOperationspublic final MatrixBlock aggregateUnaryOperations(AggregateUnaryOperator op, MatrixValue result, int blen, MatrixIndexes indexesIn) - Specified by:
- aggregateUnaryOperationsin class- MatrixValue
 
 - 
aggregateUnaryOperationspublic MatrixBlock aggregateUnaryOperations(AggregateUnaryOperator op, MatrixValue result, int blen, MatrixIndexes indexesIn, boolean inCP) - Specified by:
- aggregateUnaryOperationsin class- MatrixValue
 
 - 
prepareAggregateUnaryOutputpublic MatrixBlock prepareAggregateUnaryOutput(AggregateUnaryOperator op, MatrixValue result, int blen) 
 - 
dropLastRowsOrColumnspublic void dropLastRowsOrColumns(Types.CorrectionLocationType correctionLocation) 
 - 
cmOperationspublic CM_COV_Object cmOperations(CMOperator op) 
 - 
checkCMOperationspublic static void checkCMOperations(MatrixBlock mb, CMOperator op) 
 - 
cmOperationspublic CM_COV_Object cmOperations(CMOperator op, MatrixBlock weights) 
 - 
covOperationspublic CM_COV_Object covOperations(COVOperator op, MatrixBlock that) 
 - 
covOperationspublic CM_COV_Object covOperations(COVOperator op, MatrixBlock that, MatrixBlock weights) 
 - 
sortOperationspublic final MatrixBlock sortOperations() 
 - 
sortOperationspublic final MatrixBlock sortOperations(MatrixValue weights) 
 - 
sortOperationspublic MatrixBlock sortOperations(MatrixValue weights, MatrixBlock result) 
 - 
sortOperationspublic MatrixBlock sortOperations(MatrixValue weights, MatrixBlock result, int k) 
 - 
interQuartileMeanpublic double interQuartileMean() 
 - 
computeIQMCorrectionpublic static double computeIQMCorrection(double sum, double sum_wt, double q25Part, double q25Val, double q75Part, double q75Val)
 - 
pickValuespublic MatrixBlock pickValues(MatrixValue quantiles, MatrixValue ret) 
 - 
medianpublic double median() 
 - 
pickValuepublic final double pickValue(double quantile) 
 - 
pickValuepublic double pickValue(double quantile, boolean average)
 - 
sumWeightForQuantilepublic double sumWeightForQuantile() In a given two column matrix, the second column denotes weights. This function computes the total weight- Returns:
- sum weight for quantile
 
 - 
aggregateBinaryOperationspublic final MatrixBlock aggregateBinaryOperations(MatrixBlock m1, MatrixBlock m2, AggregateBinaryOperator op) 
 - 
aggregateBinaryOperationspublic MatrixBlock aggregateBinaryOperations(MatrixBlock m1, MatrixBlock m2, MatrixBlock ret, AggregateBinaryOperator op) 
 - 
aggregateTernaryOperationspublic MatrixBlock aggregateTernaryOperations(MatrixBlock m1, MatrixBlock m2, MatrixBlock m3, MatrixBlock ret, AggregateTernaryOperator op, boolean inCP) 
 - 
uaggouterchainOperationspublic MatrixBlock uaggouterchainOperations(MatrixBlock mbLeft, MatrixBlock mbRight, MatrixBlock mbOut, BinaryOperator bOp, AggregateUnaryOperator uaggOp) 
 - 
groupedAggOperationspublic final MatrixBlock groupedAggOperations(MatrixValue tgt, MatrixValue wghts, MatrixValue ret, int ngroups, Operator op) Invocation from CP instructions. The aggregate is computed on the groups object against target and weights. Notes: * The computed number of groups is reused for multiple invocations with different target. * This implementation supports that the target is passed as column or row vector, in case of row vectors we also use sparse-safe implementations for sparse safe aggregation operators.- Parameters:
- tgt- ?
- wghts- ?
- ret- ?
- ngroups- ?
- op- operator
- Returns:
- matrix block
 
 - 
groupedAggOperationspublic MatrixBlock groupedAggOperations(MatrixValue tgt, MatrixValue wghts, MatrixValue ret, int ngroups, Operator op, int k) 
 - 
removeEmptyOperationspublic MatrixBlock removeEmptyOperations(MatrixBlock ret, boolean rows, boolean emptyReturn, MatrixBlock select) 
 - 
removeEmptyOperationspublic final MatrixBlock removeEmptyOperations(MatrixBlock ret, boolean rows, boolean emptyReturn) 
 - 
rexpandOperationspublic MatrixBlock rexpandOperations(MatrixBlock ret, double max, boolean rows, boolean cast, boolean ignore, int k) 
 - 
replaceOperationspublic MatrixBlock replaceOperations(MatrixValue result, double pattern, double replacement) - Specified by:
- replaceOperationsin class- MatrixValue
 
 - 
extractTriangularpublic MatrixBlock extractTriangular(MatrixBlock ret, boolean lower, boolean diag, boolean values) 
 - 
ctableOperationspublic void ctableOperations(Operator op, double scalarThat, MatrixValue that2Val, CTableMap resultMap, MatrixBlock resultBlock) D = ctable(A,v2,W) this <- A; scalarThat <- v2; that2 <- W; result <- D (i1,j1,v1) from input1 (this) (v2) from sclar_input2 (scalarThat) (i3,j3,w) from input3 (that2)- Specified by:
- ctableOperationsin class- MatrixValue
 
 - 
ctableOperationspublic void ctableOperations(Operator op, double scalarThat, double scalarThat2, CTableMap resultMap, MatrixBlock resultBlock) D = ctable(A,v2,w) this <- A; scalar_that <- v2; scalar_that2 <- w; result <- D (i1,j1,v1) from input1 (this) (v2) from sclar_input2 (scalarThat) (w) from scalar_input3 (scalarThat2)- Specified by:
- ctableOperationsin class- MatrixValue
 
 - 
ctableOperationspublic void ctableOperations(Operator op, MatrixIndexes ix1, double scalarThat, boolean left, int blen, CTableMap resultMap, MatrixBlock resultBlock) Specific ctable case of ctable(seq(...),X), where X is the only matrix input. The 'left' input parameter specifies if the seq appeared on the left, otherwise it appeared on the right.- Specified by:
- ctableOperationsin class- MatrixValue
 
 - 
ctableOperationspublic void ctableOperations(Operator op, MatrixValue thatVal, double scalarThat2, boolean ignoreZeros, CTableMap resultMap, MatrixBlock resultBlock) D = ctable(A,B,w) this <- A; that <- B; scalar_that2 <- w; result <- D (i1,j1,v1) from input1 (this) (i1,j1,v2) from input2 (that) (w) from scalar_input3 (scalarThat2) NOTE: This method supports both vectors and matrices. In case of matrices and ignoreZeros=true we can also use a sparse-safe implementation- Specified by:
- ctableOperationsin class- MatrixValue
 
 - 
ctableSeqOperationspublic MatrixBlock ctableSeqOperations(MatrixValue thatMatrix, double thatScalar, MatrixBlock ret, boolean updateClen) - Parameters:
- thatMatrix- matrix value
- thatScalar- scalar double
- ret- result matrix block
- updateClen- when this matrix already has the desired number of columns updateClen can be set to false
- Returns:
- result matrix block
 
 - 
ctableSeqOperationspublic final MatrixBlock ctableSeqOperations(MatrixValue thatMatrix, double thatScalar, MatrixBlock resultBlock) D = ctable(seq,A,w) this <- seq; thatMatrix <- A; thatScalar <- w; result <- D (i1,j1,v1) from input1 (this) (i1,j1,v2) from input2 (that) (w) from scalar_input3 (scalarThat2)- Parameters:
- thatMatrix- matrix value
- thatScalar- scalar double
- resultBlock- result matrix block
- Returns:
- resultBlock
 
 - 
ctableOperationspublic final void ctableOperations(Operator op, MatrixValue thatVal, MatrixValue that2Val, CTableMap resultMap) D = ctable(A,B,W) this <- A; that <- B; that2 <- W; result <- D (i1,j1,v1) from input1 (this) (i1,j1,v2) from input2 (that) (i1,j1,w) from input3 (that2)- Parameters:
- op- operator
- thatVal- matrix value 1
- that2Val- matrix value 2
- resultMap- table map
 
 - 
ctableOperationspublic void ctableOperations(Operator op, MatrixValue thatVal, MatrixValue that2Val, CTableMap resultMap, MatrixBlock resultBlock) - Specified by:
- ctableOperationsin class- MatrixValue
 
 - 
quaternaryOperationspublic final MatrixBlock quaternaryOperations(QuaternaryOperator qop, MatrixBlock um, MatrixBlock vm, MatrixBlock wm, MatrixBlock out) 
 - 
quaternaryOperationspublic MatrixBlock quaternaryOperations(QuaternaryOperator qop, MatrixBlock U, MatrixBlock V, MatrixBlock wm, MatrixBlock out, int k) 
 - 
randOperationspublic static MatrixBlock randOperations(int rows, int cols, double sparsity, double min, double max, String pdf, long seed) Function to generate the random matrix with specified dimensions (block sizes are not specified).- Parameters:
- rows- number of rows
- cols- number of columns
- sparsity- sparsity as a percentage
- min- minimum value
- max- maximum value
- pdf- pdf
- seed- random seed
- Returns:
- matrix block
 
 - 
randOperationspublic static MatrixBlock randOperations(int rows, int cols, double sparsity, double min, double max, String pdf, long seed, int k) Function to generate the random matrix with specified dimensions (block sizes are not specified).- Parameters:
- rows- number of rows
- cols- number of columns
- sparsity- sparsity as a percentage
- min- minimum value
- max- maximum value
- pdf- pdf
- seed- random seed
- k- ?
- Returns:
- matrix block
 
 - 
randOperationspublic static MatrixBlock randOperations(RandomMatrixGenerator rgen, long seed) Function to generate the random matrix with specified dimensions and block dimensions.- Parameters:
- rgen- random matrix generator
- seed- seed value
- Returns:
- matrix block
 
 - 
randOperationspublic static MatrixBlock randOperations(RandomMatrixGenerator rgen, long seed, int k) Function to generate the random matrix with specified dimensions and block dimensions.- Parameters:
- rgen- random matrix generator
- seed- seed value
- k- ?
- Returns:
- matrix block
 
 - 
randOperationsInPlacepublic MatrixBlock randOperationsInPlace(RandomMatrixGenerator rgen, org.apache.commons.math3.random.Well1024a bigrand, long bSeed) Function to generate a matrix of random numbers. This is invoked both from CP as well as from MR. In case of CP, it generates an entire matrix block-by-block. Abigrandis passed so that block-level seeds are generated internally. In case of MR, it generates a single block for given block-level seedbSeed. When pdf="uniform", cell values are drawn from uniform distribution in range[min,max]. When pdf="normal", cell values are drawn from standard normal distribution N(0,1). The range of generated values will always be (-Inf,+Inf).- Parameters:
- rgen- random matrix generator
- bigrand- ?
- bSeed- seed value
- Returns:
- matrix block
 
 - 
randOperationsInPlacepublic MatrixBlock randOperationsInPlace(RandomMatrixGenerator rgen, org.apache.commons.math3.random.Well1024a bigrand, long bSeed, int k) Function to generate a matrix of random numbers. This is invoked both from CP as well as from MR. In case of CP, it generates an entire matrix block-by-block. Abigrandis passed so that block-level seeds are generated internally. In case of MR, it generates a single block for given block-level seedbSeed. When pdf="uniform", cell values are drawn from uniform distribution in range[min,max]. When pdf="normal", cell values are drawn from standard normal distribution N(0,1). The range of generated values will always be (-Inf,+Inf).- Parameters:
- rgen- random matrix generator
- bigrand- ?
- bSeed- seed value
- k- ?
- Returns:
- matrix block
 
 - 
seqOperationspublic static MatrixBlock seqOperations(double from, double to, double incr) Method to generate a sequence according to the given parameters. The generated sequence is always in dense format. Both end points specifiedfromandtomust be included in the generated sequence i.e., [from,to] both inclusive. Note that,tois included only if (to-from) is perfectly divisible byincr. For example, seq(0,1,0.5) generates (0.0 0.5 1.0) whereas seq(0,1,0.6) generates (0.0 0.6) but not (0.0 0.6 1.0)- Parameters:
- from- ?
- to- ?
- incr- ?
- Returns:
- matrix block
 
 - 
seqOperationsInPlacepublic MatrixBlock seqOperationsInPlace(double from, double to, double incr) 
 - 
sampleOperationspublic static MatrixBlock sampleOperations(long range, int size, boolean replace, long seed) 
 - 
isThreadSafepublic boolean isThreadSafe() Indicates if concurrent modifications of disjoint rows are thread-safe.- Returns:
- true if thread-safe
 
 - 
isThreadSafepublic static boolean isThreadSafe(boolean sparse) Indicates if concurrent modifications of disjoint rows are thread-safe.- Parameters:
- sparse- true if sparse
- Returns:
- true if ?
 
 - 
checkNaNpublic void checkNaN() Checks for existing NaN values in the matrix block.- Throws:
- DMLRuntimeException- if the blocks contains at least one NaN.
 
 - 
compareTopublic final int compareTo(Object arg0) - Specified by:
- compareToin interface- Comparable
 
 - 
getDoublepublic double getDouble(int r, int c)Description copied from interface:CacheBlockReturns the double value at the passed row and column. If the value is missing 0 is returned.- Specified by:
- getDoublein interface- CacheBlock
- Parameters:
- r- row of the value
- c- column of the value
- Returns:
- double value at the passed row and column
 
 - 
getDoubleNaNpublic double getDoubleNaN(int r, int c)Description copied from interface:CacheBlockReturns the double value at the passed row and column. If the value is missing NaN is returned.- Specified by:
- getDoubleNaNin interface- CacheBlock
- Parameters:
- r- row of the value
- c- column of the value
- Returns:
- double value at the passed row and column
 
 - 
getStringpublic String getString(int r, int c) Description copied from interface:CacheBlockReturns the string of the value at the passed row and column. If the value is missing or NaN, null is returned.- Specified by:
- getStringin interface- CacheBlock
- Parameters:
- r- row of the value
- c- column of the value
- Returns:
- string of the value at the passed row and column
 
 
- 
 
-