66 CustomOrder<Dim_, Index_, Float_> runner(num_dim, num_obs, batches, output, *builder, options.
num_neighbors, options.
order, options.
mass_cap, options.
num_threads);
71 AutomaticOrder<Dim_, Index_, Float_> runner(num_dim, num_obs, batches, output, *builder, options.
num_neighbors, options.
reference_policy, options.
mass_cap, options.
num_threads);
78 CustomOrder<Dim_, Index_, Float_> runner(num_dim, num_obs, batches, output, *builder, options.
num_neighbors, trivial_order, options.
mass_cap, options.
num_threads);
131 auto stats = internal::compute(num_dim, num_obs, batches, output, options);
132 internal::restore_order(num_dim, stats.merge_order, num_obs, output);
159 std::vector<const Float_*> batches;
160 batches.reserve(num_obs.size());
161 for (
auto n : num_obs) {
162 batches.push_back(input);
163 input += n * num_dim;
165 return compute(num_dim, num_obs, batches, output, options);
191 const size_t nbatches = (num_obs ?
static_cast<size_t>(*std::max_element(batch, batch + num_obs)) + 1 : 0);
192 std::vector<size_t> sizes(nbatches);
193 for (
size_t o = 0; o < num_obs; ++o) {
199 bool already_sorted =
true;
200 for (
size_t o = 1; o < num_obs; ++o) {
201 if (batch[o] < batch[o-1]) {
202 already_sorted =
false;
206 if (already_sorted) {
207 return compute(num_dim, sizes, input, output, options);
210 size_t accumulated = 0;
211 std::vector<size_t> offsets(nbatches);
212 for (
size_t b = 0; b < nbatches; ++b) {
213 offsets[b] = accumulated;
214 accumulated += sizes[b];
218 std::vector<Float_> tmp(num_dim * num_obs);
219 std::vector<const Float_*> ptrs(nbatches);
220 for (
size_t b = 0; b < nbatches; ++b) {
221 ptrs[b] = tmp.data() + offsets[b] * num_dim;
224 for (
size_t o = 0; o < num_obs; ++o) {
225 auto current = input + o * num_dim;
226 auto& offset = offsets[batch[o]];
227 auto destination = tmp.data() + num_dim * offset;
228 std::copy_n(current, num_dim, destination);
232 auto stats = internal::compute(num_dim, sizes, ptrs, output, options);
233 internal::restore_order(num_dim, stats.merge_order, sizes, batch, output);