Package org.apache.sysds.runtime.data
Class DenseBlock
- java.lang.Object
- 
- org.apache.sysds.runtime.data.DenseBlock
 
- 
- All Implemented Interfaces:
- Serializable
 - Direct Known Subclasses:
- DenseBlockDRB,- DenseBlockLDRB
 
 public abstract class DenseBlock extends Object implements Serializable This DenseBlock is an abstraction for different dense, row-major matrix formats. For efficient dense operations, this API does not expose a row but a row-block abstraction, where a block can contain one or many contiguous rows.- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classDenseBlock.Type
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intblockSize()Get the number of rows per block, except last one.abstract intblockSize(int bix)Get the number of rows of the given block.abstract longcapacity()Get the total length of allocated blocks.abstract longcountNonZeros()Compute the number of non-zero values, which potentially makes a full pass over the underlying blocks.abstract intcountNonZeros(int r)Compute the number of non-zero values for the given row, which potentially makes a full pass over the underlying row.abstract longcountNonZeros(int rl, int ru, int cl, int cu)Compute the number of non-zero values, which potentially makes a full pass over the underlying blocks in the row range.static doubleestimateMemory(long nrows, long ncols)abstract doubleget(int[] ix)Get the value of a given cellabstract doubleget(int r, int c)Get the value for a given row and column.intgetCumODims(int i)Get the ith cumulative dimensions size of the dense block, without row.intgetDim(int i)Get the ith dimensions size of the dense block.abstract longgetLong(int[] ix)Get the value of a given cell as longvoidgetNextIndexes(int[] ix)Calculates the next index array.abstract StringgetString(int[] ix)Get the value of a given cell as a Stringabstract voidincr(int r, int c)Increments the given value for a given row and column.abstract voidincr(int r, int c, double delta)Increments the given value for a given row and column by delta.abstract intindex(int r)Get the block index for a given row.abstract booleanisContiguous()Indicates if the dense block has a single underlying block, i.e., if numBlocks==1.abstract booleanisContiguous(int rl, int ru)Indicates if the dense block has a single underlying block for the given row range.abstract booleanisNumeric()Indicates if the dense block is numeric.abstract booleanisNumeric(Types.ValueType vt)Indicates if the dense block is a specific numeric value type.abstract intnumBlocks()Get the number of allocated blocks.intnumDims()Get the number of dimensions.intnumRows()Get the number of rows.abstract intpos(int r)Get the position for a given row within its associated block.abstract intpos(int[] ix)Get the position for a given cell within the associated block.abstract intpos(int r, int c)Get the position for a given row and column within the associated block.voidreset()Resets the dense block by deleting non-zero values.voidreset(int[] dims)Resets the dense block by deleting non-zero values.voidreset(int[] dims, double v)Resets the dense block by deleting non-zeros.voidreset(int rlen, int clen)Resets the dense block by deleting non-zeros.voidreset(int rlen, int[] odims)Resets the dense block by deleting non-zeros.abstract voidreset(int rlen, int[] odims, double v)Resets the dense block by setting the given value.voidreset(int rlen, int clen, double v)Resets the dense block by setting the given value.abstract DenseBlockset(double v)Set the given value for the entire dense block (fill).abstract DenseBlockset(int[] ix, double v)Set the specified cell to the given value.abstract DenseBlockset(int[] ix, long v)Set the specified cell to the given value.abstract DenseBlockset(int[] ix, String v)Set the specified cell to the given value.abstract DenseBlockset(int r, double[] v)Copy the given vector into the given row.abstract DenseBlockset(int r, int c, double v)Set the given value for a given row and column.abstract DenseBlockset(int rl, int ru, int cl, int cu, double v)Set the given value for an entire index range of the dense block (fill).DenseBlockset(int rl, int ru, int cl, int cu, DenseBlock db)Copy the given dense block into the specified index range.DenseBlockset(int r, KahanObject kbuff)Copy the given kahan object sum and correction into the given row.DenseBlockset(String s)Set the given string for the entire dense block (fill).abstract DenseBlockset(DenseBlock db)Copy the given dense block.DenseBlockset(KahanObject kbuff)Copy the given kahan object sum and correction.voidsetDims(int[] dims)Set the dimensions of the dense MatrixBlock.longsize()Get the length of the dense block as the product of all dimensions.abstract intsize(int bix)Get the length of the given block.StringtoString()abstract double[]values(int r)Get the allocated block for the given row.abstract double[]valuesAt(int bix)Get an allocated block.
 
