tatami_chunked
Helpers to create custom chunked tatami matrices
|
Mock a subsettable sparse chunk for a CustomSparseChunkedMatrix
.
More...
#include <mock_sparse_chunk.hpp>
Classes | |
struct | Workspace |
Public Types | |
typedef double | value_type |
Static Public Attributes | |
static constexpr bool | use_subset = true |
Mock a subsettable sparse chunk for a CustomSparseChunkedMatrix
.
Mock a subsettable sparse chunk for use inside a CustomSparseChunkedMatrix
. 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.
Type of the value stored in this chunk. Implementations can use any numeric type.
|
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.
Index_ | Integer type for the row/column indices of the CustomSparseChunkedMatrix . |
row | Whether to extract rows from the chunk, i.e., the rows are the target dimension. | |
target_start | Index of the start of a contiguous block of the target dimension to be extracted. If row = true , this is the first row, otherwise it is the first column. | |
target_length | Length 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_start | Index 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_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_values | Vector 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_indices | Vector 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_number | Pointer 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] . |
shift | Shift to be added to the chunk's reported indices when storing them in output_indices . |
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 from the target_*
arguments and the block of rows from the non_target_*
arguments. 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.
|
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.
Index_ | Integer type for the row/column indices of the CustomSparseChunkedMatrix . |
row | Whether to extract rows from the chunk, i.e., the rows are the target dimension. | |
target_start | Index of the start of a contiguous block of the target dimension to be extracted. If row = true , this is the first row, otherwise it is the first column. | |
target_length | Length 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_indices | Indices 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. | |
work | Re-usable workspace for extraction from one or more chunks. | |
[out] | output_values | Vector 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_indices | Vector 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_number | Pointer 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] . |
shift | Shift to be added to the chunk's reported indices when storing them in output_indices . |
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 from the target_*
arguments and a subset of rows from non_target_indices
. 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.
|
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.
Index_ | Integer type for the row/column indices of the CustomSparseChunkedMatrix . |
row | Whether to extract rows from the chunk, i.e., the rows are the target dimension. | |
target_indices | Indices 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_start | Index 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_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_values | Vector 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_indices | Vector 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_number | Pointer 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] . |
shift | Shift to be added to the chunk's reported indices when storing them in output_indices . |
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 from the target_*
arguments and the block of rows from the non_target_*
arguments. 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.
|
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.
Index_ | Integer type for the row/column indices of the CustomSparseChunkedMatrix . |
row | Whether to extract rows from the chunk, i.e., the rows are the target dimension. | |
target_indices | Indices 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_indices | Indices 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. | |
work | Re-usable workspace for extraction from one or more chunks. | |
[out] | output_values | Vector 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_indices | Vector 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_number | Pointer 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] . |
shift | Shift to be added to the chunk's reported indices when storing them in output_indices . |
If row = true
, we would extract a subset of rows in target_indices
and a subset of columns in non_target_indices
. conversely, if row = false
, we would extract a subset of columns in target_indices
and the subset of rows in non_target_indices
. 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.
Whether to extract a subset of elements on the target dimension. This should be set to true
, otherwise a MockSimpleSparseChunk
is expected.