tatami_chunked
Helpers to create custom chunked tatami matrices
|
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 |
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.
Type of the value stored in this chunk. Implementations can use any numeric type.
|
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.
Index_ | Integer type for the row/column indices of the CustomDenseChunkedMatrix . |
row | Whether to extract rows from the chunk, i.e., the rows are the target dimension. | |
non_target_start | Index 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_length | Length 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. | |
work | Re-usable workspace for extraction from one or more chunks. | |
[out] | output | Pointer 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. |
stride | Distance 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.
|
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.
Index_ | Integer type for the row/column indices of the CustomDenseChunkedMatrix . |
row | Whether to extract rows from the chunk, i.e., the rows are the target dimension. | |
non_target_indices | Indexed 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. | |
work | Re-usable workspace for extraction from one or more chunks. | |
[out] | output | Pointer 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. |
stride | Distance 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.
Whether to extract a subset of elements on the target dimension. This should be set to false
, otherwise a MockSubsettedDenseChunk
is expected.