MUQ  0.4.3
IndexedScalarBasis.h
Go to the documentation of this file.
1 #ifndef INDEXEDSCALARBASIS_H_
2 #define INDEXEDSCALARBASIS_H_
3 
4 #include <functional>
5 #include <string>
6 
9 
10 namespace muq {
11  namespace Approximation {
12 
23  public:
24 
25 
26  typedef std::function<std::shared_ptr<IndexedScalarBasis>()> ScalarBasisConstructorType;
27  typedef std::map<std::string, ScalarBasisConstructorType> ScalarBasisMapType;
28  static std::shared_ptr<ScalarBasisMapType> GetScalarBasisMap();
29 
30  // Factory method for consttructing polynomial from family
31  static std::shared_ptr<IndexedScalarBasis> Construct(std::string const& polyName);
32 
33 
36 
37  virtual ~IndexedScalarBasis() = default;
38 
40 
44  virtual double BasisEvaluate(int const order,
45  double const x) const = 0;
46 
47 
49  virtual Eigen::VectorXd EvaluateAllTerms(int const maxOrder,
50  double const x) const
51  {
52  Eigen::VectorXd output(maxOrder+1);
53  for(int i=0; i<=maxOrder; ++i)
54  output(i) = BasisEvaluate(i,x);
55  return output;
56  };
57 
64  virtual double DerivativeEvaluate(int const polyOrder,
65  int const derivOrder,
66  double const x) const = 0;
67 
68 
69  private:
70 
72  virtual void EvaluateImpl(muq::Modeling::ref_vector<boost::any> const& inputs);
73 
74 
75  };
76  } // namespace Approximation
77 } // namespace muq
78 
79 
80 #define REGISTER_SCALARBASIS_FAMILY(NAME) static auto regScalarBasis ##NAME \
81  = muq::Approximation::IndexedScalarBasis::GetScalarBasisMap()->insert(std::make_pair(#NAME, muq::Utilities::shared_factory<NAME>()));
82 
83 
84 
85 #endif
virtual void EvaluateImpl(muq::Modeling::ref_vector< boost::any > const &inputs)
Evaluate the polynomial at a given point and order.
static std::shared_ptr< IndexedScalarBasis > Construct(std::string const &polyName)
virtual double DerivativeEvaluate(int const polyOrder, int const derivOrder, double const x) const =0
virtual Eigen::VectorXd EvaluateAllTerms(int const maxOrder, double const x) const
Evaluates all basis functions with order <= maxOrder.
IndexedScalarBasis()
Create a basis function.
virtual double BasisEvaluate(int const order, double const x) const =0
Evaluate the specific basis type (must be implemented by the child)
std::function< std::shared_ptr< IndexedScalarBasis >)> ScalarBasisConstructorType
static std::shared_ptr< ScalarBasisMapType > GetScalarBasisMap()
std::map< std::string, ScalarBasisConstructorType > ScalarBasisMapType
Base class for MUQ's modelling envronment.
Definition: WorkPiece.h:40
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37