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::MockSimpleDenseChunk Class Reference

Mock a simple 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_ 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_ > &non_target_indices, Workspace &work, value_type *output, size_t stride) const
 

Static Public Attributes

static constexpr bool use_subset = false
 

Detailed Description

Mock a simple dense chunk for a CustomDenseChunkedMatrix.

Mock a simple dense chunk for use inside a CustomDenseChunkedMatrix. Each chunk should represent a 2-dimensional array of numeric values. The interface is "simple" as any extraction of data from the chunk retrieves the full extent of the target dimension, with no attempt at optimization if only a subset of dimension elements are of interest.

Member Typedef Documentation

◆ value_type

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

Member Function Documentation

◆ extract() [1/2]

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

Extract all elements of the target dimension into an output buffer. For each element, this method will 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.
non_target_startIndex of the start of the continguous 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 * P, where P is the number of rows (if row = true) or columns (otherwise) in this chunk.
strideDistance between corresponding values from adjacent elements of the target dimension when they are being stored in output. This is guaranteed to be greater than or equal to non_target_length.

If row = true, we would extract data for all rows and a block of columns [non_target_start, non_target_start + non_target_length); conversely, if row = false, we would extract data for all columns and a block of rows. 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]. The stride option allows concatenation of multiple chunks into a single contiguous array for easier fetching in the CustomDenseChunkedMatrix.

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/2]

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

Extract all elements of the target dimension into an output buffer. For each element, this method will 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.
non_target_indicesIndexed subset of 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 * P, where P is the number of rows (if row = true) or columns (otherwise) in this chunk.
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 all rows and a subset of columns in non_target_indices; conversely, if row = false, we would extract data for all columns and a subset of rows. 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]. The stride option allows concatenation of multiple chunks into a single contiguous array for easier fetching in the CustomDenseChunkedMatrix.

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::MockSimpleDenseChunk::use_subset = false
staticconstexpr

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


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