|
| | DelayedCast (std::shared_ptr< const Matrix< ValueIn_, IndexIn_ > > matrix) |
| |
| IndexOut_ | nrow () const |
| |
| IndexOut_ | 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 row) const |
| |
| std::unique_ptr< MyopicDenseExtractor< ValueOut_, IndexOut_ > > | dense (const bool row, const Options &opt) const |
| |
| std::unique_ptr< MyopicDenseExtractor< ValueOut_, IndexOut_ > > | dense (const bool row, const IndexOut_ block_start, const IndexOut_ block_length, const Options &opt) const |
| |
| std::unique_ptr< MyopicDenseExtractor< ValueOut_, IndexOut_ > > | dense (const bool row, VectorPtr< IndexOut_ > indices_my_matrix, const Options &opt) const |
| |
| std::unique_ptr< MyopicSparseExtractor< ValueOut_, IndexOut_ > > | sparse (const bool row, const Options &opt) const |
| |
| std::unique_ptr< MyopicSparseExtractor< ValueOut_, IndexOut_ > > | sparse (const bool row, const IndexOut_ block_start, const IndexOut_ block_length, const Options &opt) const |
| |
| std::unique_ptr< MyopicSparseExtractor< ValueOut_, IndexOut_ > > | sparse (const bool row, VectorPtr< IndexOut_ > indices_my_matrix, const Options &opt) const |
| |
| std::unique_ptr< OracularDenseExtractor< ValueOut_, IndexOut_ > > | dense (const bool row, std::shared_ptr< const Oracle< IndexOut_ > > oracle, const Options &opt) const |
| |
| std::unique_ptr< OracularDenseExtractor< ValueOut_, IndexOut_ > > | dense (const bool row, std::shared_ptr< const Oracle< IndexOut_ > > oracle, const IndexOut_ block_start, const IndexOut_ block_length, const Options &opt) const |
| |
| std::unique_ptr< OracularDenseExtractor< ValueOut_, IndexOut_ > > | dense (const bool row, std::shared_ptr< const Oracle< IndexOut_ > > oracle, VectorPtr< IndexOut_ > indices_my_matrix, const Options &opt) const |
| |
| std::unique_ptr< OracularSparseExtractor< ValueOut_, IndexOut_ > > | sparse (const bool row, std::shared_ptr< const Oracle< IndexOut_ > > oracle, const Options &opt) const |
| |
| std::unique_ptr< OracularSparseExtractor< ValueOut_, IndexOut_ > > | sparse (const bool row, std::shared_ptr< const Oracle< IndexOut_ > > oracle, const IndexOut_ block_start, const IndexOut_ block_length, const Options &opt) const |
| |
| std::unique_ptr< OracularSparseExtractor< ValueOut_, IndexOut_ > > | sparse (const bool row, std::shared_ptr< const Oracle< IndexOut_ > > oracle, VectorPtr< IndexOut_ > indices_my_matrix, const Options &opt) const |
| |
template<typename ValueOut_, typename IndexOut_, typename ValueIn_, typename IndexIn_>
class tatami::DelayedCast< ValueOut_, IndexOut_, ValueIn_, IndexIn_ >
Recast a Matrix to a different interface type.
This performs a delayed cast from one interface type to another. It is useful as a compatibility layer between functions that require Matrix objects of different types. Casting is achieved by extracting the requested row/column from the input Matrix and transforming it to the output types. Note that this is only done per row/column - the entirety of the original matrix is not copied to the new type.
- Template Parameters
-
| ValueOut_ | Data type to cast to. |
| IndexOut_ | Index type to cast to. |
| ValueIn_ | Data type to cast from. |
| IndexIn_ | Index type to cast from. |
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
- 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< ValueOut_, IndexOut_ >.
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
- 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< ValueOut_, IndexOut_ >.
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
| double tatami::DelayedCast< ValueOut_, IndexOut_, ValueIn_, IndexIn_ >::is_sparse_proportion |
( |
| ) |
const |
|
inlinevirtual |
- 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< ValueOut_, IndexOut_ >.
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
| double tatami::DelayedCast< ValueOut_, IndexOut_, ValueIn_, IndexIn_ >::prefer_rows_proportion |
( |
| ) |
const |
|
inlinevirtual |
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< ValueOut_, IndexOut_ >.
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
| bool tatami::DelayedCast< ValueOut_, IndexOut_, ValueIn_, IndexIn_ >::uses_oracle |
( |
const bool | row | ) |
const |
|
inlinevirtual |
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< ValueOut_, IndexOut_ >.
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
| std::unique_ptr< MyopicDenseExtractor< ValueOut_, IndexOut_ > > tatami::DelayedCast< ValueOut_, IndexOut_, ValueIn_, IndexIn_ >::dense |
( |
const bool | row, |
|
|
const IndexOut_ | block_start, |
|
|
const IndexOut_ | block_length, |
|
|
const Options & | opt ) const |
|
inlinevirtual |
Create an 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. |
| 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< ValueOut_, IndexOut_ >.
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
| std::unique_ptr< MyopicSparseExtractor< ValueOut_, IndexOut_ > > tatami::DelayedCast< ValueOut_, IndexOut_, ValueIn_, IndexIn_ >::sparse |
( |
const bool | row, |
|
|
const IndexOut_ | block_start, |
|
|
const IndexOut_ | block_length, |
|
|
const Options & | opt ) const |
|
inlinevirtual |
Create an 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. |
| 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 sparse form. This should not outlive the parent Matrix from which it was created.
Implements tatami::Matrix< ValueOut_, IndexOut_ >.
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
| std::unique_ptr< OracularDenseExtractor< ValueOut_, IndexOut_ > > tatami::DelayedCast< ValueOut_, IndexOut_, ValueIn_, IndexIn_ >::dense |
( |
const bool | row, |
|
|
std::shared_ptr< const Oracle< IndexOut_ > > | oracle, |
|
|
const IndexOut_ | block_start, |
|
|
const IndexOut_ | block_length, |
|
|
const Options & | opt ) const |
|
inlinevirtual |
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< ValueOut_, IndexOut_ >.
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
Create an oracle-aware extractor that retrieves an indexed subset 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). |
| indices_ptr | Pointer to a vector of sorted and unique column indices (if row = true) or row indices (otherwise). Each entry should be non-negative and less than the respective number of columns/rows. This should not be NULL. |
| opt | Options for extraction. |
- Returns
- Object for extracting an indexed subset 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< ValueOut_, IndexOut_ >.
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
| std::unique_ptr< OracularSparseExtractor< ValueOut_, IndexOut_ > > tatami::DelayedCast< ValueOut_, IndexOut_, ValueIn_, IndexIn_ >::sparse |
( |
const bool | row, |
|
|
std::shared_ptr< const Oracle< IndexOut_ > > | oracle, |
|
|
const IndexOut_ | block_start, |
|
|
const IndexOut_ | block_length, |
|
|
const Options & | opt ) const |
|
inlinevirtual |
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< ValueOut_, IndexOut_ >.
template<typename ValueOut_ , typename IndexOut_ , typename ValueIn_ , typename IndexIn_ >
Create an oracle-aware extractor that retrieves an indexed subset 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). |
| indices_ptr | Pointer to a vector of sorted and unique column indices (if row = true) or row indices (otherwise). Each entry should be non-negative and less than the respective number of columns/rows. This should not be NULL. |
| opt | Options for extraction. |
- Returns
- Object for extracting an indexed subset from each row (if
row = true) or column (otherwise) in sparse form. This should not outlive the parent Matrix from which it was created.
Implements tatami::Matrix< ValueOut_, IndexOut_ >.