84 CustomOrder<Dim_, Index_, Float_> runner(num_dim, num_obs, batches, output, *builder, options.
num_neighbors, options.
order.data(), options.
mass_cap, options.
num_threads);
89 AutomaticOrder<Dim_, Index_, Float_> runner(num_dim, num_obs, batches, output, *builder, options.
num_neighbors, options.
reference_policy, options.
mass_cap, options.
num_threads);
96 CustomOrder<Dim_, Index_, Float_> runner(num_dim, num_obs, batches, output, *builder, options.
num_neighbors, trivial_order.data(), options.
mass_cap, options.
num_threads);
149 auto stats = internal::compute(num_dim, num_obs, batches, output, options);
150 internal::restore_order(num_dim, stats.merge_order, num_obs, output);
177 std::vector<const Float_*> batches;
178 batches.reserve(num_obs.size());
179 for (
auto n : num_obs) {
180 batches.push_back(input);
181 input += n * num_dim;
183 return compute(num_dim, num_obs, batches, output, options);
209 const size_t nbatches = (num_obs ?
static_cast<size_t>(*std::max_element(batch, batch + num_obs)) + 1 : 0);
210 std::vector<size_t> sizes(nbatches);
211 for (
size_t o = 0; o < num_obs; ++o) {
217 bool already_sorted =
true;
218 for (
size_t o = 1; o < num_obs; ++o) {
219 if (batch[o] < batch[o-1]) {
220 already_sorted =
false;
224 if (already_sorted) {
225 return compute(num_dim, sizes, input, output, options);
228 size_t accumulated = 0;
229 std::vector<size_t> offsets(nbatches);
230 for (
size_t b = 0; b < nbatches; ++b) {
231 offsets[b] = accumulated;
232 accumulated += sizes[b];
236 std::vector<Float_> tmp(num_dim * num_obs);
237 std::vector<const Float_*> ptrs(nbatches);
238 for (
size_t b = 0; b < nbatches; ++b) {
239 ptrs[b] = tmp.data() + offsets[b] * num_dim;
242 for (
size_t o = 0; o < num_obs; ++o) {
243 auto current = input + o * num_dim;
244 auto& offset = offsets[batch[o]];
245 auto destination = tmp.data() + num_dim * offset;
246 std::copy_n(current, num_dim, destination);
250 auto stats = internal::compute(num_dim, sizes, ptrs, output, options);
251 internal::restore_order(num_dim, stats.merge_order, sizes, batch, output);