Alexandria
2.18
Please provide a description of the project.
|
Classes | |
class | AdaptativeIntegration |
Class implementing the NumericalIntegrationScheme interface. More... | |
class | Cumulative |
Class for build cumulative from PDF and extract feature out of it. More... | |
class | DefaultMultiplication |
interface | Differentiable |
Interface representing a differentiable function. More... | |
interface | Function |
Interface class representing a function. More... | |
class | FunctionAdapter |
Adapt a std::function<double(double)> to the Function Interface. More... | |
interface | Integrable |
Interface representing an integrable function. More... | |
struct | InterpolationException |
class | ModeInfo |
Class for storing the information of a PDF mode. More... | |
interface | NumericalIntegrationScheme |
Interface class representing a numerical integration scheme. More... | |
class | Piecewise |
Represents a piecewise function. More... | |
class | Polynomial |
Represents a polynomial function. More... | |
class | SimpsonsRule |
Typedefs | |
typedef std::unique_ptr< Function >(* | MultiplyFunction) (const Function &, const Function &) |
Alias of a function which multiplies Function objects. More... | |
Enumerations | |
enum | InterpolationType { InterpolationType::LINEAR, InterpolationType::CUBIC_SPLINE } |
Enumeration of the different supported interpolation types. More... | |
Functions | |
ELEMENTS_API double | integrate (const Function &function, const double min, const double max, std::unique_ptr< NumericalIntegrationScheme > numericalIntegrationScheme=nullptr) |
ELEMENTS_API std::unique_ptr< Function > | multiply (const Function &f1, const Function &f2) |
ELEMENTS_API std::unique_ptr< Function > | interpolate (const std::vector< double > &x, const std::vector< double > &y, InterpolationType type, bool extrapolate=false) |
ELEMENTS_API std::unique_ptr< Function > | interpolate (const Euclid::XYDataset::XYDataset &dataset, InterpolationType type, bool extrapolate=false) |
double | derivative (const Function &f, const double x) |
double | derivative2nd (const Function &f, const double x) |
std::vector< ModeInfo > | extractNHighestModes (const XYDataset::XYDataset &pdf, double merge_ratio, size_t n) |
std::vector< ModeInfo > | extractNHighestModes (std::vector< double > &x_sampling, std::vector< double > &pdf_sampling, double merge_ratio, size_t n) |
std::vector< ModeInfo > | extractNBigestModes (const XYDataset::XYDataset &pdf, double merge_ratio, size_t n) |
std::vector< ModeInfo > | extractNBigestModes (std::vector< double > &x_sampling, std::vector< double > &pdf_sampling, double merge_ratio, size_t n) |
std::unique_ptr< Function > | multiplyPolynomials (const Function &f1, const Function &f2) |
Function for multiplying two Polynomials. It multiplies their coefficients. More... | |
std::unique_ptr< Function > | multiplyPiecewiseWithGeneric (const Function &f1, const Function &f2) |
std::vector< double > | overlappingKnots (const std::vector< double > &knots1, const std::vector< double > &knots2) |
Returns a vector of the overlapping knots from the given vectors. More... | |
std::unique_ptr< Function > | multiplyPiecewises (const Function &f1, const Function &f2) |
std::unique_ptr< Function > | linearInterpolation (const std::vector< double > &x, const std::vector< double > &y, bool extrapolate) |
Performs linear interpolation for the given set of data points. More... | |
std::unique_ptr< Function > | splineInterpolation (const std::vector< double > &x, const std::vector< double > &y, bool extrapolate) |
Performs cubic spline interpolation for the given set of data points. More... | |
static double | guess_h (double initial_h, double x) |
std::pair< std::vector< double >, std::vector< double > > | getXYs (const XYDataset::XYDataset &pdf) |
size_t | findMaximumIndex (const std::vector< double > &pdf) |
std::pair< size_t, size_t > | catchPeak (const std::vector< double > &pdf, size_t center_index, double merge_ratio) |
std::pair< double, double > | avgArea (std::pair< std::vector< double >, std::vector< double >> &pdf, size_t min_x, size_t max_x) |
double | getInterpolationAround (const std::pair< std::vector< double >, std::vector< double >> &pdf, size_t x_index) |
std::pair< std::vector< double >, std::vector< double > > | flatternPeak (const std::pair< std::vector< double >, std::vector< double >> &pdf, size_t min_x, size_t max_x, double value) |
typedef std::unique_ptr<Function>(* Euclid::MathUtils::MultiplyFunction) (const Function &, const Function &) |
Alias of a function which multiplies Function objects.
Definition at line 40 of file multiplication.h.
|
strong |
Enumeration of the different supported interpolation types.
Enumerator | |
---|---|
LINEAR | |
CUBIC_SPLINE |
Definition at line 41 of file interpolation.h.
std::pair<double, double> Euclid::MathUtils::avgArea | ( | std::pair< std::vector< double >, std::vector< double >> & | pdf, |
size_t | min_x, | ||
size_t | max_x | ||
) |
Definition at line 99 of file PdfModeExtraction.cpp.
References std::make_pair().
Referenced by extractNBigestModes(), and extractNHighestModes().
std::pair<size_t, size_t> Euclid::MathUtils::catchPeak | ( | const std::vector< double > & | pdf, |
size_t | center_index, | ||
double | merge_ratio | ||
) |
Definition at line 65 of file PdfModeExtraction.cpp.
References std::make_pair(), and std::vector< T >::size().
Referenced by extractNBigestModes(), and extractNHighestModes().
double Euclid::MathUtils::derivative | ( | const Function & | f, |
const double | x | ||
) |
Derivative using finite differences: \( f'(x) = \frac{f(x+h) - f(x)}{h} \)
f | The Function to derive |
x | The point where to do the derivation |
Definition at line 41 of file FiniteDifference.cpp.
References guess_h(), and std::sqrt().
double Euclid::MathUtils::derivative2nd | ( | const Function & | f, |
const double | x | ||
) |
Second derivative using finite differences: \( f''(x) = \frac{f(x+h) - 2f(x) + f(x - h)}{h^2} \)
f | The Function to derive |
x | The point where to do the derivation |
Definition at line 50 of file FiniteDifference.cpp.
References guess_h(), and std::sqrt().
std::vector< ModeInfo > Euclid::MathUtils::extractNBigestModes | ( | const XYDataset::XYDataset & | pdf, |
double | merge_ratio, | ||
size_t | n | ||
) |
Extract the n modes with biggest area in the provided pdf and compute for each of them the location of the mode and its area. A mode is discovered as the highest point of the pdf, then, on both sides, samples are added until the pdf starts to rise again. In order to avoid truncating the mode due to a noisy pdf it is possible to specify a merge_ratio. In this case the samples are added until their values is below the hight of the peak times the merge ratio, then additional point are added until the pdf rise again.
The sampling of the pdf to be analysed. | |
merge_ratio | The parameter for mode cutting. |
n | The (maximum) number of modes to be returned. |
Definition at line 238 of file PdfModeExtraction.cpp.
References getXYs().
std::vector< ModeInfo > Euclid::MathUtils::extractNBigestModes | ( | std::vector< double > & | x_sampling, |
std::vector< double > & | pdf_sampling, | ||
double | merge_ratio, | ||
size_t | n | ||
) |
Extract the n modes with biggest area in the provided pdf and compute for each of them the location of the mode and its area. A mode is discovered as the highest point of the pdf, then, on both sides, samples are added until the pdf starts to rise again. In order to avoid truncating the mode due to a noisy pdf it is possible to specify a merge_ratio. In this case the samples are added until their values is below the hight of the peak times the merge ratio, then additional point are added until the pdf rise again.
x_sampling | The horizontal sampling of the pdf to be analysed. |
pdf_sampling | The sampling of the pdf to be analysed. |
merge_ratio | The parameter for mode cutting. |
n | The (maximum) number of modes to be returned. |
Definition at line 197 of file PdfModeExtraction.cpp.
References avgArea(), catchPeak(), findMaximumIndex(), flatternPeak(), getInterpolationAround(), std::make_pair(), and std::vector< T >::size().
std::vector< ModeInfo > Euclid::MathUtils::extractNHighestModes | ( | const XYDataset::XYDataset & | pdf, |
double | merge_ratio, | ||
size_t | n | ||
) |
Extract the n highest modes in the provided pdf and compute for each of them the location of the mode and its area. A mode is discovered as the highest point of the pdf, then, on both sides, samples are added until the pdf starts to rise again. In order to avoid truncating the mode due to a noisy pdf it is possible to specify a merge_ratio. In this case the samples are added until their values is below the hight of the peak times the merge ratio, then additional point are added until the pdf rise again.
The sampling of the pdf to be analysed. | |
merge_ratio | The parameter for mode cutting. |
n | The (maximum) number of modes to be returned. |
Definition at line 192 of file PdfModeExtraction.cpp.
References getXYs().
std::vector< ModeInfo > Euclid::MathUtils::extractNHighestModes | ( | std::vector< double > & | x_sampling, |
std::vector< double > & | pdf_sampling, | ||
double | merge_ratio, | ||
size_t | n | ||
) |
Extract the n highest modes in the provided pdf and compute for each of them the location of the mode and its area. A mode is discovered as the highest point of the pdf, then, on both sides, samples are added until the pdf starts to rise again. In order to avoid truncating the mode due to a noisy pdf it is possible to specify a merge_ratio. In this case the samples are added until their values is below the hight of the peak times the merge ratio, then additional point are added until the pdf rise again.
x_sampling | The horizontal sampling of the pdf to be analysed. |
pdf_sampling | The sampling of the pdf to be analysed. |
merge_ratio | The parameter for mode cutting. |
n | The (maximum) number of modes to be returned. |
Definition at line 175 of file PdfModeExtraction.cpp.
References avgArea(), catchPeak(), findMaximumIndex(), flatternPeak(), getInterpolationAround(), and std::make_pair().
size_t Euclid::MathUtils::findMaximumIndex | ( | const std::vector< double > & | ) |
Definition at line 50 of file PdfModeExtraction.cpp.
References std::vector< T >::begin(), and std::vector< T >::end().
Referenced by extractNBigestModes(), and extractNHighestModes().
std::pair<std::vector<double>, std::vector<double> > Euclid::MathUtils::flatternPeak | ( | const std::pair< std::vector< double >, std::vector< double >> & | pdf, |
size_t | min_x, | ||
size_t | max_x, | ||
double | value | ||
) |
Definition at line 166 of file PdfModeExtraction.cpp.
References std::make_pair().
Referenced by extractNBigestModes(), and extractNHighestModes().
double Euclid::MathUtils::getInterpolationAround | ( | const std::pair< std::vector< double >, std::vector< double >> & | pdf, |
size_t | x_index | ||
) |
Definition at line 120 of file PdfModeExtraction.cpp.
Referenced by extractNBigestModes(), and extractNHighestModes().
std::pair<std::vector<double>, std::vector<double> > Euclid::MathUtils::getXYs | ( | const XYDataset::XYDataset & | ) |
Definition at line 36 of file PdfModeExtraction.cpp.
References Euclid::XYDataset::XYDataset::begin(), Euclid::XYDataset::XYDataset::end(), and std::make_pair().
Referenced by extractNBigestModes(), and extractNHighestModes().
|
static |
Definition at line 32 of file FiniteDifference.cpp.
References std::nextafter().
Referenced by derivative(), and derivative2nd().
double Euclid::MathUtils::integrate | ( | const Function & | function, |
const double | min, | ||
const double | max, | ||
std::unique_ptr< NumericalIntegrationScheme > | numericalIntegrationScheme = nullptr |
||
) |
Returns the integral of the given function inside the range [min,max]. This method will take advantage of Functions which also implement the Integrable interface. For other Function the integration will be delegated to the NumericalIntegrationScheme. Note that at the moment there is no default numerical implementation, so if the given function is not Integrable and no numerical integration scheme is provided an exception will be thrown.
function | The function to integrate |
min | The minimum range of the integration |
max | The maximum range of the integration |
numericalIntegrationScheme | The class in charge of the numerical integration (if the function do not implement the Integrable interface). |
Definition at line 33 of file function_tools.cpp.
References Euclid::MathUtils::Integrable::integrate().
Referenced by Euclid::PhysicsUtils::CosmologicalDistances::comovingDistance(), and Euclid::MathUtils::Piecewise::integrate().
std::unique_ptr< Function > Euclid::MathUtils::interpolate | ( | const Euclid::XYDataset::XYDataset & | dataset, |
InterpolationType | type, | ||
bool | extrapolate = false |
||
) |
Returns a Function which performs interpolation for the data points of the given dataset.
dataset | The dataset containing the data points |
type | The type of the interpolation to perform |
InterpolationException | if there are decreasing x values |
InterpolationException | if there are (X,Y) pairs with same X value but different Y value (step functions) |
Definition at line 91 of file interpolation.cpp.
References std::vector< T >::emplace_back(), interpolate(), std::vector< T >::reserve(), and Euclid::XYDataset::XYDataset::size().
std::unique_ptr< Function > Euclid::MathUtils::interpolate | ( | const std::vector< double > & | x, |
const std::vector< double > & | y, | ||
InterpolationType | type, | ||
bool | extrapolate = false |
||
) |
Returns a Function which performs interpolation for the given set of data points. Duplicate (x,y) pairs are ignored and treated as a single one.
x | The x values of the data points |
y | The y values of the data points |
type | The type of the interpolation to perform |
InterpolationException | if the x and y vectors do not have the same size |
InterpolationException | if there are decreasing x values |
InterpolationException | if there are (X,Y) pairs with same X value but different Y value (step functions) |
Definition at line 40 of file interpolation.cpp.
References std::vector< T >::emplace_back(), std::vector< T >::front(), LINEAR, linearInterpolation(), Euclid::Configuration::logger, std::vector< T >::reserve(), std::vector< T >::size(), splineInterpolation(), and Elements::Logging::warn().
Referenced by interpolate().
std::unique_ptr< Function > Euclid::MathUtils::linearInterpolation | ( | const std::vector< double > & | x, |
const std::vector< double > & | y, | ||
bool | extrapolate | ||
) |
Performs linear interpolation for the given set of data points.
Definition at line 34 of file linear.cpp.
References std::vector< T >::back(), std::vector< T >::front(), std::numeric_limits::lowest(), std::numeric_limits::max(), std::move(), std::vector< T >::push_back(), and std::vector< T >::size().
Referenced by interpolate().
std::unique_ptr< Function > Euclid::MathUtils::multiply | ( | const Function & | f1, |
const Function & | f2 | ||
) |
Returns a function which represents the multiplication of the two parameters. This method makes use of the multiplySpecificSpecificMap and multiplySpecificGenericMap maps for detecting efficient ways of multiplying the parameters.
f1 | The first function to multiply |
f2 | The second function to multiply |
Definition at line 63 of file function_tools.cpp.
References multiplySpecificGenericMap, and multiplySpecificSpecificMap.
Referenced by multiplyPiecewises(), and multiplyPiecewiseWithGeneric().
std::unique_ptr<Function> Euclid::MathUtils::multiplyPiecewises | ( | const Function & | f1, |
const Function & | f2 | ||
) |
Definition at line 92 of file multiplication.cpp.
References Euclid::MathUtils::Piecewise::getFunctions(), Euclid::MathUtils::Piecewise::getKnots(), multiply(), and overlappingKnots().
std::unique_ptr<Function> Euclid::MathUtils::multiplyPiecewiseWithGeneric | ( | const Function & | f1, |
const Function & | f2 | ||
) |
Function for multiplying a Piecewise with any other type. It multiplies each sub-function of the Piecewise with the other function.
Definition at line 52 of file multiplication.cpp.
References Euclid::MathUtils::Piecewise::getFunctions(), Euclid::MathUtils::Piecewise::getKnots(), multiply(), and std::vector< T >::push_back().
std::unique_ptr<Function> Euclid::MathUtils::multiplyPolynomials | ( | const Function & | f1, |
const Function & | f2 | ||
) |
Function for multiplying two Polynomials. It multiplies their coefficients.
Definition at line 38 of file multiplication.cpp.
References Euclid::MathUtils::Polynomial::getCoefficients(), and std::vector< T >::size().
std::vector<double> Euclid::MathUtils::overlappingKnots | ( | const std::vector< double > & | knots1, |
const std::vector< double > & | knots2 | ||
) |
Returns a vector of the overlapping knots from the given vectors.
Definition at line 62 of file multiplication.cpp.
References std::vector< T >::begin(), and std::vector< T >::end().
Referenced by multiplyPiecewises().
std::unique_ptr< Function > Euclid::MathUtils::splineInterpolation | ( | const std::vector< double > & | x, |
const std::vector< double > & | y, | ||
bool | extrapolate | ||
) |
Performs cubic spline interpolation for the given set of data points.
Definition at line 34 of file spline.cpp.
References std::vector< T >::back(), std::vector< T >::emplace_back(), std::vector< T >::front(), g, std::numeric_limits::lowest(), std::numeric_limits::max(), std::move(), std::vector< T >::reserve(), and std::vector< T >::size().
Referenced by interpolate().
std::map< std::type_index, MultiplyFunction > Euclid::MathUtils::multiplySpecificGenericMap {{typeid(Piecewise), multiplyPiecewiseWithGeneric}} |
A map for retrieving specific function multiplication implementations. The keys of the map are the type of a Function which can be multiplied with any other function and the value of the map is the function which can be used for performing this multiplication in an efficient way.
Definition at line 127 of file multiplication.cpp.
Referenced by multiply().
std::map< std::pair< std::type_index, std::type_index >, MultiplyFunction > Euclid::MathUtils::multiplySpecificSpecificMap |
A map for retrieving specific function multiplication implementations. The keys of the map are the pairs of the Function types and the value of the map is the function which can be used for performing this multiplication in an efficient way.
Definition at line 123 of file multiplication.cpp.
Referenced by multiply().