Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
Indexing.h File Reference

Helpers for converting between indexed maps and dense containers. More...

#include <map>
#include <vector>
#include <stdexcept>
#include "Matrix.h"
#include "Include.h"
#include "ObservableValue.h"
#include "BinnedObservableId.h"
Include dependency graph for Indexing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  UnzipResult1D< T, U >
 Result of converting a one-dimensional indexed map to dense vectors. More...
 
struct  UnzipResult2D< T >
 Result of converting a square indexed matrix to dense vectors. More...
 

Functions

template<typename T , typename U >
std::map< T, U > zip (const std::vector< T > &ids, const std::vector< U > &vals)
 Builds a map from parallel id and value vectors.
 
template<typename T >
std::map< T, std::map< T, double > > zip (const std::vector< T > &ids, const std::vector< std::vector< double > > &vals)
 Builds a square nested map from ids and a dense matrix.
 
UnzipResult1D< BinnedObservableId, double > flatten (std::map< ObservableId, std::vector< ObservableValue > > indexed)
 Flattens observable values into binned observable ids and values.
 
template<typename T >
std::map< T, std::map< T, double > > zip (const std::vector< T > &ids, const RealMatrix &vals)
 Builds a square nested map from ids and a RealMatrix.
 
template<typename T , typename U >
UnzipResult1D< T, U > unzip (const std::map< T, U > &indexed)
 Splits a map into parallel id and value vectors.
 
template<typename T >
UnzipResult2D< Tunzip (const std::map< T, std::map< T, double > > &indexed)
 Splits a nested square map into ids and a dense matrix.
 

Detailed Description

Helpers for converting between indexed maps and dense containers.

The utilities in this file are used to keep the association between logical ids and numerical values while switching between STL maps, vectors, and matrix representations.

Definition in file Indexing.h.

Function Documentation

◆ flatten()

UnzipResult1D< BinnedObservableId, double > flatten ( std::map< ObservableId, std::vector< ObservableValue > >  indexed)
inline

Flattens observable values into binned observable ids and values.

Each input observable can contain several binned values. The output contains one BinnedObservableId per value, using (0, 0) as the bin range when an observable value has no explicit bin.

Parameters
indexedMap from observable id to one or more observable values.
Returns
Parallel vectors of binned ids and numerical values.

Definition at line 118 of file Indexing.h.

◆ unzip() [1/2]

template<typename T >
UnzipResult2D< T > unzip ( const std::map< T, std::map< T, double > > &  indexed)

Splits a nested square map into ids and a dense matrix.

Template Parameters
TRow and column id type.
Parameters
indexedNested square map.
Returns
Id vector and dense matrix values in map iteration order.

Definition at line 198 of file Indexing.h.

◆ unzip() [2/2]

template<typename T , typename U >
UnzipResult1D< T, U > unzip ( const std::map< T, U > &  indexed)

Splits a map into parallel id and value vectors.

Template Parameters
TId type.
UValue type.
Parameters
indexedInput map.
Returns
Parallel vectors in map iteration order.

Definition at line 176 of file Indexing.h.

◆ zip() [1/3]

template<typename T >
std::map< T, std::map< T, double > > zip ( const std::vector< T > &  ids,
const RealMatrix vals 
)

Builds a square nested map from ids and a RealMatrix.

Template Parameters
TRow and column id type.
Parameters
idsRow and column ids.
valsDense square matrix.
Returns
Nested map such that out[row_id][col_id] stores the corresponding matrix entry.
Exceptions
std::invalid_argumentif vals is not square with respect to ids.

Definition at line 149 of file Indexing.h.

◆ zip() [2/3]

template<typename T >
std::map< T, std::map< T, double > > zip ( const std::vector< T > &  ids,
const std::vector< std::vector< double > > &  vals 
)

Builds a square nested map from ids and a dense matrix.

Template Parameters
TRow and column id type.
Parameters
idsRow and column ids.
valsDense square matrix represented as nested vectors.
Returns
Nested map such that out[row_id][col_id] stores the corresponding matrix entry.
Exceptions
std::invalid_argumentif vals is empty, non-square with respect to ids, or has incompatible dimensions.

Definition at line 88 of file Indexing.h.

◆ zip() [3/3]

template<typename T , typename U >
std::map< T, U > zip ( const std::vector< T > &  ids,
const std::vector< U > &  vals 
)

Builds a map from parallel id and value vectors.

Template Parameters
TId type.
UValue type.
Parameters
idsOrdered ids.
valsValues associated with ids.
Returns
Map associating each id with the value at the same position.
Exceptions
std::invalid_argumentif the two vectors do not have the same size.

Definition at line 61 of file Indexing.h.