1#ifndef TATAMI_TEST_DEFINE_DIMENSION_PART_HPP
2#define TATAMI_TEST_DEFINE_DIMENSION_PART_HPP
11#include "sanisizer/sanisizer.hpp"
40template<
typename Index_>
43 const double relative_start,
44 const double relative_length
47 return std::pair<Index_, Index_>(0, 0);
52 Index_ actual_start = std::min(extent - 1,
static_cast<Index_
>(std::round(relative_start * extent)));
53 Index_ actual_end = std::min(extent,
static_cast<Index_
>(std::round((relative_start + relative_length) * extent)));
54 return std::pair<Index_, Index_>(actual_start, actual_end - actual_start);
73template<
typename Value_,
typename Index_>
77 const double relative_start,
78 const double relative_length
80 const Index_ nsecondary = (use_row ? matrix.
ncol() : matrix.
nrow());
101template<
typename Index_>
103 auto ptr =
new std::vector<Index_>;
108 const Index_ max = start + length;
111 if (seed.has_value()) {
118 ptr->push_back(start);
119 std::uniform_real_distribution udist;
120 for (Index_ i = start + 1; i < max; ++i) {
121 if (udist(rng) < probability) {
125 if (ptr->back() !=
static_cast<Index_
>(max - 1)) {
126 ptr->push_back(max - 1);
148template<
typename Index_>
151 const double relative_start,
152 const double relative_length,
153 const double probability,
154 const std::optional<SeedType>& seed
178template<
typename Value_,
typename Index_>
182 const double relative_start,
183 const double relative_length,
184 const double probability,
185 const std::optional<SeedType>& seed
187 const Index_ nsecondary = (use_row ? matrix.
ncol() : matrix.
nrow());
195template<
typename Index_>
206template<
typename Value_,
typename Index_>
208 const Index_ nsecondary = (use_row ? matrix.
ncol() : matrix.
nrow());
210 (start < nsecondary || (nsecondary == 0 && start == 0)) &&
212 && sanisizer::is_less_than_or_equal(length, nsecondary - start);
215template<
typename Value_,
typename Index_>
221 const auto num_indices = indices_ptr->size();
222 if (num_indices == 0) {
226 auto previous = indices_ptr->front();
231 for (I<
decltype(num_indices)> i = 1; i < num_indices; ++i) {
232 if ((*indices_ptr)[i] <= previous) {
235 previous = (*indices_ptr)[i];
237 const Index_ nsecondary = (use_row ? matrix.
ncol() : matrix.
nrow());
238 return indices_ptr->back() < nsecondary;
virtual Index_ ncol() const=0
virtual Index_ nrow() const=0
Utilities for testing tatami libraries.
Definition create_seed.hpp:17
SeedType create_seed(Args_ &&... args)
Definition create_seed.hpp:93
std::mt19937_64 RngEngine
Definition utils.hpp:26
RngEngine::result_type SeedType
Definition utils.hpp:31
tatami::VectorPtr< Index_ > define_non_target_indices(const Index_ start, const Index_ length, const double probability, const std::optional< SeedType > &seed)
Definition define_non_target_part.hpp:102
std::pair< Index_, Index_ > define_non_target_block(const Index_ extent, const double relative_start, const double relative_length)
Definition define_non_target_part.hpp:41
std::shared_ptr< const std::vector< Index_ > > VectorPtr