50template<
bool include_stat_,
typename Stat_,
typename Value_,
typename Index_,
typename Label_>
51Markers<include_stat_, Index_, Stat_> choose_raw(
56 const auto NC = matrix.
ncol();
57 auto group_sizes = tatami_stats::tabulate_groups(label, NC);
58 const auto ngroups = group_sizes.size();
60 const auto num_keep = get_num_keep<Index_>(ngroups, options.
number);
61 auto pqueues = sanisizer::create<std::vector<std::optional<PairwiseTopQueues<Stat_, Index_> > > >(options.
num_threads);
63 const auto num_used = scan_matrix<Stat_>(
65 sanisizer::cast<std::size_t>(ngroups),
69 [&]() -> PairwiseTopQueues<Stat_, Index_> {
70 PairwiseTopQueues<Stat_, Index_> output;
71 allocate_pairwise_queues(output, num_keep, ngroups, options.
keep_ties,
true);
75 [&](
const Index_ r,
const std::vector<Stat_>& medians, PairwiseTopQueues<Stat_, Index_>& curqueues) ->
void {
76 for (I<
decltype(ngroups)> g1 = 1; g1 < ngroups; ++g1) {
77 for (I<
decltype(ngroups)> g2 = 0; g2 < g1; ++g2) {
78 const auto delta = medians[g1] - medians[g2];
79 curqueues[g1][g2].emplace(delta, r);
80 curqueues[g2][g1].emplace(-delta, r);
85 [&](
const int t, PairwiseTopQueues<Stat_, Index_>& curqueues) ->
void {
86 pqueues[t] = std::move(curqueues);
92 pqueues.resize(num_used);
93 Markers<include_stat_, Index_, Stat_> output;
94 report_best_top_queues<include_stat_>(pqueues, ngroups, output);
125template<
typename Stat_ =
double,
typename Value_,
typename Index_,
typename Label_>
126std::vector<std::vector<std::vector<std::pair<Index_, Stat_> > > >
choose(
131 return choose_raw<true, Stat_>(matrix, label, options);
153template<
typename Stat_ =
double,
typename Value_,
typename Index_,
typename Label_>
159 return choose_raw<false, Stat_>(matrix, label, options);
std::vector< std::vector< std::vector< Index_ > > > choose_index(const tatami::Matrix< Value_, Index_ > &matrix, const Label_ *label, const ChooseOptions &options)
Definition choose.hpp:154
std::vector< std::vector< std::vector< std::pair< Index_, Stat_ > > > > choose(const tatami::Matrix< Value_, Index_ > &matrix, const Label_ *label, const ChooseOptions &options)
Definition choose.hpp:126