tatami_chunked
Helpers to create custom chunked tatami matrices
Loading...
Searching...
No Matches
ChunkDimensionStats.hpp
1#ifndef TATAMI_CHUNKED_CHUNK_DIMENSION_STATS_HPP
2#define TATAMI_CHUNKED_CHUNK_DIMENSION_STATS_HPP
3
4namespace tatami_chunked {
5
16template<typename Index_>
17Index_ integer_ceil(Index_ left, Index_ right) {
18 if (right) {
19 return left / right + (left % right > 0); // avoids overflow.
20 } else {
21 return 0;
22 }
23}
24
34template<typename Index_>
75
84template<typename Index_>
85Index_ get_chunk_length(const ChunkDimensionStats<Index_>& stats, Index_ i) {
86 return (i + 1 == stats.num_chunks ? stats.last_chunk_length : stats.chunk_length);
87}
88
89}
90
91#endif
Methods to handle chunked tatami matrices.
Definition ChunkDimensionStats.hpp:4
Index_ get_chunk_length(const ChunkDimensionStats< Index_ > &stats, Index_ i)
Definition ChunkDimensionStats.hpp:85
Index_ integer_ceil(Index_ left, Index_ right)
Definition ChunkDimensionStats.hpp:17
Statistics for regular chunks along a dimension.
Definition ChunkDimensionStats.hpp:35
Index_ chunk_length
Definition ChunkDimensionStats.hpp:61
ChunkDimensionStats(Index_ dimension_extent, Index_ chunk_length)
Definition ChunkDimensionStats.hpp:40
ChunkDimensionStats()
Definition ChunkDimensionStats.hpp:50
Index_ num_chunks
Definition ChunkDimensionStats.hpp:66
Index_ dimension_extent
Definition ChunkDimensionStats.hpp:55
Index_ last_chunk_length
Definition ChunkDimensionStats.hpp:73