public class SparseBlockCOO extends SparseBlock
SparseBlock.Type
INIT_CAPACITY, RESIZE_FACTOR1, RESIZE_FACTOR2
Constructor and Description |
---|
SparseBlockCOO(int rlen) |
SparseBlockCOO(int rlen,
int capacity) |
SparseBlockCOO(SparseBlock sblock)
Copy constructor sparse block abstraction.
|
SparseBlockCOO(SparseRow[] rows,
int nnz)
Copy constructor old sparse row representation.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(int r,
int c,
double v)
Add a value to a matrix cell (r,c).
|
void |
allocate(int r)
Allocate the underlying data structure holding non-zero values
of row r if necessary.
|
void |
allocate(int r,
int nnz)
Allocate the underlying data structure holding non-zero values
of row r if necessary, w/ given size.
|
void |
allocate(int r,
int ennz,
int maxnnz)
Allocate the underlying data structure holding non-zero values
of row r w/ the specified estimated nnz and max nnz.
|
void |
append(int r,
int c,
double v)
Append a value to the end of the physical representation.
|
boolean |
checkValidity(int rlen,
int clen,
long nnz,
boolean strict)
Validate the correctness of the internal data structures of the different
sparse block implementations.
|
void |
compact(int r)
Re-allocate physical row if physical size exceeds
logical size plus resize factor.
|
void |
deleteIndexRange(int r,
int cl,
int cu)
Deletes all non-zero values of the given column range [cl,cu) in row r.
|
static long |
estimateMemory(long nrows,
long ncols,
double sparsity)
Get the estimated in-memory size of the sparse block in COO
with the given dimensions w/o accounting for overallocation.
|
SparseRow |
get(int r)
Get values of row r in the format of a sparse row.
|
double |
get(int r,
int c)
Get value of matrix cell (r,c).
|
Iterator<IJV> |
getIterator()
Get a non-zero iterator over the entire sparse block.
|
Iterator<IJV> |
getIterator(int ru)
Get a non-zero iterator over the partial sparse block [0,ru).
|
Iterator<IJV> |
getIterator(int rl,
int ru)
Get a non-zero iterator over the subblock [rl, ru).
|
int[] |
indexes()
Get raw access to underlying array of column indices
For use in GPU code
|
int[] |
indexes(int r)
Get the sorted array of column indexes of all non-zero entries in
row r.
|
boolean |
isAllocated(int r)
Indicates if the underlying data structure for a given row
is already allocated.
|
boolean |
isContiguous()
Indicates if the underlying data structures returned by values
and indexes are contiguous arrays, which can be exploited for
more efficient operations.
|
boolean |
isEmpty(int r)
Get information if row r is empty, i.e., does not contain non-zero
values.
|
boolean |
isThreadSafe()
Indicates if the underlying implementation allows thread-safe row
updates if concurrent threads update disjoint rows.
|
int |
numRows()
Get the number of rows in the sparse block.
|
int |
pos(int r)
Get the starting position of row r in the indexes/values arrays returned
by indexes(r) and values(r).
|
int |
posFIndexGT(int r,
int c)
Get position of first column index greater than column c in row r.
|
int |
posFIndexGTE(int r,
int c)
Get position of first column index greater than or equal column c
in row r.
|
int |
posFIndexLTE(int r,
int c)
Get position of first column index lower than or equal column c
in row r.
|
void |
reset()
Clears the sparse block by deleting non-zero values.
|
void |
reset(int ennz,
int maxnnz)
Clears the sparse block by deleting non-zero values.
|
void |
reset(int r,
int ennz,
int maxnnz)
Clears row r of the sparse block by deleting non-zero values.
|
int[] |
rowIndexes()
Get raw access to underlying array of row indices
For use in GPU code
|
boolean |
set(int r,
int c,
double v)
Set the value of a matrix cell (r,c).
|
void |
set(int r,
SparseRow row,
boolean deep)
Set the values of row r to the given sparse row.
|
void |
setIndexRange(int r,
int cl,
int cu,
double[] v,
int[] vix,
int vpos,
int vlen)
Sets a sparse array of non-zeros values and indexes into the column range [cl,cu)
in row r.
|
void |
setIndexRange(int r,
int cl,
int cu,
double[] v,
int vix,
int vlen)
Sets a dense array of non-zeros values into the column range [cl,cu)
in row r.
|
long |
size()
Get the number of non-zero values in the sparse block.
|
int |
size(int r)
Get the number of non-zero values in row r.
|
long |
size(int rl,
int ru)
Get the number of non-zeros values in the row range
of [rl, ru).
|
long |
size(int rl,
int ru,
int cl,
int cu)
Get the number of non-zeros values in the row and column
range of [rl/cl, ru/cu);
|
void |
sort()
Sort all non-zero value/index pairs of the sparse block by row
and column index.
|
void |
sort(int r)
Sort all non-zero value/index pairs of row r column index.
|
String |
toString() |
double[] |
values()
Get raw access to underlying array of values
For use in GPU code
|
double[] |
values(int r)
Get the array of all non-zero entries in row r, sorted by their column
indexes.
|
isAligned, isAligned
public SparseBlockCOO(int rlen)
public SparseBlockCOO(int rlen, int capacity)
public SparseBlockCOO(SparseBlock sblock)
sblock
- sparse block to copypublic SparseBlockCOO(SparseRow[] rows, int nnz)
rows
- array of sparse rowsnnz
- number of non-zerospublic static long estimateMemory(long nrows, long ncols, double sparsity)
nrows
- number of rowsncols
- number of columnssparsity
- sparsity ratiopublic void allocate(int r)
SparseBlock
allocate
in class SparseBlock
r
- row indexpublic void allocate(int r, int nnz)
SparseBlock
allocate
in class SparseBlock
r
- row indexnnz
- number of non-zerospublic void allocate(int r, int ennz, int maxnnz)
SparseBlock
allocate
in class SparseBlock
r
- row indexennz
- estimated non-zerosmaxnnz
- max non-zerospublic void compact(int r)
SparseBlock
compact
in class SparseBlock
r
- row indexpublic int numRows()
SparseBlock
numRows
in class SparseBlock
public boolean isThreadSafe()
SparseBlock
isThreadSafe
in class SparseBlock
public boolean isContiguous()
SparseBlock
isContiguous
in class SparseBlock
public boolean isAllocated(int r)
SparseBlock
isAllocated
in class SparseBlock
r
- row indexpublic boolean checkValidity(int rlen, int clen, long nnz, boolean strict)
SparseBlock
checkValidity
in class SparseBlock
rlen
- number of rowsclen
- number of columnsnnz
- number of non zerosstrict
- enforce optional propertiespublic void reset()
SparseBlock
reset
in class SparseBlock
public void reset(int ennz, int maxnnz)
SparseBlock
reset
in class SparseBlock
ennz
- estimated non-zerosmaxnnz
- max non-zerospublic void reset(int r, int ennz, int maxnnz)
SparseBlock
reset
in class SparseBlock
r
- row indexennz
- estimated non-zerosmaxnnz
- max non-zerospublic long size()
SparseBlock
size
in class SparseBlock
public int size(int r)
SparseBlock
size
in class SparseBlock
r
- row index starting at 0public long size(int rl, int ru)
SparseBlock
size
in class SparseBlock
rl
- row lower indexru
- row upper indexpublic long size(int rl, int ru, int cl, int cu)
SparseBlock
size
in class SparseBlock
rl
- row lower indexru
- row upper indexcl
- column lower indexcu
- column upper indexpublic boolean isEmpty(int r)
SparseBlock
isEmpty
in class SparseBlock
r
- row index starting at 0public int[] indexes(int r)
SparseBlock
indexes
in class SparseBlock
r
- row index starting at 0public double[] values(int r)
SparseBlock
values
in class SparseBlock
r
- row index starting at 0public int pos(int r)
SparseBlock
pos
in class SparseBlock
r
- row index starting at 0public boolean set(int r, int c, double v)
SparseBlock
set
in class SparseBlock
r
- row index starting at 0c
- column index starting at 0v
- zero or non-zero valuepublic void set(int r, SparseRow row, boolean deep)
SparseBlock
set
in class SparseBlock
r
- row index starting at 0row
- sparse rowdeep
- indicator to create deep copy of sparse rowpublic boolean add(int r, int c, double v)
SparseBlock
add
in class SparseBlock
r
- row index starting at 0c
- column index starting at 0v
- zero or non-zero valuepublic void append(int r, int c, double v)
SparseBlock
append
in class SparseBlock
r
- row index starting at 0c
- column index starting at 0v
- zero or non-zero valuepublic void setIndexRange(int r, int cl, int cu, double[] v, int vix, int vlen)
SparseBlock
setIndexRange
in class SparseBlock
r
- row index starting at 0cl
- lower column index starting at 0cu
- upper column index starting at 0v
- value arrayvix
- start index in value arrayvlen
- number of relevant valuespublic void setIndexRange(int r, int cl, int cu, double[] v, int[] vix, int vpos, int vlen)
SparseBlock
setIndexRange
in class SparseBlock
r
- row index starting at 0cl
- lower column index starting at 0cu
- upper column index starting at 0v
- value arrayvix
- column index arrayvpos
- start index in value and index arraysvlen
- number of relevant valuespublic void deleteIndexRange(int r, int cl, int cu)
SparseBlock
deleteIndexRange
in class SparseBlock
r
- row index starting at 0cl
- lower column index starting at 0cu
- upper column index starting at 0public void sort()
SparseBlock
sort
in class SparseBlock
public void sort(int r)
SparseBlock
sort
in class SparseBlock
r
- row index starting at 0public double get(int r, int c)
SparseBlock
get
in class SparseBlock
r
- row index starting at 0c
- column index starting at 0public SparseRow get(int r)
SparseBlock
get
in class SparseBlock
r
- row index starting at 0public int posFIndexLTE(int r, int c)
SparseBlock
posFIndexLTE
in class SparseBlock
r
- row index starting at 0c
- column index starting at 0public int posFIndexGTE(int r, int c)
SparseBlock
posFIndexGTE
in class SparseBlock
r
- row index starting at 0c
- column index starting at 0public int posFIndexGT(int r, int c)
SparseBlock
posFIndexGT
in class SparseBlock
r
- row index starting at 0c
- column index starting at 0public Iterator<IJV> getIterator()
SparseBlock
getIterator
in class SparseBlock
public Iterator<IJV> getIterator(int ru)
SparseBlock
getIterator
in class SparseBlock
ru
- exclusive upper row index starting at 0public Iterator<IJV> getIterator(int rl, int ru)
SparseBlock
getIterator
in class SparseBlock
rl
- inclusive lower row index starting at 0ru
- exclusive upper row index starting at 0public String toString()
toString
in class SparseBlock
public int[] rowIndexes()
public int[] indexes()
public double[] values()
Copyright © 2018 The Apache Software Foundation. All rights reserved.