|
| | DelayedUnaryIsometricOperation (std::shared_ptr< const Matrix< InputValue_, Index_ > > matrix, std::shared_ptr< const Helper_ > helper) |
| |
| 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 row) const |
| |
| std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > | dense (const bool row, const Options &opt) const |
| |
| std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > | dense (const bool row, const Index_ block_start, const Index_ block_length, const Options &opt) const |
| |
| std::unique_ptr< MyopicDenseExtractor< OutputValue_, Index_ > > | dense (const bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
| |
| std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > | sparse (const bool row, const Options &opt) const |
| |
| std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > | sparse (const bool row, const Index_ block_start, const Index_ block_length, const Options &opt) const |
| |
| std::unique_ptr< MyopicSparseExtractor< OutputValue_, Index_ > > | sparse (const bool row, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
| |
| std::unique_ptr< OracularDenseExtractor< OutputValue_, Index_ > > | dense (const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const |
| |
| std::unique_ptr< OracularDenseExtractor< OutputValue_, 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< OutputValue_, Index_ > > | dense (const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
| |
| std::unique_ptr< OracularSparseExtractor< OutputValue_, Index_ > > | sparse (const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, const Options &opt) const |
| |
| std::unique_ptr< OracularSparseExtractor< OutputValue_, 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< OutputValue_, Index_ > > | sparse (const bool row, std::shared_ptr< const Oracle< Index_ > > oracle, VectorPtr< Index_ > indices_ptr, const Options &opt) const |
| |
template<typename OutputValue_, typename InputValue_, typename Index_, class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
class tatami::DelayedUnaryIsometricOperation< OutputValue_, InputValue_, Index_, Helper_ >
Delayed isometric operation on a single matrix.
Implements any operation that preserves the shape of the matrix and operates on each matrix value independently. This operation is "delayed" in that it is only evaluated during data extraction, e.g., with MyopicDenseExtractor::fetch() or friends. We only consider "unary" operations that involve a single Matrix - see DelayedBinaryIsometricOperation for operations between two Matrix instances.
This class is inspired by the DelayedUnaryIsoOp classes from the DelayedArray Bioconductor package.
- Template Parameters
-
| OutputValue_ | Type of the result of the operation. |
| InputValue_ | Type of the value of the input matrix. |
| Index_ | Integer type for the row/column indices. |
| Helper_ | Helper class implementing the operation of interest, providing the same methods as DelayedUnaryIsometricOperationHelper. |
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
- 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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
- 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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
- 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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
Create an extractor that retrieves the full extent 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. |
| opt | Options for extraction. |
- Returns
- Object for extracting 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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
Create an 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. |
| 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 be non-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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
Create an extractor that retrieves the full extent 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. |
| opt | Options for extraction. |
- Returns
- Object for extracting each row (if
row = true) or columns (otherwise) in sparse form. This should not outlive the parent Matrix from which it was created.
Implements tatami::Matrix< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
Create an 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. |
| 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 be non-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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
Create an oracle-aware extractor that retrieves the full extent 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). |
| opt | Options for extraction. |
- Returns
- Object for extracting each row (if
row = true) or columns (otherwise) in dense form. This should not outlive the parent Matrix from which it was created.
Implements tatami::Matrix< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
Create an oracle-aware extractor that retrieves the full extent 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). |
| opt | Options for extraction. |
- Returns
- Object for extracting each row (if
row = true) or columns (otherwise) in sparse form. This should not outlive the parent Matrix from which it was created.
Implements tatami::Matrix< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
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< OutputValue_, Index_ >.
template<typename OutputValue_ , typename InputValue_ , typename Index_ , class Helper_ = DelayedUnaryIsometricOperationHelper<OutputValue_, InputValue_, Index_>>
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< OutputValue_, Index_ >.