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

Mock a simple sparse chunk for a CustomSparseChunkedMatrix. More...

#include <mock_sparse_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, const std::vector< value_type * > &output_values, const std::vector< Index_ * > &output_indices, Index_ *output_number, Index_ shift) const
 
template<typename Index_ >
void extract (bool row, const std::vector< Index_ > &non_target_indices, Workspace &work, const std::vector< value_type * > &output_values, const std::vector< Index_ * > &output_indices, Index_ *output_number, Index_ shift) const
 

Static Public Attributes

static constexpr bool use_subset = false
 

Detailed Description

Mock a simple sparse chunk for a CustomSparseChunkedMatrix.

Mock a simple sparse chunk for use inside a CustomSparseChunkedMatrix. Each chunk should represent a 2-dimensional array of numeric values. The interface is "simple" as extraction of any data involves realization of the entire chunk's contents along 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::MockSimpleSparseChunk::extract ( bool  row,
Index_  non_target_start,
Index_  non_target_length,
Workspace work,
const std::vector< value_type * > &  output_values,
const std::vector< Index_ * > &  output_indices,
Index_ output_number,
Index_  shift 
) const
inline

Extract all elements of the target dimension into output buffers. 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 CustomSparseChunkedMatrix.
Parameters
rowWhether to extract rows from the chunk, i.e., the rows are the target dimension.
non_target_startIndex of the start of a 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]output_valuesVector of pointers in which to store the values of non-zero elements. This has length equal to the extent of the target dimension for this chunk. Each pointer corresponds to an element of the target dimension and refers to an array of length no less than the extent of the non-target dimension of the chunk. Alternatively, this vector may be empty, in which case no values should be stored.
[out]output_indicesVector of vectors in which to store the indices of the non-zero elements along the non-target dimension. This has length equal to the extent of the target dimension for this chunk. Each pointer corresponds to an element of the target dimension and refers to an array of length no less than the extent of the non-target dimension of the chunk. Alternatively, this vector may be empty, in which case no indices should be stored.
[in,out]output_numberPointer to an array of length equal to the extent of the target dimension. Each entry i specifies the number of non-zero elements that are already present in output_values[i] and output_indices[i].
shiftShift to be added to the chunk's reported indices when storing them in output_indices.

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. Given a target dimension element p, the values of non-zero elements from the requested non-target block should be stored at output_values[p] + output_number[p]. The non-target indices for those non-zero elements should be increased by shift and stored at output_indices[p] + output_number[p] in ascending order. output_number[p] should then be increased by the number of non-zero entries stored in this manner. This layout allows concatenation of multiple sparse chunks into a single set of vectors for easier fetching in the CustomSparseChunkedMatrix.

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::MockSimpleSparseChunk::extract ( bool  row,
const std::vector< Index_ > &  non_target_indices,
Workspace work,
const std::vector< value_type * > &  output_values,
const std::vector< Index_ * > &  output_indices,
Index_ output_number,
Index_  shift 
) const
inline

Extract all elements of the target dimension into output buffers. 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 CustomSparseChunkedMatrix.
Parameters
rowWhether to extract rows from the chunk, i.e., the rows are the target dimension.
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]output_valuesVector of pointers in which to store the values of non-zero elements. This has length equal to the extent of the target dimension for this chunk. Each pointer corresponds to an element of the target dimension and refers to an array of length no less than the extent of the non-target dimension of the chunk. Alternatively, this vector may be empty, in which case no values should be stored.
[out]output_indicesVector of vectors in which to store the indices of the non-zero elements along the non-target dimension. This has length equal to the extent of the target dimension for this chunk. Each pointer corresponds to an element of the target dimension and refers to an array of length no less than the extent of the non-target dimension of the chunk. Alternatively, this vector may be empty, in which case no indices should be stored.
[in,out]output_numberPointer to an array of length equal to the extent of the target dimension. Each entry i specifies the number of non-zero elements that are already present in output_values[i] and output_indices[i].
shiftShift to be added to the chunk's reported indices when storing them in output_indices.

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. Given a target dimension element p, the values of non-zero elements from the requested non-target subset should be stored at output_values[p] + output_number[p]. The non-target indices for those non-zero elements should be increased by shift and stored at output_indices[p] + output_number[p] in ascending order. output_number[p] should then be increased by the number of non-zero entries stored in this manner. This layout allows concatenation of multiple sparse chunks into a single set of vectors for easier fetching in the CustomSparseChunkedMatrix.

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

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


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