- 
- 
- 
Method Detail- 
getDimpublic final int getDim(int i) Get the ith dimensions size of the dense block.- Parameters:
- i- the number of dimension to get
- Returns:
- the size of the dimension
 
 - 
getCumODimspublic final int getCumODims(int i) Get the ith cumulative dimensions size of the dense block, without row.- Parameters:
- i- the number of the cumulative dimension to get (0 equals the second dimension!)
- Returns:
- the size of the dimension cumulative with all following dimensions
 
 - 
resetpublic final void reset() Resets the dense block by deleting non-zero values. After this call all countNonZeros() calls are guaranteed to return 0.
 - 
resetpublic final void reset(int[] dims) Resets the dense block by deleting non-zero values. After this call all countNonZeros() calls are guaranteed to return 0. If the new dimensions exceed the current capacity, the underlying storage is extended accordingly.- Parameters:
- dims- length and size of dimensions.
 
 - 
resetpublic final void reset(int[] dims, double v)Resets the dense block by deleting non-zeros.- Parameters:
- dims- lenth and size of dimensions
- v- value
 
 - 
resetpublic final void reset(int rlen, int clen)Resets the dense block by deleting non-zeros.- Parameters:
- rlen- number of rows
- clen- number of columns
 
 - 
resetpublic final void reset(int rlen, int[] odims)Resets the dense block by deleting non-zeros.- Parameters:
- rlen- number of rows
- odims- offsets of other dimensions
 
 - 
resetpublic final void reset(int rlen, int clen, double v)Resets the dense block by setting the given value.- Parameters:
- rlen- number of rows
- clen- number of columns
- v- value
 
 - 
resetpublic abstract void reset(int rlen, int[] odims, double v)Resets the dense block by setting the given value.- Parameters:
- rlen- number of rows
- odims- other dimensions
- v- value
 
 - 
estimateMemorypublic static double estimateMemory(long nrows, long ncols)
 - 
setDimspublic void setDims(int[] dims) Set the dimensions of the dense MatrixBlock.- Parameters:
- dims- The dimensions to set, first dimension is rows, second cols.
 
 - 
numRowspublic final int numRows() Get the number of rows.- Returns:
- number of rows
 
 - 
numDimspublic final int numDims() Get the number of dimensions.- Returns:
- number of dimensions, min 2
 
 - 
numBlockspublic abstract int numBlocks() Get the number of allocated blocks.- Returns:
- number of blocks
 
 - 
blockSizepublic abstract int blockSize() Get the number of rows per block, except last one.- Returns:
- number of rows in block
 
 - 
blockSizepublic abstract int blockSize(int bix) Get the number of rows of the given block.- Parameters:
- bix- block index
- Returns:
- number of rows in block
 
 - 
isNumericpublic abstract boolean isNumeric() Indicates if the dense block is numeric.- Returns:
- true if numeric (FP, INT, BOOLEAN)
 
 - 
isNumericpublic abstract boolean isNumeric(Types.ValueType vt) Indicates if the dense block is a specific numeric value type.- Parameters:
- vt- value type to check
- Returns:
- true if numeric and of value type vt
 
 - 
isContiguouspublic abstract boolean isContiguous() Indicates if the dense block has a single underlying block, i.e., if numBlocks==1.- Returns:
- true if single block
 
 - 
isContiguouspublic abstract boolean isContiguous(int rl, int ru)Indicates if the dense block has a single underlying block for the given row range.- Parameters:
- rl- row lower index
- ru- row upper index (inclusive)
- Returns:
- true if single block in row range
 
 - 
sizepublic final long size() Get the length of the dense block as the product of all dimensions.- Returns:
- length
 
 - 
sizepublic abstract int size(int bix) Get the length of the given block.- Parameters:
- bix- block index
- Returns:
- length
 
 - 
capacitypublic abstract long capacity() Get the total length of allocated blocks.- Returns:
- capacity
 
 - 
countNonZerospublic abstract long countNonZeros() Compute the number of non-zero values, which potentially makes a full pass over the underlying blocks.- Returns:
- number of non-zeros
 
 - 
countNonZerospublic abstract int countNonZeros(int r) Compute the number of non-zero values for the given row, which potentially makes a full pass over the underlying row.- Parameters:
- r- row index
- Returns:
- number of non-zeros
 
 - 
countNonZerospublic abstract long countNonZeros(int rl, int ru, int cl, int cu)Compute the number of non-zero values, which potentially makes a full pass over the underlying blocks in the row range.- Parameters:
- rl- row lower index
- ru- row upper index (exclusive)
- cl- column lower index
- cu- column upper index (exclusive)
- Returns:
- number of non-zeros
 
 - 
