9#include <BSMPT/config.h>
12#include <gsl/gsl_integration.h>
20#include <boost/version.hpp>
21#if BOOST_VERSION >= 107200
22#include <boost/math/interpolators/cardinal_cubic_b_spline.hpp>
24#include <boost/math/interpolators/cubic_b_spline.hpp>
45bool StringEndsWith(
const std::string &str,
const std::string &suffix);
50const std::string
sep =
"\t";
61std::vector<T>
push_back(std::vector<T> &a,
const std::vector<T> &b)
63 return a.insert(a.end(), b.begin(), b.end());
69template <
typename T> std::string
vec_to_string(
const std::vector<T> &vec)
73 for (
const auto &el : vec)
77 res +=
sep + std::to_string(el);
81 res = std::to_string(el);
91std::vector<std::string>
split(
const std::string &str,
char delimiter);
97std::ostream &
operator<<(std::ostream &os,
const std::vector<T> &vec)
100 for (
const auto &el : vec)
119std::vector<T>
operator+(
const std::vector<T> &a,
const std::vector<T> &b)
121 if (a.size() != b.size())
122 throw std::runtime_error(
123 "Vector cannot be added. Must have the same size.");
124 std::vector<T> result;
125 result.reserve(a.size());
127 std::transform(a.begin(),
130 std::back_inserter(result),
139std::vector<T>
operator-(
const std::vector<T> &a,
const std::vector<T> &b)
141 if (a.size() != b.size())
142 throw(
"Vector cannot be subtracted. Must have the same size.");
144 std::vector<T> result;
145 result.reserve(a.size());
147 std::transform(a.begin(),
150 std::back_inserter(result),
158template <
typename T,
typename T2>
159std::vector<T>
operator*(
const T2 &a,
const std::vector<T> &b)
161 std::vector<T> result;
162 result.reserve(b.size());
164 std::transform(b.begin(),
166 std::back_inserter(result),
167 [&a](T i) { return a * i; });
174template <
typename T,
typename T2>
175std::vector<T>
operator/(
const std::vector<T> &a,
const T2 &b)
177 std::vector<T> result;
178 result.reserve(a.size());
180 std::transform(a.begin(),
182 std::back_inserter(result),
183 [&b](T i) { return i / b; });
191T
operator*(
const std::vector<T> &a,
const std::vector<T> &b)
193 if (a.size() != b.size())
195 "Dot product between vectors cannot be done. Must have the same size.");
197 std::vector<T> result;
198 result.reserve(a.size());
200 std::transform(a.begin(),
203 std::back_inserter(result),
204 [](T i, T j) { return (i * j); });
206 T result1 = std::accumulate(result.begin(), result.end(), 0.0);
215std::vector<T>
operator*(
const std::vector<std::vector<T>> &a,
216 const std::vector<T> &b)
218 if (a.size() != b.size())
219 throw(
"Multiplication of matrix with vector cannot be done. Must have the "
222 std::vector<T> result;
223 result.reserve(a.size());
225 std::transform(a.begin(),
227 std::back_inserter(result),
228 [&](std::vector<T> i) { return (i * b); });
237std::vector<T>
flatten(std::vector<std::vector<T>>
const &vec)
239 std::vector<T> flattened;
240 for (
auto const &v : vec)
242 flattened.insert(flattened.end(), v.begin(), v.end());
259std::vector<std::vector<double>>
260Transpose(
const std::vector<std::vector<double>> &A);
270double Li2(
const double &x);
298#if BOOST_VERSION >= 107200
300using boost_cubic_b_spline =
301 boost::math::interpolators::cardinal_cubic_b_spline<T>;
304using boost_cubic_b_spline = boost::math::cubic_b_spline<T>;
ModelIDs
The ModelIDs enum containing all IDs for identifying the Models.
Definition IncludeAllModels.h:32
This classes calculates the Bounce action of the potential with a set temperature.
Definition CalculateEtaInterface.h:24
std::vector< T > operator*(const T2 &a, const std::vector< T > &b)
multiplication of vector with scalar
Definition utility.h:159
std::vector< T > operator+(const std::vector< T > &a, const std::vector< T > &b)
vector addition
Definition utility.h:119
std::vector< T > operator-(const std::vector< T > &a, const std::vector< T > &b)
vector subtraction
Definition utility.h:139
std::vector< T > operator/(const std::vector< T > &a, const T2 &b)
division of vector by scalar
Definition utility.h:175
std::string vec_to_string(const std::vector< T > &vec)
vector to_string
Definition utility.h:69
bool StringStartsWith(const std::string &str, const std::string &prefix)
StringStartsWith checks if str starts with prefix.
Definition utility.cpp:46
int factorial(const int &a)
factorial function
Definition utility.cpp:51
std::vector< T > flatten(std::vector< std::vector< T > > const &vec)
flatten matrix
Definition utility.h:237
double L2NormVector(const std::vector< double > &vec)
L2NormVector.
Definition utility.cpp:56
std::vector< T > push_back(std::vector< T > &a, const std::vector< T > &b)
push back vector into vector
Definition utility.h:61
double Li2(const double &x)
Dilogarithm of x.
Definition utility.cpp:84
const std::string sep
seperator used to write into output files
Definition utility.h:50
std::vector< std::vector< double > > Transpose(const std::vector< std::vector< double > > &A)
Calculates the tranpose of a matrix.
Definition utility.cpp:68
bool StringEndsWith(const std::string &str, const std::string &suffix)
StringEndsWith tests if str ends with suffix.
Definition utility.cpp:104
std::ostream & operator<<(std::ostream &os, const StatusNLOStability &status)
Override << operator to handle StatusNLOStability.
Definition minimum_tracer.cpp:18
double EllipIntSecond(const double &x)
Incomplete elliptic integral of the second kind of x with a different parameterization and k^2 = -2.
Definition utility.cpp:110
std::vector< std::string > split(const std::string &str, char delimiter)
split string separated by delimiter into substrings
Definition utility.cpp:26