SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
Public Member Functions | Static Public Member Functions | List of all members
SSAGES::Legendre Class Reference

Defines the class of Legendre polynomials. More...

#include <Basis.h>

Inheritance diagram for SSAGES::Legendre:
Inheritance graph
[legend]

Public Member Functions

 Legendre (unsigned int polyOrd, unsigned int nbins)
 Constructor. More...
 
double Evaluate (double x, int n)
 Calculates the output of the basis function. More...
 
double EvalGrad (double x, int n)
 Calculates the gradient of the basis function. More...
 
double GetNorm (int n)
 Gets the norm of the basis function. More...
 
- Public Member Functions inherited from SSAGES::BasisFunction
 BasisFunction (unsigned int polyOrd, unsigned int nbins, bool isFinite, bool zeroOrder, double boundLow, double boundUp)
 Constructor. More...
 
unsigned int GetOrder ()
 Gets the order of the current polynomial. More...
 
unsigned int GetBins ()
 Gets the number of bins for the discretization. More...
 
bool GetZeroOrder ()
 Gets the flag for constant-order polynomials. More...
 
double GetLower ()
 Gets the lower bound on the CV. More...
 
double GetUpper ()
 Gets the upper bound on the CV. More...
 
double GetRange ()
 Gets the magnitude of the range of bounds. More...
 
virtual double Weight (double)
 Calculates the weight of the basis function. More...
 
virtual ~BasisFunction ()
 Destructor.
 

Static Public Member Functions

static LegendreBuild (const Json::Value &json, const std::string &path, unsigned int nbins)
 Build BasisFunction from JSON value. More...
 
- Static Public Member Functions inherited from SSAGES::BasisFunction
static BasisFunctionBuild (const Json::Value &json, const std::string &path, unsigned int nbins)
 Build BasisFunction from JSON value. More...
 

Additional Inherited Members

- Protected Attributes inherited from SSAGES::BasisFunction
unsigned int polyOrd_
 Order of the polynomial.
 
unsigned int nbins_
 Number of bins.
 
bool isFinite_
 Flag for finite-range polynomials.
 
bool zeroOrder_
 Flag for constant-order polynomials.
 
double boundLow_
 Lower bound on CV.
 
double boundUp_
 Upper bound on CV.
 

Detailed Description

Defines the class of Legendre polynomials.

Definition at line 257 of file Basis.h.

Constructor & Destructor Documentation

◆ Legendre()

SSAGES::Legendre::Legendre ( unsigned int  polyOrd,
unsigned int  nbins 
)
inline

Constructor.

Parameters
polyOrdOrder of Legendre polynomial.
nbinsNumber of bins.

Constructs an instance of the Legendre function class.

Definition at line 269 of file Basis.h.

269  :
270  BasisFunction(polyOrd, nbins, true, false, -1.0, 1.0)
271  {
272  }
BasisFunction(unsigned int polyOrd, unsigned int nbins, bool isFinite, bool zeroOrder, double boundLow, double boundUp)
Constructor.
Definition: Basis.h:82

Referenced by Build().

Here is the caller graph for this function:

Member Function Documentation

◆ Build()

Legendre * SSAGES::Legendre::Build ( const Json::Value &  json,
const std::string &  path,
unsigned int  nbins 
)
static

Build BasisFunction from JSON value.

Build the Legendre polynomial

Parameters
jsonJSON value node.
pathPath for JSON path specification.
nbinsNumber of bins.
Returns
Pointer to new BasisFunction.

Definition at line 75 of file Basis.cpp.

78  {
79  Json::ObjectRequirement validator;
80  Json::Value schema;
81  Json::CharReaderBuilder rbuilder;
82  Json::CharReader* reader = rbuilder.newCharReader();
83 
84  reader->parse(JsonSchema::LegendreBasis.c_str(),
85  JsonSchema::LegendreBasis.c_str() + JsonSchema::LegendreBasis.size(),
86  &schema, nullptr);
87  validator.Parse(schema, path);
88 
89  //Validate Inputs
90  validator.Validate(json, path);
91  if(validator.HasErrors())
92  throw BuildException(validator.GetErrors());
93 
94  return new Legendre(
95  json["polynomial_order"].asInt(),
96  nbin
97  );
98  }
Requirements on an object.
virtual void Parse(Value json, const std::string &path) override
Parse JSON value to generate Requirement(s).
virtual void Validate(const Value &json, const std::string &path) override
Validate JSON value.
std::vector< std::string > GetErrors()
Get list of error messages.
Definition: Requirement.h:92
bool HasErrors()
Check if errors have occured.
Definition: Requirement.h:86
Legendre(unsigned int polyOrd, unsigned int nbins)
Constructor.
Definition: Basis.h:269

References Json::Requirement::GetErrors(), Json::Requirement::HasErrors(), Legendre(), Json::ObjectRequirement::Parse(), and Json::ObjectRequirement::Validate().

Referenced by SSAGES::BasisFunction::Build().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EvalGrad()

double SSAGES::Legendre::EvalGrad ( double  ,
int   
)
inlinevirtual

Calculates the gradient of the basis function.

Parameters
valInput value for function.
orderOrder of the polynomial.
Returns
Gradient for function.

Reimplemented from SSAGES::BasisFunction.

Definition at line 281 of file Basis.h.

282  {
283  return n == 0 ? 0.0 :
284  n == 1 ? 1.0 :
285  (2.0*n-1.0)/(double)n*(Evaluate(x,n-1) + x * EvalGrad(x,n-1)) - (n-1.0)/(double)n*EvalGrad(x,n-2);
286  }
double EvalGrad(double x, int n)
Calculates the gradient of the basis function.
Definition: Basis.h:281
double Evaluate(double x, int n)
Calculates the output of the basis function.
Definition: Basis.h:274

References Evaluate().

Here is the call graph for this function:

◆ Evaluate()

double SSAGES::Legendre::Evaluate ( double  ,
int   
)
inlinevirtual

Calculates the output of the basis function.

Parameters
valInput value for function.
orderOrder of the polynomial.
Returns
Output value for function.

Reimplemented from SSAGES::BasisFunction.

Definition at line 274 of file Basis.h.

275  {
276  return n == 0 ? 1.0 :
277  n == 1 ? x :
278  (2.0*n-1.0)/(double)n*x*Evaluate(x,n-1) - (n-1.0)/(double)n*Evaluate(x,n-2);
279  }

Referenced by EvalGrad().

Here is the caller graph for this function:

◆ GetNorm()

double SSAGES::Legendre::GetNorm ( int  )
inlinevirtual

Gets the norm of the basis function.

Parameters
orderOrder of the polynomial.
Returns
Norm of a specific order of polynomial.

Reimplemented from SSAGES::BasisFunction.

Definition at line 288 of file Basis.h.

289  {
290  return n + 0.5;
291  }

The documentation for this class was generated from the following files: