WaveBlocksND
exponential.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Eigen/Core>
4 #include <unsupported/Eigen/MatrixFunctions>
5 
6 #include "../../utilities/evaluations.hpp"
7 
8 #include "../bases.hpp"
9 
10 
11 namespace waveblocks
12 {
13  namespace potentials
14  {
15  namespace modules
16  {
17  namespace exponential
18  {
31  template <class Subtype, class Basis>
32  class Abstract
33  {
35  IMPORT_TYPES_FROM( Basis)
36 
37  potential_evaluation_type evaluate_exponential_at( const argument_type &arg,
38  const real_t &factor = 1 ) const {
39  static_cast<const Subtype*>(this)->evaluate_exponential_at_implementation( arg, factor );
40  }
41 
42  template < template <typename...> class grid_in = std::vector,
43  template <typename...> class grid_out = grid_in >
44  grid_out<potential_evaluation_type> evaluate_exponential(
45  grid_in<argument_type > args,
46  real_t factor = 1 ) const {
47  return utilities::evaluate_function_in_grid < argument_type,
48  potential_evaluation_type,
49  grid_in,
50  grid_out,
51  function_t > (
53  this,
54  std::placeholders::_1,
55  factor ),
56  args );
57  }
58  };
59 
71  template <class EvalImpl, class Basis>
72  struct Standard : public Abstract<Standard<EvalImpl, Basis>, Basis>,
73  public EvalImpl {
74  IMPORT_TYPES_FROM( Basis)
75 
76  Standard(potential_type pot) : EvalImpl(pot){}
77 
78  potential_evaluation_type evaluate_exponential_at_implementation(
79  const argument_type &arg,
80  real_t factor ) const {
81  // Compute matrix
82  auto values = evaluate_at( arg );
83  potential_evaluation_type result;
84 
85  // Compute exponential
86  return (factor * values).exp();
87  }
88  };
89 
90  template <class EvalImpl, template <int, int> class B, int D>
91  struct Standard<EvalImpl, B<1, D>> : public Abstract<Standard<EvalImpl, B<1,D>>, B<1,D>>,
92  public EvalImpl {
93  using Basis = B<1,D>;
95 
96  Standard(potential_type pot) : EvalImpl(pot){}
97 
98  potential_evaluation_type evaluate_exponential_at_implementation(
99  const argument_type &arg,
100  real_t factor ) const {
101  // Compute matrix
102  auto values = evaluate_at( arg );
103  return std::exp(factor * values);
104  }
105  };
106  }
107 
108  template <class Basis>
110  }
111  }
112 }
Definition: coefficients_file_parser.cpp:10
grid_out< potential_evaluation_type > evaluate_exponential(grid_in< argument_type > args, real_t factor=1) const
Definition: exponential.hpp:44
potential_evaluation_type evaluate_exponential_at(const argument_type &arg, const real_t &factor=1) const
Definition: exponential.hpp:37
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
double real_t
Definition: types.hpp:14
Implementation of exponential of potential evaluation.
Definition: exponential.hpp:72
Abstract class for exponential of potential evaluation.
Definition: exponential.hpp:32
std::function< P > function_t
Definition: types.hpp:57
#define IMPORT_TYPES_FROM(B)
Definition: bases.hpp:3
potential_evaluation_type evaluate_exponential_at_implementation(const argument_type &arg, real_t factor) const
Definition: exponential.hpp:98
potential_evaluation_type evaluate_exponential_at_implementation(const argument_type &arg, real_t factor) const
Definition: exponential.hpp:78