tatami_chunked
Helpers to create custom chunked tatami matrices
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
tatami_chunked::MockSubsettedDenseChunk Class Reference

Mock a subsettable dense chunk for a CustomDenseChunkedMatrix. More...

#include <mock_dense_chunk.hpp>

Classes

struct  Workspace
 

Public Types

typedef double value_type
 

Public Member Functions

template<typename Index_ >
void extract (bool row, Index_ target_start, Index_ target_length, Index_ non_target_start, Index_ non_target_length, Workspace &work, value_type *output, size_t stride) const
 
template<typename Index_ >
void extract (bool row, Index_ target_start, Index_ target_length, const std::vector< Index_ > &non_target_indices, Workspace &work, value_type *output, size_t stride) const
 
template<typename Index_ >
void extract (bool row, const std::vector< Index_ > &target_indices, Index_ non_target_start, Index_ non_target_length, Workspace &work, value_type *output, size_t stride) const
 
template<typename Index_ >
void extract (bool row, const std::vector< Index_ > &target_indices, const std::vector< Index_ > &non_target_indices, Workspace &work, value_type *output, size_t stride) const
 

Static Public Attributes

static constexpr bool use_subset = true
 

Detailed Description

Mock a subsettable dense chunk for a CustomDenseChunkedMatrix.

Mock a subsettable dense chunk for use inside a CustomDenseChunkedMatrix. Each chunk should represent a (possible compressed) 2-dimensional array of numeric values. The interface is smarter as it only extracts elements of interest along the target dimension. The elements of interest may be either a contiguous block or a indexed subset, as predicted for each chunk from the OracularSubsettedSlabCache. This provides some opportunities for optimization if the chunk supports partial reads.

Member Typedef Documentation

◆ value_type

Type of the value stored in this chunk. Implementations can use any numeric type.

Member Function Documentation

◆ extract() [1/4]

template<typename Index_ >
void tatami_chunked::MockSubsettedDenseChunk::extract ( bool  row,
Index_  target_start,
Index_  target_length,
Index_  non_target_start,
Index_  non_target_length,
Workspace work,
value_type output,
size_t  stride 
) const
inline

Extract a contiguous block of the target dimension into an output buffer. For each element, this method will only extract a contiguous block of the non-target dimension.

Template Parameters
Index_Integer type for the row/column indices of the CustomDenseChunkedMatrix.
Parameters
rowWhether to extract rows from the chunk, i.e., the rows are the target dimension.
target_startIndex of the start of the contiguous block of the target dimension to be extracted. If row = true, this is the first row, otherwise it is the first column.
target_lengthLength of the contiguous block of the target dimension to be extracted. If row = true, this is the number of rows, otherwise it is the number of columns. This is guaranteed to be positive.
non_target_startIndex of the start of the contiguous block of the non-target dimension to be extracted. If row = true, this is the first column, otherwise it is the first row.
non_target_lengthLength of the contiguous block of the non-target dimension to be extracted. If row = true, this is the number of columns, otherwise it is the number of rows. This is guaranteed to be positive.
workRe-usable workspace for extraction from one or more chunks.
[out]outputPointer to an output array of length no less than stride * target_length + non_target_length.
strideDistance between corresponding values from consecutive target dimension elements when stored in output. This is guaranteed to be greater than or equal to non_target_length.

If row = true, we would extract a block of rows [target_start, target_start + length) and a block of columns [non_target_start, non_target_start + non_target_length); conversely, if row = false, we would extract a block of columns as the target and the block of rows as the secondary. For a target dimension index target_start + p and non-target dimension index non_target_start + i, the value from the chunk should be stored in output[p * stride + i]. This layout allows concatenation of multiple chunks into a single contiguous array for easier fetching in the CustomChunkedMatrix.

Note that implementions of this method do not need to have the exact same template arguments as shown here, as long as the types can be deduced.

◆ extract() [2/4]

template<typename Index_ >
void tatami_chunked::MockSubsettedDenseChunk::extract ( bool  row,
Index_  target_start,
Index_  target_length,
const std::vector< Index_ > &  non_target_indices,
Workspace work,
value_type output,
size_t  stride 
) const
inline

Extract a contiguous block of the target dimension into an output buffer. For each element, this method will only extract an indexed subset of the non-target dimension.

Template Parameters
Index_Integer type for the row/column indices of the CustomDenseChunkedMatrix.
Parameters
rowWhether to extract rows from the chunk, i.e., the rows are the target dimension.
target_startIndex of the first element on the target dimension to be extracted. If row = true, this is the first row, otherwise it is the first column.
target_lengthNumber of elements on the target dimension to be extracted. If row = true, this is the number of rows, otherwise it is the number of columns. This is guaranteed to be positive.
non_target_indicesIndices of the elements on the non-target dimension to be extracted. If row = true, these are column indices, otherwise these are row indices. This is guaranteed to be non-empty with unique and sorted indices.
workRe-usable workspace for extraction from one or more chunks.
[out]outputPointer to an output array of length no less than stride * (target_start + target_length).
strideDistance between corresponding values from consecutive target dimension elements when stored in output. This is guaranteed to be greater than or equal to non_target_indices.size().

