SSAGES  0.8.5
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 val)
 Calculates the gradient 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 265 of file Basis.h.

Constructor & Destructor Documentation

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 277 of file Basis.h.

277  :
278  BasisFunction(polyOrd, nbins, true, false, -1.0, 1.0)
279  {
280  }
BasisFunction(unsigned int polyOrd, unsigned int nbins, bool isFinite, bool zeroOrder, double boundLow, double boundUp)
Constructor.
Definition: Basis.h:84

Member Function Documentation

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.

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

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

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  }
Legendre(unsigned int polyOrd, unsigned int nbins)
Constructor.
Definition: Basis.h:277
bool HasErrors()
Check if errors have occured.
Definition: Requirement.h:86
virtual void Parse(Value json, const std::string &path) override
Parse JSON value to generate Requirement(s).
std::vector< std::string > GetErrors()
Get list of error messages.
Definition: Requirement.h:92
Requirements on an object.
virtual void Validate(const Value &json, const std::string &path) override
Validate JSON value.

Here is the call graph for this function:

Here is the caller graph for this function:

double SSAGES::Legendre::EvalGrad ( double  val,
int  order 
)
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 289 of file Basis.h.

290  {
291  return n == 0 ? 0.0 :
292  n == 1 ? 1.0 :
293  (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);
294  }
double EvalGrad(double x, int n)
Calculates the gradient of the basis function.
Definition: Basis.h:289
double Evaluate(double x, int n)
Calculates the output of the basis function.
Definition: Basis.h:282
double SSAGES::Legendre::Evaluate ( double  val,
int  order 
)
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 282 of file Basis.h.

283  {
284  return n == 0 ? 1.0 :
285  n == 1 ? x :
286  (2.0*n-1.0)/(double)n*x*Evaluate(x,n-1) - (n-1.0)/(double)n*Evaluate(x,n-2);
287  }
double Evaluate(double x, int n)
Calculates the output of the basis function.
Definition: Basis.h:282
double SSAGES::Legendre::GetNorm ( int  order)
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 296 of file Basis.h.

297  {
298  return n + 0.5;
299  }

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