tatami
C++ API for different matrix representations
|
Compressed sparse matrix representation. More...
#include <CompressedSparseMatrix.hpp>
Public Member Functions | |
CompressedSparseMatrix (Index_ nrow, Index_ ncol, ValueStorage_ values, IndexStorage_ indices, PointerStorage_ pointers, bool csr, bool check=true) | |
Index_ | nrow () const |
Index_ | ncol () const |
bool | is_sparse () const |
double | is_sparse_proportion () const |
bool | prefer_rows () const |
double | prefer_rows_proportion () const |
bool | uses_oracle (bool) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense (bool row, const Options &) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense (bool row, Index_ block_start, Index_ block_end, const Options &) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense (bool row, VectorPtr< Index_ > indices_ptr, const Options &) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse (bool row, const Options &opt) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse (bool row, Index_ block_start, Index_ block_end, const Options &opt) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse (bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense (bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense (bool row, std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_end, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense (bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > my_indices_ptr, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse (bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse (bool row, std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_end, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse (bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > my_indices_ptr, const Options &opt) const |
Public Member Functions inherited from tatami::Matrix< Value_, Index_ > | |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_row (const Options &opt) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_row (Index_ block_start, Index_ block_length, const Options &opt) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_row (VectorPtr< Index_ > indices_ptr, const Options &opt) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_row (std::vector< Index_ > indices, const Options &opt) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_row () const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_row (Index_ block_start, Index_ block_length) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_row (VectorPtr< Index_ > indices_ptr) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_row (std::vector< Index_ > indices) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_row (std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_row (std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_row (std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_row (std::shared_ptr< const Oracle< Index_ > > oracle, std::vector< Index_ > indices, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_row (std::shared_ptr< const Oracle< Index_ > > oracle) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_row (std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_row (std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_row (std::shared_ptr< const Oracle< Index_ > > oracle, std::vector< Index_ > indices) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_column (const Options &opt) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_column (Index_ block_start, Index_ block_length, const Options &opt) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_column (VectorPtr< Index_ > indices_ptr, const Options &opt) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_column (std::vector< Index_ > indices, const Options &opt) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_column () const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_column (Index_ block_start, Index_ block_length) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_column (VectorPtr< Index_ > indices_ptr) const |
std::unique_ptr< MyopicDenseExtractor< Value_, Index_ > > | dense_column (std::vector< Index_ > indices) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_column (std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_column (std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_column (std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_column (std::shared_ptr< const Oracle< Index_ > > oracle, std::vector< Index_ > indices, const Options &opt) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_column (std::shared_ptr< const Oracle< Index_ > > oracle) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_column (std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_column (std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr) const |
std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense_column (std::shared_ptr< const Oracle< Index_ > > oracle, std::vector< Index_ > indices) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_row (const Options &opt) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_row (Index_ block_start, Index_ block_length, const Options &opt) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_row (VectorPtr< Index_ > indices_ptr, const Options &opt) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_row (std::vector< Index_ > indices, const Options &opt) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_row () const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_row (Index_ block_start, Index_ block_length) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_row (VectorPtr< Index_ > indices_ptr) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_row (std::vector< Index_ > indices) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_row (std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_row (std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_row (std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_row (std::shared_ptr< const Oracle< Index_ > > oracle, std::vector< Index_ > indices, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_row (std::shared_ptr< const Oracle< Index_ > > oracle) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_row (std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_row (std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_row (std::shared_ptr< const Oracle< Index_ > > oracle, std::vector< Index_ > indices) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_column (const Options &opt) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_column (Index_ block_start, Index_ block_length, const Options &opt) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_column (VectorPtr< Index_ > indices_ptr, const Options &opt) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_column (std::vector< Index_ > indices, const Options &opt) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_column () const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_column (Index_ block_start, Index_ block_length) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_column (VectorPtr< Index_ > indices_ptr) const |
std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > | sparse_column (std::vector< Index_ > indices) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_column (std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_column (std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_column (std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_column (std::shared_ptr< const Oracle< Index_ > > oracle, std::vector< Index_ > indices, const Options &opt) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_column (std::shared_ptr< const Oracle< Index_ > > oracle) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_column (std::shared_ptr< const Oracle< Index_ > > oracle, Index_ block_start, Index_ block_length) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_column (std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr) const |
std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse_column (std::shared_ptr< const Oracle< Index_ > > oracle, std::vector< Index_ > indices) const |
Additional Inherited Members | |
Public Types inherited from tatami::Matrix< Value_, Index_ > | |
typedef Value_ | value_type |
typedef Index_ | index_type |
Compressed sparse matrix representation.
Value_ | Type of the matrix values. |
Index_ | Type of the row/column indices. |
ValueStorage_ | Vector class used to store the matrix values internally. This does not necessarily have to contain Value_ , as long as the type is convertible to Value_ . Methods should be available for size() , begin() , end() and [] . If a method is available for data() that returns a const Value_* , it will also be used. |
IndexStorage_ | Vector class used to store the row/column indices internally. This does not necessarily have to contain Index_ , as long as the type is convertible to Index_ . Methods should be available for size() , begin() , end() and [] . If a method is available for data() that returns a const Index_* , it will also be used. |
PointerStorage_ | Vector class used to store the column/row index pointers. Methods should be available for size() , begin() , end() and [] . |
|
inline |
nrow | Number of rows. |
ncol | Number of columns. |
values | Vector of non-zero elements. |
indices | Vector of row indices (if csr = false ) or column indices (if csr = true ) for the non-zero elements. |
pointers | Vector of index pointers. |
csr | Whether this is a compressed sparse row representation. |
check | Should the input vectors be checked for validity? |
If check=true
, the constructor will check that values
and indices
have the same length, equal to the number of structural non-zero elements; pointers
has length equal to the number of rows (if csr = true
) or columns (otherwise) plus one; pointers
is non-decreasing with first and last values set to 0 and the number of structural non-zeroes, respectively; indices
is strictly increasing within each interval defined by successive elements of pointers
; and all values of indices
are non-negative and less than the number of columns (if csr = true
) or rows (otherwise).
|
inlinevirtual |
Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
This can be used to choose between dense and sparse outputs.
Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
This is defined as the proportion of matrix elements that lie within sparse submatrices. It is intended for use in Matrix
representations that consist of combinations of multiple submatrices (e.g., DelayedBind
), allowing them to derive a suitable value for is_sparse()
based on whether most of its submatrices are sparse. (A more granular approach would be to report the density of structural non-zero elements, but this may not be known by all representations at construction time.)
Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
true
, row-wise extraction is preferred; if false
, column-wise extraction is preferred. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
This is defined as the proportion of matrix elements that lie within submatrices that prefer row-level access. It is useful for determining the return value of prefer_rows()
in combined matrices consisting of both row- and column-preferred submatrices. In such cases, the net preference can be determined based on the combined size of the submatrices for each preference. (A more granular approach would be to report the iteration cost on each dimension, but this is difficult to estimate.)
Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
row | Row access if true , column access otherwise. |
tatami::Extractor
classes make use of oracle predictions for row (if row = true
) or column access (otherwise).The output of this method indicates whether callers should construct an oracle for use in ExtractorBase::set_oracle()
. If false
, callers should not bother to pass an oracle as it will be ignored.
Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an extractor that retrieves the full extent of the non-target dimension in dense form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
opt | Options for extraction. |
row = true
) or column (otherwise) in dense form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an extractor that retrieves a contiguous block of the non-target dimension in dense form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
block_start | Index of the column (if row = true ) or row (otherwise) at the start of the block. |
block_length | Number of columns (if row = true ) or rows (otherwise) in the block. |
opt | Options for extraction. |
row = true
) or column (otherwise) in dense form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an extractor that retrieves an indexed subset of the non-target dimension in dense form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
indices_ptr | Pointer to a vector of sorted and unique column indices (if row = true ) or row indices (otherwise). This should be non-NULL. |
opt | Options for extraction. |
row = true
) or column (otherwise) in dense form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an extractor that retrieves the full extent of the non-target dimension in sparse form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
opt | Options for extraction. |
row = true
) or columns (otherwise) in sparse form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an extractor that retrieves a contiguous block of the non-target dimension in sparse form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
block_start | Index of the column (if row = true ) or row (otherwise) at the start of the block. |
block_length | Number of columns (if row = true ) or rows (otherwise) in the block. |
opt | Options for extraction. |
row = true
) or column (otherwise) in sparse form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an extractor that retrieves an indexed subset of the non-target dimension in sparse form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
indices_ptr | Pointer to a vector of sorted and unique column indices (if row = true ) or row indices (otherwise). This should be non-NULL. |
opt | Options for extraction. |
row = true
) or column (otherwise) in sparse form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an oracle-aware extractor that retrieves the full extent of the non-target dimension in dense form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
oracle | An oracle supplying predictions of the next requested row (if row = true ) or column (otherwise). |
opt | Options for extraction. |
row = true)
or columns (otherwise) in dense form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an oracle-aware extractor that retrieves a contiguous block of the non-target dimension in dense form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
oracle | An oracle supplying predictions of the next requested row (if row = true ) or column (otherwise). |
block_start | Index of the column (if row = true ) or row (otherwise) at the start of the block. |
block_length | Number of columns (if row = true ) or rows (otherwise) in the block. |
opt | Options for extraction. |
row = true
) or column (otherwise) in dense form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an oracle-aware extractor that retrieves an indexed subset of the non-target dimension in dense form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
oracle | An oracle supplying predictions of the next requested row (if row = true ) or column (otherwise). |
indices_ptr | Pointer to a vector of sorted and unique column indices (if row = true ) or row indices (otherwise). This should not be NULL. |
opt | Options for extraction. |
row = true
) or column (otherwise) in dense form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an oracle-aware extractor that retrieves the full extent of the non-target dimension in sparse form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
oracle | An oracle supplying predictions of the next requested row (if row = true ) or column (otherwise). |
opt | Options for extraction. |
row = true)
or columns (otherwise) in sparse form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an oracle-aware extractor that retrieves a contiguous block of the non-target dimension in sparse form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
oracle | An oracle supplying predictions of the next requested row (if row = true ) or column (otherwise). |
block_start | Index of the column (if row = true ) or row (otherwise) at the start of the block. |
block_length | Number of columns (if row = true ) or rows (otherwise) in the block. |
opt | Options for extraction. |
row = true
) or column (otherwise) in dense form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.
|
inlinevirtual |
Create an oracle-aware extractor that retrieves an indexed subset of the non-target dimension in sparse form.
row | Whether to create a row-wise extractor, i.e., the rows are the target dimension. |
oracle | An oracle supplying predictions of the next requested row (if row = true ) or column (otherwise). |
indices_ptr | Pointer to a vector of sorted and unique column indices (if row = true ) or row indices (otherwise). This should not be NULL. |
opt | Options for extraction. |
row = true
) or column (otherwise) in sparse form. This should not outlive the parent Matrix
from which it was created. Implements tatami::Matrix< Value_, Index_ >.