If row = true, we would extract a block of rows [target_start, target_start + length) and a subset of columns in non_target_indices; conversely, if row = false, we would extract a block of columns as the target and a subset of rows instead. For a target dimension index p and non-target dimension index non_target_indices[i], the value from the chunk should be stored in output[p * stride + i]. This layout allows concatenation of multiple chunks into a single contiguous array for easier fetching in the CustomChunkedMatrix.

Note that implementions of this method do not need to have the exact same template arguments as shown here, as long as the types can be deduced.

◆ extract() [3/4]

template<typename Index_ >
void tatami_chunked::MockSubsettedDenseChunk::extract ( bool  row,
const std::vector< Index_ > &  target_indices,
Index_  non_target_start,
Index_  non_target_length,
Workspace work,
value_type output,
size_t  stride 
) const
inline

Extract an indexed subset of the target dimension into an output buffer. For each element, this method will only extract a contiguous block of the non-target dimension.

Template Parameters
Index_Integer type for the row/column indices of the CustomDenseChunkedMatrix.
Parameters
rowWhether to extract rows from the chunk, i.e., the rows are the target dimension.
target_indicesIndices of the elements of the target dimension to be extracted. If row = true, these are row indices, otherwise these are column indices. This is guaranteed to be non-empty with unique and sorted indices.
non_target_startIndex of the start of the contiguous block of the non-target dimension to be extracted. If row = true, this is the first column, otherwise it is the first row.
non_target_lengthLength of the contiguous block of the non-target dimension to be extracted. If row = true, this is the number of columns, otherwise it is the number of rows. This is guaranteed to be positive.
workRe-usable workspace for extraction from one or more chunks.
[out]outputPointer to an output array of length no less than stride * (target_indices.back() + 1).
strideDistance between corresponding values from consecutive target dimension elements when stored in output. This is guaranteed to be greater than or equal to non_target_length.

If row = true, we would extract a subset of rows in target_indices and a block of columns [non_target_start, non_target_start + non_target_length), conversely, if row = false, we would extract a subset of columns as the target and the block of rows as the secondary. For a target dimension index p and non-target dimension index non_target_start + i, the value from the chunk should be stored in output[p * stride + i]. This layout allows concatenation of multiple chunks into a single contiguous array for easier fetching in the CustomChunkedMatrix.

Note that implementions of this method do not need to have the exact same template arguments as shown here, as long as the types can be deduced.

◆ extract() [4/4]

template<typename Index_ >
void tatami_chunked::MockSubsettedDenseChunk::extract ( bool  row,
const std::vector< Index_ > &  target_indices,
const std::vector< Index_ > &  non_target_indices,
Workspace work,
value_type output,
size_t  stride 
) const
inline

Extract an indexed subset of the target dimension into an output buffer. For each element, this method will only extract an indexed subset of the non-target dimension.

Template Parameters
Index_Integer type for the row/column indices of the CustomDenseChunkedMatrix.
Parameters
rowWhether to extract rows from the chunk, i.e., the rows are the target dimension.
target_indicesIndices of the elements on the target dimension to be extracted. If row = true, these are row indices, otherwise these are column indices. This is guaranteed to be non-empty with unique and sorted indices.
non_target_indicesIndices of the elements on the non-target dimension to be extracted. If row = true, these are column indices, otherwise these are row indices. This is guaranteed to be non-empty with unique and sorted indices.
workRe-usable workspace for extraction from one or more chunks.
[out]outputPointer to an output array of length no less than stride * (target_indices.back() + 1).
strideDistance between corresponding values from consecutive target dimension elements when stored in output. This is guaranteed to be greater than or equal to non_target_indices.size().

If row = true, we would extract a subset of rows in target_indices and a subset columns in non_target_indices. conversely, if row = false, we would extract a subset of columns as the target and the subset of rows as the secondary. For a target dimension index p and non-target dimension index non_target_indices[i], the value from the chunk should be stored in output[p * stride + i]. This layout allows concatenation of multiple chunks into a single contiguous array for easier fetching in the CustomChunkedMatrix.

Note that implementions of this method do not need to have the exact same template arguments as shown here, as long as the types can be deduced.

Member Data Documentation

◆ use_subset

constexpr bool tatami_chunked::MockSubsettedDenseChunk::use_subset = true
staticconstexpr

Whether to extract a subset of elements on the target dimension. This should be set to false, otherwise a MockSimpleDenseChunk is expected.


The documentation for this class was generated from the following file: