public class MatrixBlock extends MatrixValue implements org.apache.sysml.runtime.controlprogram.caching.CacheBlock, Externalizable
Modifier and Type | Class and Description |
---|---|
static class |
MatrixBlock.BlockType |
static class |
MatrixBlock.SparsityEstimate |
MatrixValue.CellIndex
Modifier and Type | Field and Description |
---|---|
protected int |
clen |
static boolean |
CONVERT_MCSR_TO_CSR_ON_DEEP_SERIALIZE |
static SparseBlock.Type |
DEFAULT_INPLACE_SPARSEBLOCK |
static SparseBlock.Type |
DEFAULT_SPARSEBLOCK |
protected DenseBlock |
denseBlock |
protected int |
estimatedNNzsPerRow |
static int |
HEADER_SIZE |
static double |
MAX_SHALLOW_SERIALIZE_OVERHEAD |
protected long |
nonZeros |
protected int |
rlen |
protected boolean |
sparse |
protected SparseBlock |
sparseBlock |
static double |
SPARSITY_TURN_POINT |
static int |
ULTRA_SPARSE_BLOCK_NNZ |
static double |
ULTRA_SPARSITY_TURN_POINT |
static double |
ULTRA_SPARSITY_TURN_POINT2 |
Constructor and 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,
long estnnz) |
MatrixBlock(int rl,
int cl,
long nnz,
SparseBlock sblock)
Constructs a sparse
MatrixBlock with a given instance of a SparseBlock |
MatrixBlock(MatrixBlock that) |
MatrixBlock(MatrixBlock that,
SparseBlock.Type stype,
boolean deep) |
Modifier and Type | Method and Description |
---|---|
MatrixBlock |
aggregateBinaryOperations(MatrixBlock m1,
MatrixBlock m2,
MatrixBlock ret,
org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator op) |
MatrixBlock |
aggregateBinaryOperations(MatrixIndexes m1Index,
MatrixBlock m1,
MatrixIndexes m2Index,
MatrixBlock m2,
MatrixBlock ret,
org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator op) |
MatrixBlock |
aggregateTernaryOperations(MatrixBlock m1,
MatrixBlock m2,
MatrixBlock m3,
MatrixBlock ret,
org.apache.sysml.runtime.matrix.operators.AggregateTernaryOperator op,
boolean inCP) |
MatrixValue |
aggregateUnaryOperations(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator op,
MatrixValue result,
int blockingFactorRow,
int blockingFactorCol,
MatrixIndexes indexesIn) |
MatrixValue |
aggregateUnaryOperations(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator op,
MatrixValue result,
int blockingFactorRow,
int blockingFactorCol,
MatrixIndexes indexesIn,
boolean inCP) |
void |
allocateAndResetSparseBlock(boolean clearNNZ,
SparseBlock.Type stype) |
MatrixBlock |
allocateBlock() |
MatrixBlock |
allocateDenseBlock() |
boolean |
allocateDenseBlock(boolean clearNNZ) |
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()
|
boolean |
allocateSparseRowsBlock() |
boolean |
allocateSparseRowsBlock(boolean clearNNZ) |
MatrixBlock |
append(MatrixBlock[] that,
MatrixBlock ret,
boolean cbind) |
MatrixBlock |
append(MatrixBlock that,
MatrixBlock ret) |
MatrixBlock |
append(MatrixBlock that,
MatrixBlock ret,
boolean cbind) |
void |
append(MatrixValue v2,
ArrayList<org.apache.sysml.runtime.matrix.mapred.IndexedMatrixValue> outlist,
int blockRowFactor,
int blockColFactor,
boolean cbind,
boolean m2IsLast,
int nextNCol) |
void |
appendRow(int r,
SparseRow row) |
void |
appendRow(int r,
SparseRow row,
boolean deep) |
void |
appendRowToSparse(SparseBlock dest,
MatrixBlock src,
int i,
int rowoffset,
int coloffset,
boolean deep) |
void |
appendToSparse(MatrixBlock that,
int rowoffset,
int coloffset) |
void |
appendToSparse(MatrixBlock that,
int rowoffset,
int coloffset,
boolean deep) |
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
|
MatrixValue |
binaryOperations(org.apache.sysml.runtime.matrix.operators.BinaryOperator op,
MatrixValue thatValue,
MatrixValue result) |
void |
binaryOperationsInPlace(org.apache.sysml.runtime.matrix.operators.BinaryOperator op,
MatrixValue thatValue) |
MatrixBlock |
chainMatrixMultOperations(MatrixBlock v,
MatrixBlock w,
MatrixBlock out,
org.apache.sysml.lops.MapMultChain.ChainType ctype) |
MatrixBlock |
chainMatrixMultOperations(MatrixBlock v,
MatrixBlock w,
MatrixBlock out,
org.apache.sysml.lops.MapMultChain.ChainType ctype,
int k) |
void |
checkNaN()
Checks for existing NaN values in the matrix block.
|
void |
checkNonZeros()
Basic debugging primitive to check correctness of nnz.
|
void |
checkSparseRows() |
void |
checkSparseRows(int rl,
int ru)
Basic debugging primitive to check sparse block column ordering.
|
void |
cleanupBlock(boolean dense,
boolean sparse)
Allows to cleanup all previously allocated sparserows or denseblocks.
|
org.apache.sysml.runtime.instructions.cp.CM_COV_Object |
cmOperations(org.apache.sysml.runtime.matrix.operators.CMOperator op) |
org.apache.sysml.runtime.instructions.cp.CM_COV_Object |
cmOperations(org.apache.sysml.runtime.matrix.operators.CMOperator op,
MatrixBlock weights) |
void |
compactEmptyBlock()
Free unnecessarily allocated empty block.
|
int |
compareTo(Object arg0) |
static double |
computeIQMCorrection(double sum,
double sum_wt,
double q25Part,
double q25Val,
double q75Part,
double q75Val) |
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.
|
void |
copy(MatrixValue thatValue) |
void |
copy(MatrixValue thatValue,
boolean sp) |
MatrixBlock |
copyShallow(MatrixBlock that) |
org.apache.sysml.runtime.instructions.cp.CM_COV_Object |
covOperations(org.apache.sysml.runtime.matrix.operators.COVOperator op,
MatrixBlock that) |
org.apache.sysml.runtime.instructions.cp.CM_COV_Object |
covOperations(org.apache.sysml.runtime.matrix.operators.COVOperator op,
MatrixBlock that,
MatrixBlock weights) |
void |
ctableOperations(org.apache.sysml.runtime.matrix.operators.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)
|
void |
ctableOperations(org.apache.sysml.runtime.matrix.operators.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)
|
void |
ctableOperations(org.apache.sysml.runtime.matrix.operators.Operator op,
MatrixIndexes ix1,
double scalarThat,
boolean left,
int brlen,
CTableMap resultMap,
MatrixBlock resultBlock)
Specific ctable case of ctable(seq(...),X), where X is the only
matrix input.
|
void |
ctableOperations(org.apache.sysml.runtime.matrix.operators.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.
|
void |
ctableOperations(org.apache.sysml.runtime.matrix.operators.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)
|
void |
ctableOperations(org.apache.sysml.runtime.matrix.operators.Operator op,
MatrixValue thatVal,
MatrixValue that2Val,
CTableMap resultMap,
MatrixBlock resultBlock) |
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)
|
void |
dropLastRowsOrColumns(org.apache.sysml.lops.PartialAggregate.CorrectionLocationType correctionLocation) |
boolean |
equals(Object arg0) |
static long |
estimateSizeDenseInMemory(long nrows,
long ncols) |
long |
estimateSizeInMemory() |
static long |
estimateSizeInMemory(long nrows,
long ncols,
double sparsity) |
long |
estimateSizeOnDisk() |
static long |
estimateSizeOnDisk(long nrows,
long ncols,
long nnz) |
static long |
estimateSizeSparseInMemory(long nrows,
long ncols,
double sparsity) |
static long |
estimateSizeSparseInMemory(long nrows,
long ncols,
double sparsity,
SparseBlock.Type stype) |
static MatrixBlock.SparsityEstimate |
estimateSparsityOnAggBinary(MatrixBlock m1,
MatrixBlock m2,
org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator op) |
boolean |
evalSparseFormatInMemory()
Evaluates if this matrix block should be in sparse format in
memory.
|
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.
|
boolean |
evalSparseFormatOnDisk()
Evaluates if this matrix block should be in sparse format on
disk.
|
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).
|
void |
examSparsity() |
void |
examSparsity(boolean allowCSR)
Evaluates if this matrix block should be in sparse format in
memory.
|
MatrixBlock |
extractTriangular(MatrixBlock ret,
boolean lower,
boolean diag,
boolean values) |
DenseBlock |
getDenseBlock() |
double[] |
getDenseBlockValues() |
long |
getExactSerializedSize()
Get the exact serialized size in bytes of the cache block.
|
long |
getExactSizeOnDisk()
NOTE: The used estimates must be kept consistent with the respective write functions.
|
long |
getInMemorySize()
Get the in-memory size in bytes of the cache block.
|
long |
getLength() |
MatrixCharacteristics |
getMatrixCharacteristics() |
long |
getNonZeros() |
int |
getNumColumns() |
int |
getNumRows() |
SparseBlock |
getSparseBlock() |
Iterator<IJV> |
getSparseBlockIterator() |
Iterator<IJV> |
getSparseBlockIterator(int rl,
int ru) |
double |
getSparsity() |
double |
getValue(int r,
int c) |
double |
getValueDenseUnsafe(int r,
int c) |
MatrixBlock |
groupedAggOperations(MatrixValue tgt,
MatrixValue wghts,
MatrixValue ret,
int ngroups,
org.apache.sysml.runtime.matrix.operators.Operator op)
Invocation from CP instructions.
|
MatrixBlock |
groupedAggOperations(MatrixValue tgt,
MatrixValue wghts,
MatrixValue ret,
int ngroups,
org.apache.sysml.runtime.matrix.operators.Operator op,
int k) |
int |
hashCode() |
void |
incrementalAggregate(org.apache.sysml.runtime.matrix.operators.AggregateOperator aggOp,
MatrixValue newWithCorrection) |
void |
incrementalAggregate(org.apache.sysml.runtime.matrix.operators.AggregateOperator aggOp,
MatrixValue correction,
MatrixValue newWithCorrection,
boolean deep) |
void |
init(double[][] arr,
int r,
int c)
NOTE: This method is designed only for dense representation.
|
void |
init(double[] arr,
int r,
int c)
NOTE: This method is designed only for dense representation.
|
double |
interQuartileMean() |
boolean |
isAllocated() |
boolean |
isEmpty() |
boolean |
isEmptyBlock() |
boolean |
isEmptyBlock(boolean safe) |
boolean |
isInSparseFormat()
Returns the current representation (true for sparse).
|
boolean |
isShallowSerialize()
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.
|
boolean |
isShallowSerialize(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.
|
boolean |
isThreadSafe()
Indicates if concurrent modifications of disjoint rows are thread-safe.
|
static boolean |
isThreadSafe(boolean sparse)
Indicates if concurrent modifications of disjoint rows are thread-safe.
|
boolean |
isUltraSparse() |
boolean |
isUltraSparse(boolean checkNnz) |
boolean |
isUltraSparsePermutationMatrix() |
boolean |
isVector() |
MatrixBlock |
leftIndexingOperations(MatrixBlock rhsMatrix,
org.apache.sysml.runtime.util.IndexRange ixrange,
MatrixBlock ret,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject.UpdateType update) |
MatrixBlock |
leftIndexingOperations(MatrixBlock rhsMatrix,
int rl,
int ru,
int cl,
int cu,
MatrixBlock ret,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject.UpdateType update) |
MatrixBlock |
leftIndexingOperations(org.apache.sysml.runtime.instructions.cp.ScalarObject scalar,
int rl,
int cl,
MatrixBlock ret,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject.UpdateType update)
Explicitly allow left indexing for scalars.
|
double |
max()
Wrapper method for reduceall-max of a matrix.
|
double |
mean()
Wrapper method for reduceall-mean of a matrix.
|
double |
median() |
void |
merge(org.apache.sysml.runtime.controlprogram.caching.CacheBlock that,
boolean appendOnly)
Merge the given block into the current block.
|
void |
merge(MatrixBlock that,
boolean appendOnly)
Merge disjoint: merges all non-zero values of the given input into the current
matrix block.
|
void |
merge(MatrixBlock that,
boolean appendOnly,
boolean par) |
double |
min()
Wrapper method for reduceall-min of a matrix.
|
double |
minNonZero()
Utility function for computing the min non-zero value.
|
static MatrixBlock |
naryOperations(org.apache.sysml.runtime.matrix.operators.Operator op,
MatrixBlock[] matrices,
org.apache.sysml.runtime.instructions.cp.ScalarObject[] scalars,
MatrixBlock ret) |
void |
permutationMatrixMultOperations(MatrixValue m2Val,
MatrixValue out1Val,
MatrixValue out2Val) |
void |
permutationMatrixMultOperations(MatrixValue m2Val,
MatrixValue out1Val,
MatrixValue out2Val,
int k) |
double |
pickValue(double quantile) |
double |
pickValue(double quantile,
boolean average) |
MatrixValue |
pickValues(MatrixValue quantiles,
MatrixValue ret) |
double |
prod()
Wrapper method for reduceall-product of a matrix.
|
MatrixBlock |
quaternaryOperations(org.apache.sysml.runtime.matrix.operators.QuaternaryOperator qop,
MatrixBlock um,
MatrixBlock vm,
MatrixBlock wm,
MatrixBlock out) |
MatrixBlock |
quaternaryOperations(org.apache.sysml.runtime.matrix.operators.QuaternaryOperator qop,
MatrixBlock U,
MatrixBlock V,
MatrixBlock wm,
MatrixBlock out,
int k) |
double |
quickGetValue(int r,
int c) |
void |
quickSetValue(int r,
int c,
double v) |
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).
|
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).
|
static MatrixBlock |
randOperations(RandomMatrixGenerator rgen,
long seed)
Function to generate the random matrix with specified dimensions and block dimensions.
|
static MatrixBlock |
randOperations(RandomMatrixGenerator rgen,
long seed,
int k)
Function to generate the random matrix with specified dimensions and block dimensions.
|
MatrixBlock |
randOperationsInPlace(RandomMatrixGenerator rgen,
org.apache.commons.math3.random.Well1024a bigrand,
long bSeed)
Function to generate a matrix of random numbers.
|
MatrixBlock |
randOperationsInPlace(RandomMatrixGenerator rgen,
org.apache.commons.math3.random.Well1024a bigrand,
long bSeed,
int k)
Function to generate a matrix of random numbers.
|
void |
readExternal(ObjectInput is)
Redirects the default java serialization via externalizable to our default
hadoop writable serialization for efficient broadcast/rdd deserialization.
|
void |
readFields(DataInput in) |
long |
recomputeNonZeros()
Recomputes and materializes the number of non-zero values
of the entire matrix block.
|
long |
recomputeNonZeros(int rl,
int ru) |
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.
|
MatrixBlock |
removeEmptyOperations(MatrixBlock ret,
boolean rows,
boolean emptyReturn) |
MatrixBlock |
removeEmptyOperations(MatrixBlock ret,
boolean rows,
boolean emptyReturn,
MatrixBlock select) |
MatrixValue |
reorgOperations(org.apache.sysml.runtime.matrix.operators.ReorgOperator op,
MatrixValue ret,
int startRow,
int startColumn,
int length) |
MatrixValue |
replaceOperations(MatrixValue result,
double pattern,
double replacement) |
void |
reset() |
void |
reset(int rl,
int cl) |
void |
reset(int rl,
int cl,
boolean sp) |
void |
reset(int rl,
int cl,
boolean sp,
long estnnz) |
void |
reset(int rl,
int cl,
double val) |
void |
reset(int rl,
int cl,
long estnnz) |
MatrixBlock |
rexpandOperations(MatrixBlock ret,
double max,
boolean rows,
boolean cast,
boolean ignore,
int k) |
static MatrixBlock |
sampleOperations(long range,
int size,
boolean replace,
long seed) |
MatrixValue |
scalarOperations(org.apache.sysml.runtime.matrix.operators.ScalarOperator op,
MatrixValue result) |
static MatrixBlock |
seqOperations(double from,
double to,
double incr)
Method to generate a sequence according to the given parameters.
|
MatrixBlock |
seqOperationsInPlace(double from,
double to,
double incr) |
long |
setNonZeros(long nnz) |
void |
setNumColumns(int c) |
void |
setNumRows(int r)
NOTE: setNumRows() and setNumColumns() are used only in ternaryInstruction (for contingency tables)
and pmm for meta corrections.
|
void |
setSparseBlock(SparseBlock sblock) |
void |
setValue(int r,
int c,
double v) |
void |
slice(ArrayList<org.apache.sysml.runtime.matrix.mapred.IndexedMatrixValue> outlist,
org.apache.sysml.runtime.util.IndexRange range,
int rowCut,
int colCut,
int normalBlockRowFactor,
int normalBlockColFactor,
int boundaryRlen,
int boundaryClen) |
MatrixBlock |
slice(org.apache.sysml.runtime.util.IndexRange ixrange,
MatrixBlock ret) |
MatrixBlock |
slice(int rl,
int ru) |
MatrixBlock |
slice(int rl,
int ru,
int cl,
int cu,
boolean deep,
org.apache.sysml.runtime.controlprogram.caching.CacheBlock ret)
Method to perform rightIndex operation for a given lower and upper bounds in row and column dimensions.
|
MatrixBlock |
slice(int rl,
int ru,
int cl,
int cu,
org.apache.sysml.runtime.controlprogram.caching.CacheBlock ret)
Slice a sub block out of the current block and write into the given output block.
|
MatrixValue |
sortOperations(MatrixValue weights,
MatrixValue result) |
void |
sortSparseRows()
Sorts all existing sparse rows by column indexes.
|
void |
sortSparseRows(int rl,
int ru)
Sorts all existing sparse rows in range [rl,ru) by
column indexes.
|
void |
sparseToDense() |
double |
sum()
Wrapper method for reduceall-sum of a matrix.
|
double |
sumSq()
Wrapper method for reduceall-sumSq of a matrix.
|
double |
sumWeightForQuantile()
In a given two column matrix, the second column denotes weights.
|
MatrixBlock |
ternaryOperations(org.apache.sysml.runtime.matrix.operators.TernaryOperator op,
MatrixBlock m2,
MatrixBlock m3,
MatrixBlock ret) |
void |
toShallowSerializeBlock()
Converts a cache block that is not shallow serializable into
a form that is shallow serializable.
|
String |
toString() |
MatrixBlock |
transposeSelfMatrixMultOperations(MatrixBlock out,
org.apache.sysml.lops.MMTSJ.MMTSJType tstype) |
MatrixBlock |
transposeSelfMatrixMultOperations(MatrixBlock out,
org.apache.sysml.lops.MMTSJ.MMTSJType tstype,
int k) |
MatrixBlock |
uaggouterchainOperations(MatrixBlock mbLeft,
MatrixBlock mbRight,
MatrixBlock mbOut,
org.apache.sysml.runtime.matrix.operators.BinaryOperator bOp,
org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator uaggOp) |
MatrixValue |
unaryOperations(org.apache.sysml.runtime.matrix.operators.UnaryOperator op,
MatrixValue result) |
void |
write(DataOutput out) |
void |
writeExternal(ObjectOutput os)
Redirects the default java serialization via externalizable to our default
hadoop writable serialization for efficient broadcast/rdd serialization.
|
MatrixValue |
zeroOutOperations(MatrixValue result,
org.apache.sysml.runtime.util.IndexRange range,
boolean complementary) |
public static final double SPARSITY_TURN_POINT
public static final double ULTRA_SPARSITY_TURN_POINT
public static final double ULTRA_SPARSITY_TURN_POINT2
public static final int ULTRA_SPARSE_BLOCK_NNZ
public static final SparseBlock.Type DEFAULT_SPARSEBLOCK
public static final SparseBlock.Type DEFAULT_INPLACE_SPARSEBLOCK
public static final double MAX_SHALLOW_SERIALIZE_OVERHEAD
public static final boolean CONVERT_MCSR_TO_CSR_ON_DEEP_SERIALIZE
public static final int HEADER_SIZE
protected int rlen
protected int clen
protected boolean sparse
protected long nonZeros
protected DenseBlock denseBlock
protected SparseBlock sparseBlock
protected int estimatedNNzsPerRow
public MatrixBlock()
public MatrixBlock(int rl, int cl, boolean sp)
public MatrixBlock(int rl, int cl, long estnnz)
public MatrixBlock(int rl, int cl, boolean sp, long estnnz)
public MatrixBlock(MatrixBlock that)
public MatrixBlock(double val)
public MatrixBlock(int rl, int cl, double val)
public MatrixBlock(int rl, int cl, long nnz, SparseBlock sblock)
MatrixBlock
with a given instance of a SparseBlock
rl
- number of rowscl
- number of columnsnnz
- number of non zeroessblock
- sparse blockpublic MatrixBlock(MatrixBlock that, SparseBlock.Type stype, boolean deep)
public void reset()
reset
in class MatrixValue
public void reset(int rl, int cl)
reset
in class MatrixValue
public void reset(int rl, int cl, long estnnz)
public void reset(int rl, int cl, boolean sp)
reset
in class MatrixValue
public void reset(int rl, int cl, boolean sp, long estnnz)
reset
in class MatrixValue
public void reset(int rl, int cl, double val)
reset
in class MatrixValue
public void init(double[][] arr, int r, int c)
arr
- 2d double array matrixr
- number of rowsc
- number of columnspublic void init(double[] arr, int r, int c)
arr
- double array matrixr
- number of rowsc
- number of columnspublic boolean isAllocated()
public MatrixBlock allocateDenseBlock()
public MatrixBlock allocateBlock()
public boolean allocateDenseBlock(boolean clearNNZ)
public boolean allocateSparseRowsBlock()
public boolean allocateSparseRowsBlock(boolean clearNNZ)
public void allocateAndResetSparseBlock(boolean clearNNZ, SparseBlock.Type stype)
public void allocateDenseBlockUnsafe(int rl, int cl)
rl
- number of rowscl
- number of columnspublic void cleanupBlock(boolean dense, boolean sparse)
dense
- if true, set dense block to nullsparse
- if true, set sparse block to nullpublic int getNumRows()
getNumRows
in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
getNumRows
in class MatrixValue
public void setNumRows(int r)
r
- number of rowspublic int getNumColumns()
getNumColumns
in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
getNumColumns
in class MatrixValue
public void setNumColumns(int c)
public long getNonZeros()
getNonZeros
in class MatrixValue
public long setNonZeros(long nnz)
public double getSparsity()
public MatrixCharacteristics getMatrixCharacteristics()
public boolean isVector()
public long getLength()
public boolean isEmpty()
isEmpty
in class MatrixValue
public boolean isEmptyBlock()
public boolean isEmptyBlock(boolean safe)
public DenseBlock getDenseBlock()
public double[] getDenseBlockValues()
public SparseBlock getSparseBlock()
public void setSparseBlock(SparseBlock sblock)
public double getValue(int r, int c)
getValue
in class MatrixValue
public void setValue(int r, int c, double v)
setValue
in class MatrixValue
public double quickGetValue(int r, int c)
public void quickSetValue(int r, int c, double v)
public double getValueDenseUnsafe(int r, int c)
public void appendValue(int r, int c, double v)
r
- rowc
- columnv
- valuepublic void appendRow(int r, SparseRow row)
public void appendRow(int r, SparseRow row, boolean deep)
public void appendToSparse(MatrixBlock that, int rowoffset, int coloffset)
public void appendToSparse(MatrixBlock that, int rowoffset, int coloffset, boolean deep)
public void appendRowToSparse(SparseBlock dest, MatrixBlock src, int i, int rowoffset, int coloffset, boolean deep)
public void sortSparseRows()
public void sortSparseRows(int rl, int ru)
rl
- row lower bound, inclusiveru
- row upper bound, exclusivepublic double minNonZero()
public double prod()
public double mean()
public double min()
public double max()
public double sum()
public double sumSq()
public boolean isInSparseFormat()
isInSparseFormat
in class MatrixValue
public boolean isUltraSparse()
public boolean isUltraSparse(boolean checkNnz)
public boolean isUltraSparsePermutationMatrix()
public boolean evalSparseFormatInMemory()
public boolean evalSparseFormatOnDisk()
public void examSparsity()
public void examSparsity(boolean allowCSR)
allowCSR
- allow CSR format on dense to sparse conversionpublic static boolean evalSparseFormatInMemory(long nrows, long ncols, long nnz)
nrows
- number of rowsncols
- number of columnsnnz
- number of non-zerospublic static boolean evalSparseFormatOnDisk(long nrows, long ncols, long nnz)
nrows
- number of rowsncols
- number of columnsnnz
- number of non-zerospublic void sparseToDense()
public long recomputeNonZeros()
public long recomputeNonZeros(int rl, int ru)
public long recomputeNonZeros(int rl, int ru, int cl, int cu)
rl
- row lower index, 0-based, inclusiveru
- row upper index, 0-based, inclusivecl
- column lower index, 0-based, inclusivecu
- column upper index, 0-based, inclusivepublic void checkNonZeros()
public void checkSparseRows()
public void checkSparseRows(int rl, int ru)
rl
- row lower bound (inclusive)ru
- row upper bound (exclusive)public void copy(MatrixValue thatValue)
copy
in class MatrixValue
public void copy(MatrixValue thatValue, boolean sp)
copy
in class MatrixValue
public MatrixBlock copyShallow(MatrixBlock that)
public void copy(int rl, int ru, int cl, int cu, MatrixBlock src, boolean awareDestNZ)
rl
- row lower index, 0-basedru
- row upper index, 0-basedcl
- column lower index, 0-basedcu
- column upper index, 0-basedsrc
- matrix blockawareDestNZ
- 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)public void merge(org.apache.sysml.runtime.controlprogram.caching.CacheBlock that, boolean appendOnly)
org.apache.sysml.runtime.controlprogram.caching.CacheBlock
merge
in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
that
- cache blockappendOnly
- ?public void merge(MatrixBlock that, boolean appendOnly)
that
- matrix blockappendOnly
- ?public void merge(MatrixBlock that, boolean appendOnly, boolean par)
public void readFields(DataInput in) throws IOException
readFields
in interface org.apache.hadoop.io.Writable
IOException
public void write(DataOutput out) throws IOException
write
in interface org.apache.hadoop.io.Writable
IOException
public void readExternal(ObjectInput is) throws IOException
readExternal
in interface Externalizable
is
- object inputIOException
- if IOException occurspublic void writeExternal(ObjectOutput os) throws IOException
writeExternal
in interface Externalizable
os
- object outputIOException
- if IOException occurspublic long getExactSizeOnDisk()
public long estimateSizeInMemory()
public static long estimateSizeInMemory(long nrows, long ncols, double sparsity)
public static long estimateSizeDenseInMemory(long nrows, long ncols)
public static long estimateSizeSparseInMemory(long nrows, long ncols, double sparsity)
public static long estimateSizeSparseInMemory(long nrows, long ncols, double sparsity, SparseBlock.Type stype)
public long estimateSizeOnDisk()
public static long estimateSizeOnDisk(long nrows, long ncols, long nnz)
public static MatrixBlock.SparsityEstimate estimateSparsityOnAggBinary(MatrixBlock m1, MatrixBlock m2, org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator op)
public long getInMemorySize()
org.apache.sysml.runtime.controlprogram.caching.CacheBlock
getInMemorySize
in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
public long getExactSerializedSize()
org.apache.sysml.runtime.controlprogram.caching.CacheBlock
getExactSerializedSize
in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
public boolean isShallowSerialize()
org.apache.sysml.runtime.controlprogram.caching.CacheBlock
isShallowSerialize
in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
public boolean isShallowSerialize(boolean inclConvert)
org.apache.sysml.runtime.controlprogram.caching.CacheBlock
isShallowSerialize
in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
inclConvert
- if true report blocks as shallow serialize that are
currently not amenable but can be brought into an amenable form
via toShallowSerializeBlock
.public void toShallowSerializeBlock()
org.apache.sysml.runtime.controlprogram.caching.CacheBlock
toShallowSerializeBlock
in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
public void compactEmptyBlock()
org.apache.sysml.runtime.controlprogram.caching.CacheBlock
compactEmptyBlock
in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
public MatrixValue scalarOperations(org.apache.sysml.runtime.matrix.operators.ScalarOperator op, MatrixValue result)
scalarOperations
in class MatrixValue
public MatrixValue unaryOperations(org.apache.sysml.runtime.matrix.operators.UnaryOperator op, MatrixValue result)
unaryOperations
in class MatrixValue
public MatrixValue binaryOperations(org.apache.sysml.runtime.matrix.operators.BinaryOperator op, MatrixValue thatValue, MatrixValue result)
binaryOperations
in class MatrixValue
public void binaryOperationsInPlace(org.apache.sysml.runtime.matrix.operators.BinaryOperator op, MatrixValue thatValue)
binaryOperationsInPlace
in class MatrixValue
public MatrixBlock ternaryOperations(org.apache.sysml.runtime.matrix.operators.TernaryOperator op, MatrixBlock m2, MatrixBlock m3, MatrixBlock ret)
public void incrementalAggregate(org.apache.sysml.runtime.matrix.operators.AggregateOperator aggOp, MatrixValue correction, MatrixValue newWithCorrection, boolean deep)
incrementalAggregate
in class MatrixValue
public void incrementalAggregate(org.apache.sysml.runtime.matrix.operators.AggregateOperator aggOp, MatrixValue newWithCorrection)
incrementalAggregate
in class MatrixValue
public MatrixValue reorgOperations(org.apache.sysml.runtime.matrix.operators.ReorgOperator op, MatrixValue ret, int startRow, int startColumn, int length)
reorgOperations
in class MatrixValue
public MatrixBlock append(MatrixBlock that, MatrixBlock ret)
public MatrixBlock append(MatrixBlock that, MatrixBlock ret, boolean cbind)
public MatrixBlock append(MatrixBlock[] that, MatrixBlock ret, boolean cbind)
public static MatrixBlock naryOperations(org.apache.sysml.runtime.matrix.operators.Operator op, MatrixBlock[] matrices, org.apache.sysml.runtime.instructions.cp.ScalarObject[] scalars, MatrixBlock ret)
public MatrixBlock transposeSelfMatrixMultOperations(MatrixBlock out, org.apache.sysml.lops.MMTSJ.MMTSJType tstype)
public MatrixBlock transposeSelfMatrixMultOperations(MatrixBlock out, org.apache.sysml.lops.MMTSJ.MMTSJType tstype, int k)
public MatrixBlock chainMatrixMultOperations(MatrixBlock v, MatrixBlock w, MatrixBlock out, org.apache.sysml.lops.MapMultChain.ChainType ctype)
public MatrixBlock chainMatrixMultOperations(MatrixBlock v, MatrixBlock w, MatrixBlock out, org.apache.sysml.lops.MapMultChain.ChainType ctype, int k)
public void permutationMatrixMultOperations(MatrixValue m2Val, MatrixValue out1Val, MatrixValue out2Val)
public void permutationMatrixMultOperations(MatrixValue m2Val, MatrixValue out1Val, MatrixValue out2Val, int k)
public final MatrixBlock leftIndexingOperations(MatrixBlock rhsMatrix, org.apache.sysml.runtime.util.IndexRange ixrange, MatrixBlock ret, org.apache.sysml.runtime.controlprogram.caching.MatrixObject.UpdateType update)
public MatrixBlock leftIndexingOperations(MatrixBlock rhsMatrix, int rl, int ru, int cl, int cu, MatrixBlock ret, org.apache.sysml.runtime.controlprogram.caching.MatrixObject.UpdateType update)
public MatrixBlock leftIndexingOperations(org.apache.sysml.runtime.instructions.cp.ScalarObject scalar, int rl, int cl, MatrixBlock ret, org.apache.sysml.runtime.controlprogram.caching.MatrixObject.UpdateType update)
scalar
- scalar objectrl
- row lowercl
- column lowerret
- ?update
- ?public MatrixBlock slice(org.apache.sysml.runtime.util.IndexRange ixrange, MatrixBlock ret)
public MatrixBlock slice(int rl, int ru)
public MatrixBlock slice(int rl, int ru, int cl, int cu, org.apache.sysml.runtime.controlprogram.caching.CacheBlock ret)
org.apache.sysml.runtime.controlprogram.caching.CacheBlock
slice
in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
rl
- row lowerru
- row uppercl
- column lowercu
- column upperret
- cache blockpublic MatrixBlock slice(int rl, int ru, int cl, int cu, boolean deep, org.apache.sysml.runtime.controlprogram.caching.CacheBlock ret)
rl
- row lowerru
- row uppercl
- column lowercu
- column upperdeep
- should perform deep copyret
- output matrix blockpublic void slice(ArrayList<org.apache.sysml.runtime.matrix.mapred.IndexedMatrixValue> outlist, org.apache.sysml.runtime.util.IndexRange range, int rowCut, int colCut, int normalBlockRowFactor, int normalBlockColFactor, int boundaryRlen, int boundaryClen)
slice
in class MatrixValue
public void append(MatrixValue v2, ArrayList<org.apache.sysml.runtime.matrix.mapred.IndexedMatrixValue> outlist, int blockRowFactor, int blockColFactor, boolean cbind, boolean m2IsLast, int nextNCol)
append
in class MatrixValue
public MatrixValue zeroOutOperations(MatrixValue result, org.apache.sysml.runtime.util.IndexRange range, boolean complementary)
zeroOutOperations
in class MatrixValue
public MatrixValue aggregateUnaryOperations(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator op, MatrixValue result, int blockingFactorRow, int blockingFactorCol, MatrixIndexes indexesIn)
aggregateUnaryOperations
in class MatrixValue
public MatrixValue aggregateUnaryOperations(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator op, MatrixValue result, int blockingFactorRow, int blockingFactorCol, MatrixIndexes indexesIn, boolean inCP)
aggregateUnaryOperations
in class MatrixValue
public void dropLastRowsOrColumns(org.apache.sysml.lops.PartialAggregate.CorrectionLocationType correctionLocation)
public org.apache.sysml.runtime.instructions.cp.CM_COV_Object cmOperations(org.apache.sysml.runtime.matrix.operators.CMOperator op)
public org.apache.sysml.runtime.instructions.cp.CM_COV_Object cmOperations(org.apache.sysml.runtime.matrix.operators.CMOperator op, MatrixBlock weights)
public org.apache.sysml.runtime.instructions.cp.CM_COV_Object covOperations(org.apache.sysml.runtime.matrix.operators.COVOperator op, MatrixBlock that)
public org.apache.sysml.runtime.instructions.cp.CM_COV_Object covOperations(org.apache.sysml.runtime.matrix.operators.COVOperator op, MatrixBlock that, MatrixBlock weights)
public MatrixValue sortOperations(MatrixValue weights, MatrixValue result)
public double interQuartileMean()
public static double computeIQMCorrection(double sum, double sum_wt, double q25Part, double q25Val, double q75Part, double q75Val)
public MatrixValue pickValues(MatrixValue quantiles, MatrixValue ret)
public double median()
public double pickValue(double quantile)
public double pickValue(double quantile, boolean average)
public double sumWeightForQuantile()
public MatrixBlock aggregateBinaryOperations(MatrixIndexes m1Index, MatrixBlock m1, MatrixIndexes m2Index, MatrixBlock m2, MatrixBlock ret, org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator op)
public MatrixBlock aggregateBinaryOperations(MatrixBlock m1, MatrixBlock m2, MatrixBlock ret, org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator op)
public MatrixBlock aggregateTernaryOperations(MatrixBlock m1, MatrixBlock m2, MatrixBlock m3, MatrixBlock ret, org.apache.sysml.runtime.matrix.operators.AggregateTernaryOperator op, boolean inCP)
public MatrixBlock uaggouterchainOperations(MatrixBlock mbLeft, MatrixBlock mbRight, MatrixBlock mbOut, org.apache.sysml.runtime.matrix.operators.BinaryOperator bOp, org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator uaggOp)
public MatrixBlock groupedAggOperations(MatrixValue tgt, MatrixValue wghts, MatrixValue ret, int ngroups, org.apache.sysml.runtime.matrix.operators.Operator op)
tgt
- ?wghts
- ?ret
- ?ngroups
- ?op
- operatorpublic MatrixBlock groupedAggOperations(MatrixValue tgt, MatrixValue wghts, MatrixValue ret, int ngroups, org.apache.sysml.runtime.matrix.operators.Operator op, int k)
public MatrixBlock removeEmptyOperations(MatrixBlock ret, boolean rows, boolean emptyReturn, MatrixBlock select)
public MatrixBlock removeEmptyOperations(MatrixBlock ret, boolean rows, boolean emptyReturn)
public MatrixBlock rexpandOperations(MatrixBlock ret, double max, boolean rows, boolean cast, boolean ignore, int k)
public MatrixValue replaceOperations(MatrixValue result, double pattern, double replacement)
replaceOperations
in class MatrixValue
public MatrixBlock extractTriangular(MatrixBlock ret, boolean lower, boolean diag, boolean values)
public void ctableOperations(org.apache.sysml.runtime.matrix.operators.Operator op, double scalarThat, MatrixValue that2Val, CTableMap resultMap, MatrixBlock resultBlock)
ctableOperations
in class MatrixValue
public void ctableOperations(org.apache.sysml.runtime.matrix.operators.Operator op, double scalarThat, double scalarThat2, CTableMap resultMap, MatrixBlock resultBlock)
ctableOperations
in class MatrixValue
public void ctableOperations(org.apache.sysml.runtime.matrix.operators.Operator op, MatrixIndexes ix1, double scalarThat, boolean left, int brlen, CTableMap resultMap, MatrixBlock resultBlock)
ctableOperations
in class MatrixValue
public void ctableOperations(org.apache.sysml.runtime.matrix.operators.Operator op, MatrixValue thatVal, double scalarThat2, boolean ignoreZeros, CTableMap resultMap, MatrixBlock resultBlock)
ctableOperations
in class MatrixValue
public MatrixBlock ctableSeqOperations(MatrixValue thatMatrix, double thatScalar, MatrixBlock resultBlock)
thatMatrix
- matrix valuethatScalar
- scalar doubleresultBlock
- result matrix blockpublic void ctableOperations(org.apache.sysml.runtime.matrix.operators.Operator op, MatrixValue thatVal, MatrixValue that2Val, CTableMap resultMap)
op
- operatorthatVal
- matrix value 1that2Val
- matrix value 2resultMap
- table mappublic void ctableOperations(org.apache.sysml.runtime.matrix.operators.Operator op, MatrixValue thatVal, MatrixValue that2Val, CTableMap resultMap, MatrixBlock resultBlock)
ctableOperations
in class MatrixValue
public MatrixBlock quaternaryOperations(org.apache.sysml.runtime.matrix.operators.QuaternaryOperator qop, MatrixBlock um, MatrixBlock vm, MatrixBlock wm, MatrixBlock out)
public MatrixBlock quaternaryOperations(org.apache.sysml.runtime.matrix.operators.QuaternaryOperator qop, MatrixBlock U, MatrixBlock V, MatrixBlock wm, MatrixBlock out, int k)
public static MatrixBlock randOperations(int rows, int cols, double sparsity, double min, double max, String pdf, long seed)
rows
- number of rowscols
- number of columnssparsity
- sparsity as a percentagemin
- minimum valuemax
- maximum valuepdf
- pdfseed
- random seedpublic static MatrixBlock randOperations(int rows, int cols, double sparsity, double min, double max, String pdf, long seed, int k)
rows
- number of rowscols
- number of columnssparsity
- sparsity as a percentagemin
- minimum valuemax
- maximum valuepdf
- pdfseed
- random seedk
- ?public static MatrixBlock randOperations(RandomMatrixGenerator rgen, long seed)
rgen
- random matrix generatorseed
- seed valuepublic static MatrixBlock randOperations(RandomMatrixGenerator rgen, long seed, int k)
rgen
- random matrix generatorseed
- seed valuek
- ?public MatrixBlock randOperationsInPlace(RandomMatrixGenerator rgen, org.apache.commons.math3.random.Well1024a bigrand, long bSeed)
bigrand
is passed so that block-level
seeds are generated internally. In case of MR, it generates a single
block for given block-level seed bSeed
.
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).rgen
- random matrix generatorbigrand
- ?bSeed
- seed valuepublic MatrixBlock randOperationsInPlace(RandomMatrixGenerator rgen, org.apache.commons.math3.random.Well1024a bigrand, long bSeed, int k)
bigrand
is passed so that block-level
seeds are generated internally. In case of MR, it generates a single
block for given block-level seed bSeed
.
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).rgen
- random matrix generatorbigrand
- ?bSeed
- seed valuek
- ?public static MatrixBlock seqOperations(double from, double to, double incr)
from
and to
must be
included in the generated sequence i.e., [from,to] both inclusive. Note
that, to
is included only if (to-from) is perfectly
divisible by incr
.
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)from
- ?to
- ?incr
- ?public MatrixBlock seqOperationsInPlace(double from, double to, double incr)
public static MatrixBlock sampleOperations(long range, int size, boolean replace, long seed)
public boolean isThreadSafe()
public static boolean isThreadSafe(boolean sparse)
sparse
- true if sparsepublic void checkNaN()
DMLRuntimeException
- if the blocks contains at least one NaN.public int compareTo(Object arg0)
compareTo
in interface Comparable
Copyright © 2018 The Apache Software Foundation. All rights reserved.