ATLAS Offline Software
Classes | Typedefs | Functions
GSFUtils Namespace Reference

Dynamic array fullfilling alignment requirements. More...

Classes

struct  AlignedDynArray
 A wrapper around std::aligned_alloc. More...
 
struct  Component1D
 struct representing 1D component More...
 
struct  Merge
 struct representing an array or the merges. More...
 

Typedefs

using Component1DArray = AlignedDynArray< Component1D, GSFConstants::alignment >
 
using MergeArray = std::vector< Merge >
 

Functions

MergeArray findMerges (Component1DArray &&componentsIn, const int reducedSize)
 Return which components need to be merged. More...
 

Detailed Description

Dynamic array fullfilling alignment requirements.

Author
Anthony Morley, Christos Anastopoulos

Typedef Documentation

◆ Component1DArray

Definition at line 37 of file KLGaussianMixtureReduction.h.

◆ MergeArray

using GSFUtils::MergeArray = typedef std::vector<Merge>

Definition at line 47 of file KLGaussianMixtureReduction.h.

Function Documentation

◆ findMerges()

MergeArray GSFUtils::findMerges ( Component1DArray &&  componentsIn,
const int  reducedSize 
)

Return which components need to be merged.

Find the order in which the components need to be merged.

Returns an MergeArray with the merges (To,From). The index of the merged From is always smaller than the To (RHS is smaller than LHS)

Component1DArray : Array of simplified 1D components used to calculate the merge order using q/p.

reducedSize The size we want to reduce the mixture to. Needs to be smaller than the numComponents of the componentsIn array

Definition at line 305 of file KLGaussianMixtureReduction.cxx.

306 {
307  const int n = componentsIn.size();
308  int nn = n * (n - 1) / 2;
309  int nnpadded = vAlgs::numPadded<STRIDEForKL>(nn);
310  Component1DArray components(std::move(componentsIn));
311  // Based on the inputSize n allocate enough space for the pairwise distances
313  // initial distance calculation
314  calculateAllDistances(components.buffer(), distances.buffer(), n);
315  // As we merge keep track where things moved
317  std::iota(mergingIndex.begin(), mergingIndex.end(), 0);
318  // Result to be returned
319  MergeArray result{};
320  result.reserve(n);
321  int numberOfComponentsLeft = n;
322  // merge loop
323  while (numberOfComponentsLeft > reducedSize) {
324  // find pair with minimum distance
325  const int minIndex = KLReductionFMV::vIdxOfMin(distances.buffer(), nnpadded);
326  const triangularToIJ conversion = convert(minIndex);
327  int minTo = conversion.I;
328  int minFrom = conversion.J;
329  // This is the convention we had so retained.
330  if (mergingIndex[minTo] < mergingIndex[minFrom]) {
331  std::swap(minTo, minFrom);
332  }
333  // prepare what to return
334  const int miniToreturn = mergingIndex[minTo];
335  const int minjToreturn = mergingIndex[minFrom];
336  result.push_back({ miniToreturn, minjToreturn });
337  // Combine
338  combine(components[minTo], components[minFrom]);
339  // update distances
340  numberOfComponentsLeft = updateDistances(components.buffer(),
341  mergingIndex.buffer(),
342  distances.buffer(),
343  minFrom,
344  minTo,
345  numberOfComponentsLeft);
346 
347  // number of remaining distances padded
348  nn = (numberOfComponentsLeft - 1) * numberOfComponentsLeft / 2;
349  nnpadded = numDistances(nn, distances.buffer());
350  } // end of merge while
351  return result;
352 }
get_generator_info.result
result
Definition: get_generator_info.py:21
KLReductionFMV::vIdxOfMin
int vIdxOfMin(const float *distancesIn, int n)
Definition: KLGaussianMixtureReduction.cxx:37
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
GSFUtils::MergeArray
std::vector< Merge > MergeArray
Definition: KLGaussianMixtureReduction.h:47
GSFUtils::AlignedDynArray::size
size_type size() const noexcept
number of elements/size
beamspotman.n
n
Definition: beamspotman.py:729
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
TMVAToMVAUtils::convert
std::unique_ptr< MVAUtils::BDT > convert(TMVA::MethodBDT *bdt, bool isRegression=true, bool useYesNoLeaf=false)
Definition: TMVAToMVAUtils.h:114
FlavorTagInference::combine
size_t combine(size_t lhs, size_t rhs)
Definition: hash.h:21
GSFUtils::AlignedDynArray
A wrapper around std::aligned_alloc.
Definition: AlignedDynArray.h:30