valuespublic abstract double[] values(int r) Get the allocated block for the given row. This call is equivalent to valuesAt(indexes(r)).- Parameters:
- r- row index
- Returns:
- block
 
 - 
valuesAtpublic abstract double[] valuesAt(int bix) Get an allocated block.- Parameters:
- bix- block index
- Returns:
- block
 
 - 
indexpublic abstract int index(int r) Get the block index for a given row.- Parameters:
- r- row index
- Returns:
- block index
 
 - 
pospublic abstract int pos(int r) Get the position for a given row within its associated block.- Parameters:
- r- row index
- Returns:
- block position
 
 - 
pospublic abstract int pos(int r, int c)Get the position for a given row and column within the associated block.- Parameters:
- r- row index
- c- column index
- Returns:
- block position
 
 - 
pospublic abstract int pos(int[] ix) Get the position for a given cell within the associated block.- Parameters:
- ix- cell indexes
- Returns:
- block position
 
 - 
incrpublic abstract void incr(int r, int c)Increments the given value for a given row and column.- Parameters:
- r- row index
- c- column index
 
 - 
incrpublic abstract void incr(int r, int c, double delta)Increments the given value for a given row and column by delta.- Parameters:
- r- row index
- c- column index
- delta- increment value
 
 - 
setpublic abstract DenseBlock set(double v) Set the given value for the entire dense block (fill).- Parameters:
- v- value
- Returns:
- self
 
 - 
setpublic DenseBlock set(String s) Set the given string for the entire dense block (fill). Generally the string will be parsed, except for string DenseBlock.- Parameters:
- s- string
- Returns:
- self
 
 - 
setpublic abstract DenseBlock set(int rl, int ru, int cl, int cu, double v) Set the given value for an entire index range of the dense block (fill).- Parameters:
- rl- row lower index
- ru- row upper index (exclusive)
- cl- column lower index
- cu- column upper index (exclusive)
- v- value
- Returns:
- self
 
 - 
setpublic abstract DenseBlock set(int r, int c, double v) Set the given value for a given row and column.- Parameters:
- r- row index
- c- column index
- v- value
- Returns:
- self
 
 - 
setpublic abstract DenseBlock set(int r, double[] v) Copy the given vector into the given row.- Parameters:
- r- row index
- v- value vector
- Returns:
- self
 
 - 
setpublic abstract DenseBlock set(DenseBlock db) Copy the given dense block.- Parameters:
- db- dense block
- Returns:
- self
 
 - 
setpublic DenseBlock set(int rl, int ru, int cl, int cu, DenseBlock db) Copy the given dense block into the specified index range.- Parameters:
- rl- row lower index
- ru- row upper index (exclusive)
- cl- column lower index
- cu- column upper index (exclusive)
- db- dense block
- Returns:
- self
 
 - 
getNextIndexespublic void getNextIndexes(int[] ix) Calculates the next index array. Note that if the given index array was the last element, the next index will be outside of range.- Parameters:
- ix- the index array which will be incremented to the next index array
 
 - 
setpublic DenseBlock set(KahanObject kbuff) Copy the given kahan object sum and correction.- Parameters:
- kbuff- kahan object
- Returns:
- self
 
 - 
setpublic abstract DenseBlock set(int[] ix, double v) Set the specified cell to the given value.- Parameters:
- ix- cell indexes
- v- value
- Returns:
- self
 
 - 
setpublic abstract DenseBlock set(int[] ix, long v) Set the specified cell to the given value.- Parameters:
- ix- cell indexes
- v- value
- Returns:
- self
 
 - 
setpublic abstract DenseBlock set(int[] ix, String v) Set the specified cell to the given value.- Parameters:
- ix- cell indexes
- v- value as String
- Returns:
- self
 
 - 
setpublic DenseBlock set(int r, KahanObject kbuff) Copy the given kahan object sum and correction into the given row.- Parameters:
- r- row index
- kbuff- kahan object
- Returns:
- self
 
 - 
getpublic abstract double get(int r, int c)Get the value for a given row and column.- Parameters:
- r- row index
- c- column index
- Returns:
- value
 
 - 
getpublic abstract double get(int[] ix) Get the value of a given cell- Parameters:
- ix- cell indexes
- Returns:
- value
 
 - 
getStringpublic abstract String getString(int[] ix) Get the value of a given cell as a String- Parameters:
- ix- cell indexes
- Returns:
- value as String
 
 - 
getLongpublic abstract long getLong(int[] ix) Get the value of a given cell as long- Parameters:
- ix- cell indexes
- Returns:
- value as long
 
 
- 
 
-