|
| | FragmentedSparseMatrix (const Index_ nrow, const Index_ ncol, ValueVectorStorage_ values, IndexVectorStorage_ indices, const bool row_sparse, const FragmentedSparseMatrixOptions &options) |
| |
| 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 (const bool) const |
| |
| std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense (const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const |
| |
| std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense (const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Index_ block_start, const Index_ block_length, const Options &opt) const |
| |
| std::unique_ptr< OracularDenseExtractor< Value_, Index_ > > | dense (const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
| |
| std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse (const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const |
| |
| std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse (const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Index_ block_start, const Index_ block_length, const Options &opt) const |
| |
| std::unique_ptr< OracularSparseExtractor< Value_, Index_ > > | sparse (const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
| |
template<typename Value_, typename Index_, class ValueVectorStorage_, class IndexVectorStorage_>
class tatami::FragmentedSparseMatrix< Value_, Index_, ValueVectorStorage_, IndexVectorStorage_ >
Fragmented sparse matrix representation.
In a fragmented sparse matrix, each element of the primary dimension has its own vector of indices and data values. This differs from a compressed sparse matrix (see CompressedSparseMatrix) where the index/value vectors are concatenated across all elements. For row sparse matrices, the rows are the primary dimension, while for column sparse matrices, the columns are the primary dimension. This representation is equivalent to SciPy's list-of-lists sparse matrix (Python), or SparseArray's SVT_SparseMatrix class (R/Bioconductor).
- Template Parameters
-
| Value_ | Type of the matrix values. |
| Index_ | Type of the row/column indices. |
| ValueVectorStorage_ | Vector class used to store the matrix value vectors. Methods should be available for size(), begin(), end() and []. Each inner vector should also have methods for size(), begin(), end() and []. If a method is available for data() that returns a const Value_*, it will also be used. The inner vector does not necessarily have to contain Value_, as long as the type is convertible to Value_. |
| IndexVectorStorage_ | Vector class used to store the row/column indices internally. Methods should be available for size(), begin(), end() and []. Each inner vector should also have methods for size(), begin(), end() and []. If a method is available for data() that returns a const Index*, it will also be used. The inner vector does not necessarily have to contain Index_, as long as the type is convertible to Index_. |
template<typename Value_ , typename Index_ , class ValueVectorStorage_ , class IndexVectorStorage_ >
- Returns
- Number of rows.
It is expected that the number of rows can be represented by a std::size_t without overflow, even if Index_ is of a larger size. This is implied by the fact that MyopicDenseExtractor::fetch() and friends accept a pointer for their buffer arguments; the length of the array referenced by these pointers (possibly equal to the number of rows) must fit in a std::size_t.
Implements tatami::Matrix< Value_, Index_ >.
template<typename Value_ , typename Index_ , class ValueVectorStorage_ , class IndexVectorStorage_ >
- Returns
- Number of columns.
It is expected that the number of columns can be represented by a std::size_t without overflow, even if Index_ is of a larger size. This is implied by the fact that MyopicDenseExtractor::fetch() and friends accept a pointer for their buffer arguments; the length of the array referenced by these pointers (possibly equal to the number of rows) must fit in a std::size_t.
Implements tatami::Matrix< Value_, Index_ >.
template<typename Value_ , typename Index_ , class ValueVectorStorage_ , class IndexVectorStorage_ >
- Returns
- Approximate proportion of the matrix that is sparse.
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_ >.
template<typename Value_ , typename Index_ , class ValueVectorStorage_ , class IndexVectorStorage_ >
The return value of this method is the (approximate) 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.)
- Returns
- Approximate proportion of the matrix that prefers row-level access.
Implements tatami::Matrix< Value_, Index_ >.
template<typename Value_ , typename Index_ , class ValueVectorStorage_ , class IndexVectorStorage_ >
The return value 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.
- Parameters
-
| row | Row access if true, column access otherwise. |
- Returns
- Whether this matrix's
tatami::Extractor classes make use of oracle predictions for row (if row = true) or column access (otherwise).
Implements tatami::Matrix< Value_, Index_ >.
template<typename Value_ , typename Index_ , class ValueVectorStorage_ , class IndexVectorStorage_ >
Create an oracle-aware extractor that retrieves a contiguous block of the non-target dimension in dense form.
- Parameters
-
| 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. This should be non-negative and less than the respective number of columns/rows. (For a matrix with zero columns/rows, block_start may also be zero.) |
| block_length | Number of columns (if row = true) or rows (otherwise) in the block. This should be non-negative and block_start + block_length should be no greater than the number of columns/rows. |
| opt | Options for extraction. |
- Returns
- Object for extracting a contiguous block from each row (if
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_ >.
template<typename Value_ , typename Index_ , class ValueVectorStorage_ , class IndexVectorStorage_ >
Create an oracle-aware extractor that retrieves a contiguous block of the non-target dimension in sparse form.
- Parameters
-
| 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. This should be non-negative and less than the respective number of columns/rows. (For a matrix with zero columns/rows, block_start may also be zero.) |
| block_length | Number of columns (if row = true) or rows (otherwise) in the block. This should be non-negative and block_start + block_length should be no greater than the number of columns/rows. |
| opt | Options for extraction. |
- Returns
- Object for extracting a contiguous block from each row (if
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_ >.