WaveBlocksND
taylor.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <tuple>
4 
5 #include "../../types.hpp"
6 #include "../../utilities/evaluations.hpp"
7 #include "../bases.hpp"
8 #include "evaluation.hpp"
9 #include "jacobian.hpp"
10 #include "hessian.hpp"
11 
12 
13 namespace waveblocks
14 {
15  namespace potentials
16  {
17  namespace modules
18  {
19  namespace taylor
20  {
33  template <class Subtype, class Basis>
34  struct Abstract {
36  IMPORT_TYPES_FROM( Basis)
37 
38 
39  template <template <typename...> class Tuple = std::tuple>
40  Tuple<potential_evaluation_type, jacobian_evaluation_type, hessian_evaluation_type> taylor_at( const argument_type &g ) const {
41  return static_cast<const Subtype*>(this)->taylor_at_implementation(g);
42  }
43 
44  template < template <typename...> class Tuple = std::tuple,
45  template <typename...> class grid_in = std::vector,
46  template <typename...> class grid_out = grid_in >
47  grid_out< Tuple<potential_evaluation_type,jacobian_evaluation_type,hessian_evaluation_type>>taylor( const grid_in<argument_type > &args ) const {
48  return utilities::evaluate_function_in_grid < argument_type,
49  Tuple<>,
50  grid_in,
51  grid_out,
52  function_t > (
53  std::bind( &Self::taylor_at, this, std::placeholders::_1 ), args );
54  }
55  };
56 
68  template <class EvalImpl, class JacImpl, class HessImpl, class Basis>
69  struct Standard : public Abstract<Standard<EvalImpl, JacImpl, HessImpl, Basis>, Basis>, public EvalImpl, public JacImpl, public HessImpl {
70  IMPORT_TYPES_FROM( Basis)
71 
72  public:
73  Standard(potential_type potential,
74  jacobian_type jacobian,
75  hessian_type hessian) : EvalImpl(potential), JacImpl(jacobian), HessImpl(hessian) {}
76 
77  public:
78  template <template <typename...> class Tuple = std::tuple>
79  Tuple<potential_evaluation_type, jacobian_evaluation_type, hessian_evaluation_type> taylor_at_implementation( const argument_type &g ) const {
80  return Tuple<potential_evaluation_type,jacobian_evaluation_type,hessian_evaluation_type>(
81  EvalImpl::evaluate_at( g ), JacImpl::evaluate_jacobian_at( g ), HessImpl::evaluate_hessian_at( g ) );
82  }
83  };
84  }
85 
86 
87  template <class Basis>
89  }
90  }
91 }
Helper class for easier template specialization.
Definition: taylor.hpp:69
Definition: coefficients_file_parser.cpp:10
grid_out< Tuple< potential_evaluation_type, jacobian_evaluation_type, hessian_evaluation_type > > taylor(const grid_in< argument_type > &args) const
Definition: taylor.hpp:47
G_out< R > evaluate_function_in_grid(const F< R(A)> &f, const G_in< A > &g)
Evaluate a function in multiple points at once.
Definition: evaluations.hpp:130
Definition: stdarray2stream.hpp:7
Standard(potential_type potential, jacobian_type jacobian, hessian_type hessian)
Definition: taylor.hpp:73
Helper class for easier template specialization.
Definition: jacobian.hpp:62
Tuple< potential_evaluation_type, jacobian_evaluation_type, hessian_evaluation_type > taylor_at_implementation(const argument_type &g) const
Definition: taylor.hpp:79
std::function< P > function_t
Definition: types.hpp:57
Tuple< potential_evaluation_type, jacobian_evaluation_type, hessian_evaluation_type > taylor_at(const argument_type &g) const
Definition: taylor.hpp:40
#define IMPORT_TYPES_FROM(B)
Definition: bases.hpp:3
Abstract class for potential evaluation.
Definition: taylor.hpp:34
Helper class for easier template specialization.
Definition: hessian.hpp:63