3 #include "../Grids/Grid.h"
28 const std::vector<double>&
derivs) :
186 static BasisFunction*
Build(
const Json::Value& json,
const std::string& path,
unsigned int nbins);
207 Chebyshev(
unsigned int polyOrd,
double boundLow,
double boundUp,
unsigned int nbins) :
208 BasisFunction(polyOrd, nbins, true, false, boundLow, boundUp)
226 return n == 0 ? 1.0 :
234 return n == 0 ? 0.0 :
242 return 1.0/sqrt(1.0-xMod*xMod);
252 static Chebyshev*
Build(
const Json::Value& json,
const std::string& path,
unsigned int nbins);
269 Legendre(
unsigned int polyOrd,
unsigned int nbins) :
276 return n == 0 ? 1.0 :
278 (2.0*n-1.0)/(
double)n*x*
Evaluate(x,n-1) - (n-1.0)/(
double)n*
Evaluate(x,n-2);
283 return n == 0 ? 0.0 :
295 static Legendre*
Build(
const Json::Value& json,
const std::string& path,
unsigned int nbins);
313 Fourier(
unsigned int polyOrd,
double boundLow,
double boundUp,
unsigned int nbins) :
323 return n == 0 ? 0.5 :
330 return n == 0 ? 0.0 :
343 static Fourier*
Build(
const Json::Value& json,
const std::string& path,
unsigned int nbins);
396 std::vector<double> coeffArray (
coeff_.size(),0);
397 for (
size_t i=0; i<
coeff_.size(); i++)
399 coeffArray[i] =
coeff_[i].value;
413 val.value = coeff[ii];
Calculates the inner product of all the basis functions and the histogram.
void SetCoeff(const std::vector< double > &coeff)
Set the coefficient array in the event of a restart run.
std::vector< double > GetCoeff(void)
Gets the coefficient array.
BasisEvaluator(const std::vector< BasisFunction * > &functions)
Constructor.
std::vector< BasisLUT > lookup_
Lookup table for basis functions.
std::vector< Map > coeff_
Vector of basis function coefficients.
void BasisInit()
Creates lookup table for basis functions.
void UpdateBias(Grid< double > *bias, Grid< std::vector< double >> *grad)
Outputs the basis projection at a specific coordinate.
double UpdateCoeff(const std::vector< double > &array, Grid< unsigned int > *hist)
std::vector< BasisFunction * > functions_
Vector of basis functions.
void CoeffInit()
Initializes coefficient lookup vector.
Abstract class for all BasisFunction inheritance.
double GetUpper()
Gets the upper bound on the CV.
static BasisFunction * Build(const Json::Value &json, const std::string &path, unsigned int nbins)
Build BasisFunction from JSON value.
virtual double Evaluate(double, int)
Calculates the output of the basis function.
bool zeroOrder_
Flag for constant-order polynomials.
virtual ~BasisFunction()
Destructor.
double boundLow_
Lower bound on CV.
bool GetZeroOrder()
Gets the flag for constant-order polynomials.
double boundUp_
Upper bound on CV.
unsigned int GetBins()
Gets the number of bins for the discretization.
unsigned int nbins_
Number of bins.
virtual double Weight(double)
Calculates the weight of the basis function.
unsigned int GetOrder()
Gets the order of the current polynomial.
double GetRange()
Gets the magnitude of the range of bounds.
unsigned int polyOrd_
Order of the polynomial.
bool isFinite_
Flag for finite-range polynomials.
BasisFunction(unsigned int polyOrd, unsigned int nbins, bool isFinite, bool zeroOrder, double boundLow, double boundUp)
Constructor.
virtual double EvalGrad(double, int)
Calculates the gradient of the basis function.
virtual double GetNorm(int)
Gets the norm of the basis function.
double GetLower()
Gets the lower bound on the CV.
Defines the class of Chebyshev polynomials.
double GetNorm(int)
Gets the norm of the basis function.
double EvalGrad(double x, int n)
Calculates the gradient of the basis function.
Chebyshev(unsigned int polyOrd, double boundLow, double boundUp, unsigned int nbins)
Constructor.
double Weight(double x)
Calculates the weight of the basis function.
double Evaluate(double x, int n)
Calculates the output of the basis function.
double ChangeVariable(double x)
Transforms variable from absolute value to [-1,1] between boundaries.
static Chebyshev * Build(const Json::Value &json, const std::string &path, unsigned int nbins)
Build BasisFunction from JSON value.
Defines the class of Fourier polynomials.
Fourier(unsigned int polyOrd, double boundLow, double boundUp, unsigned int nbins)
Constructor.
double EvalGrad(double x, int n)
Calculates the gradient of the basis function.
double Evaluate(double x, int n)
Calculates the output of the basis function.
double GetNorm(int)
Gets the norm of the basis function.
static Fourier * Build(const Json::Value &json, const std::string &path, unsigned int nbins)
Build BasisFunction from JSON value.
Defines the class of Legendre polynomials.
double EvalGrad(double x, int n)
Calculates the gradient of the basis function.
static Legendre * Build(const Json::Value &json, const std::string &path, unsigned int nbins)
Build BasisFunction from JSON value.
double GetNorm(int n)
Gets the norm of the basis function.
Legendre(unsigned int polyOrd, unsigned int nbins)
Constructor.
double Evaluate(double x, int n)
Calculates the output of the basis function.
Look-up table for basis functions.
std::vector< double > values
The values of the basis sets.
BasisLUT(const std::vector< double > &values, const std::vector< double > &derivs)
Constructor.
std::vector< double > derivs
The values of the derivatives of the basis sets.
Map for histogram and coefficients.
Map(const std::vector< int > &map, double value)
Constructor.
double value
The coefficient value.
std::vector< int > map
The mapping in an array of integers.