public abstract class SparseBlock extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
SparseBlock.Type |
Modifier and Type | Field and Description |
---|---|
protected static int |
INIT_CAPACITY |
protected static double |
RESIZE_FACTOR1 |
protected static double |
RESIZE_FACTOR2 |
Constructor and Description |
---|
SparseBlock() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
add(int r,
int c,
double v)
Add a value to a matrix cell (r,c).
|
abstract void |
allocate(int r)
Allocate the underlying data structure holding non-zero values
of row r if necessary.
|
abstract void |
allocate(int r,
int nnz)
Allocate the underlying data structure holding non-zero values
of row r if necessary, w/ given size.
|
abstract 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.
|
abstract void |
append(int r,
int c,
double v)
Append a value to the end of the physical representation.
|
abstract boolean |
checkValidity(int rlen,
int clen,
long nnz,
boolean strict)
Validate the correctness of the internal data structures of the different
sparse block implementations.
|
abstract void |
compact(int r)
Re-allocate physical row if physical size exceeds
logical size plus resize factor.
|
abstract void |
deleteIndexRange(int r,
int cl,
int cu)
Deletes all non-zero values of the given column range [cl,cu) in row r.
|
abstract SparseRow |
get(int r)
Get values of row r in the format of a sparse row.
|
abstract 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).
|
abstract int[] |
indexes(int r)
Get the sorted array of column indexes of all non-zero entries in
row r.
|
boolean |
isAligned(int r,
SparseBlock that)
Indicates if all non-zero values of row r are aligned with
the same row of the given second sparse block instance, which
can be exploited for more efficient operations.
|
boolean |
isAligned(SparseBlock that)
Indicates if all non-zero values are aligned with the given
second sparse block instance, which can be exploited for
more efficient operations.
|
abstract boolean |
isAllocated(int r)
Indicates if the underlying data structure for a given row
is already allocated.
|
abstract boolean |
isContiguous()
Indicates if the underlying data structures returned by values
and indexes are contiguous arrays, which can be exploited for
more efficient operations.
|
abstract boolean |
isEmpty(int r)
Get information if row r is empty, i.e., does not contain non-zero
values.
|
abstract boolean |
isThreadSafe()
Indicates if the underlying implementation allows thread-safe row
updates if concurrent threads update disjoint rows.
|
abstract int |
numRows()
Get the number of rows in the sparse block.
|
abstract int |
pos(int r)
Get the starting position of row r in the indexes/values arrays returned
by indexes(r) and values(r).
|
abstract int |
posFIndexGT(int r,
int c)
Get position of first column index greater than column c in row r.
|
abstract int |
posFIndexGTE(int r,
int c)
Get position of first column index greater than or equal column c
in row r.
|
abstract int |
posFIndexLTE(int r,
int c)
Get position of first column index lower than or equal column c
in row r.
|
abstract void |
reset()
Clears the sparse block by deleting non-zero values.
|
abstract void |
reset(int ennz,
int maxnnz)
Clears the sparse block by deleting non-zero values.
|
abstract void |
reset(int r,
int ennz,
int maxnnz)
Clears row r of the sparse block by deleting non-zero values.
|
abstract boolean |
set(int r,
int c,
double v)
Set the value of a matrix cell (r,c).
|
abstract void |
set(int r,
SparseRow row,
boolean deep)
Set the values of row r to the given sparse row.
|
abstract 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.
|
abstract 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.
|
abstract long |
size()
Get the number of non-zero values in the sparse block.
|
abstract int |
size(int r)
Get the number of non-zero values in row r.
|
abstract long |
size(int rl,
int ru)
Get the number of non-zeros values in the row range
of [rl, ru).
|
abstract 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);
|
abstract void |
sort()
Sort all non-zero value/index pairs of the sparse block by row
and column index.
|
abstract void |
sort(int r)
Sort all non-zero value/index pairs of row r column index.
|
abstract String |
toString() |
abstract double[] |
values(int r)
Get the array of all non-zero entries in row r, sorted by their column
indexes.
|
protected static final int INIT_CAPACITY
protected static final double RESIZE_FACTOR1
protected static final double RESIZE_FACTOR2
public abstract void allocate(int r)
r
- row indexpublic abstract void allocate(int r, int nnz)
r
- row indexnnz
- number of non-zerospublic abstract void allocate(int r, int ennz, int maxnnz)
r
- row indexennz
- estimated non-zerosmaxnnz
- max non-zerospublic abstract void compact(int r)
r
- row indexpublic abstract int numRows()
public abstract boolean isThreadSafe()
public abstract boolean isContiguous()
public boolean isAligned(SparseBlock that)
that
- sparse blockpublic boolean isAligned(int r, SparseBlock that)
r
- row index starting at 0that
- sparse blockpublic abstract boolean isAllocated(int r)
r
- row indexpublic abstract void reset()
public abstract void reset(int ennz, int maxnnz)
ennz
- estimated non-zerosmaxnnz
- max non-zerospublic abstract void reset(int r, int ennz, int maxnnz)
r
- row indexennz
- estimated non-zerosmaxnnz
- max non-zerospublic abstract long size()
public abstract int size(int r)
r
- row index starting at 0public abstract long size(int rl, int ru)
rl
- row lower indexru
- row upper indexpublic abstract long size(int rl, int ru, int cl, int cu)
rl
- row lower indexru
- row upper indexcl
- column lower indexcu
- column upper indexpublic abstract boolean isEmpty(int r)
r
- row index starting at 0public abstract boolean checkValidity(int rlen, int clen, long nnz, boolean strict)
rlen
- number of rowsclen
- number of columnsnnz
- number of non zerosstrict
- enforce optional propertiespublic abstract int[] indexes(int r)
r
- row index starting at 0public abstract double[] values(int r)
r
- row index starting at 0public abstract int pos(int r)
r
- row index starting at 0public abstract boolean set(int r, int c, double v)
r
- row index starting at 0c
- column index starting at 0v
- zero or non-zero valuepublic abstract void set(int r, SparseRow row, boolean deep)
r
- row index starting at 0row
- sparse rowdeep
- indicator to create deep copy of sparse rowpublic abstract boolean add(int r, int c, double v)
r
- row index starting at 0c
- column index starting at 0v
- zero or non-zero valuepublic abstract void append(int r, int c, double v)
r
- row index starting at 0c
- column index starting at 0v
- zero or non-zero valuepublic abstract void setIndexRange(int r, int cl, int cu, double[] v, int vix, int vlen)
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 abstract void setIndexRange(int r, int cl, int cu, double[] v, int[] vix, int vpos, int vlen)
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 abstract void deleteIndexRange(int r, int cl, int cu)
r
- row index starting at 0cl
- lower column index starting at 0cu
- upper column index starting at 0public abstract void sort()
public abstract void sort(int r)
r
- row index starting at 0public abstract double get(int r, int c)
r
- row index starting at 0c
- column index starting at 0public abstract SparseRow get(int r)
r
- row index starting at 0public abstract int posFIndexLTE(int r, int c)
r
- row index starting at 0c
- column index starting at 0public abstract int posFIndexGTE(int r, int c)
r
- row index starting at 0c
- column index starting at 0public abstract int posFIndexGT(int r, int c)
r
- row index starting at 0c
- column index starting at 0public Iterator<IJV> getIterator()
public Iterator<IJV> getIterator(int ru)
ru
- exclusive upper row index starting at 0public Iterator<IJV> getIterator(int rl, int ru)
rl
- inclusive lower row index starting at 0ru
- exclusive upper row index starting at 0Copyright © 2018 The Apache Software Foundation. All rights reserved.