1#ifndef TATAMI_TEST_SIMULATE_COMPRESSED_SPARSE_HPP
2#define TATAMI_TEST_SIMULATE_COMPRESSED_SPARSE_HPP
8#include "sanisizer/sanisizer.hpp"
50template<
typename Value_,
typename Index_>
85template<
typename Value_,
typename Index_>
88 std::uniform_real_distribution<> nonzero(0.0, 1.0);
89 std::uniform_real_distribution<> unif(options.
lower, options.
upper);
92 output.
indptr.resize(sanisizer::sum<I<
decltype(output.
indptr.size())> >(primary, 1));
93 for (I<
decltype(primary)> p = 0; p < primary; ++p) {
94 auto idx = output.
indptr[p];
95 for (I<
decltype(secondary)> s = 0; s < secondary; ++s) {
96 if (nonzero(rng) < options.
density) {
97 output.
data.push_back(unif(rng));
98 output.
index.push_back(s);
102 output.
indptr[p + 1] = idx;
Utilities for testing tatami libraries.
Definition create_indexed_subset.hpp:16
std::mt19937_64 RngEngine
Definition utils.hpp:34
RngEngine::result_type SeedType
Definition utils.hpp:39
SimulateCompressedSparseResult< Value_, Index_ > simulate_compressed_sparse(const Index_ primary, const Index_ secondary, const SimulateCompressedSparseOptions &options)
Definition simulate_compressed_sparse.hpp:86
Options for simulate_compressed_sparse().
Definition simulate_compressed_sparse.hpp:22
double lower
Definition simulate_compressed_sparse.hpp:26
double upper
Definition simulate_compressed_sparse.hpp:31
SeedType seed
Definition simulate_compressed_sparse.hpp:41
double density
Definition simulate_compressed_sparse.hpp:36
Result of simulate_compressed_sparse().
Definition simulate_compressed_sparse.hpp:51
std::vector< std::size_t > indptr
Definition simulate_compressed_sparse.hpp:70
std::vector< Value_ > data
Definition simulate_compressed_sparse.hpp:56
std::vector< Index_ > index
Definition simulate_compressed_sparse.hpp:63