WaveBlocksND
hawp_gradient_operator.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../types.hpp"
4 
5 #include "hawp_commons.hpp"
8 
9 
10 namespace waveblocks {
11  namespace wavepackets {
28  template<dim_t D, class MultiIndex>
29  class HaWpGradient : public AbstractScalarHaWpBasis<D,MultiIndex>
30  {
31  public:
40  class Component : public AbstractScalarHaWp<D,MultiIndex>
41  {
42  public:
43  Component(HaWpGradient const * const owner)
44  : owner_(owner)
45  { }
46 
47  real_t eps() const override
48  {
49  return owner_->eps();
50  }
51 
52  HaWpParamSet<D> const& parameters() const override
53  {
54  return owner_->parameters();
55  }
56 
58  {
59  return owner_->shape();
60  }
61 
67  {
68  return coefficients_;
69  }
70 
75  Coefficients const& coefficients() const
76  {
77  return coefficients_;
78  }
79 
80  private:
81  HaWpGradient const * const owner_;
82 
84  };
85 
87  : components_(D, Component(this))
88  { }
89 
94  real_t & eps()
95  {
96  return eps_;
97  }
98 
99  real_t eps() const override
100  {
101  return eps_;
102  }
103 
109  {
110  return parameters_;
111  }
112 
113  HaWpParamSet<D> const& parameters() const override
114  {
115  return parameters_;
116  }
117 
127  {
128  return shape_;
129  }
130 
132  {
133  return shape_;
134  }
135 
143  Component & component(std::size_t n)
144  {
145  return components_[n];
146  }
147 
155  Component const& component(std::size_t n) const
156  {
157  return components_[n];
158  }
159 
167  Component & operator[](std::size_t n)
168  {
169  return component(n);
170  }
171 
179  Component const& operator[](std::size_t n) const
180  {
181  return component(n);
182  }
183 
187  std::size_t n_components() const
188  {
189  return components_.size();
190  }
191 
209  template<int N>
211  {
212  ScalarHaWp<D,MultiIndex> scalarwp;
213 
214  scalarwp.eps() = eps();
215  scalarwp.parameters() = parameters();
216  scalarwp.shape() = shape();
217 
218  std::vector< complex_t const* > coeffs_list(n_components());
219 
220  for (std::size_t n = 0; n < n_components(); n++) {
221  coeffs_list[n] = component(n).coefficients().data();
222  }
223 
224  return scalarwp.template create_evaluator<N>(grid).vector_reduce(coeffs_list.data(), n_components());
225  }
226 
244  template<int N>
246  {
247  CMatrix<D,N> cgrid = rgrid.template cast<complex_t>();
248  return evaluate(cgrid);
249  }
250 
251  private:
255  std::vector<Component> components_;
256  };
257 
285  template<dim_t D, class MultiIndex>
287  {
288  public:
310  {
312  gradwp.eps() = wp.eps();
313  gradwp.parameters() = wp.parameters();
314  gradwp.shape() = wp.extended_shape();
315 
316  HaWpGradientEvaluator<D,MultiIndex> evaluator(wp.eps(), &wp.parameters(), wp.shape().get(), gradwp.shape().get());
317  std::array<Coefficients, std::size_t(D) > coeffs_result = evaluator.apply(wp.coefficients());
318 
319  for (dim_t c = 0; c < D; c++) {
320  gradwp[c].coefficients() = std::move(coeffs_result[c]);
321  }
322 
323  return gradwp;
324  }
325  };
326  }
327 }
Coefficients & coefficients()
Grants writeable access to the coefficients of the wavepacket.
Definition: hawp_gradient_operator.hpp:66
std::size_t n_components() const
Returns the number of components.
Definition: hawp_gradient_operator.hpp:187
Definition: coefficients_file_parser.cpp:10
HaWpParamSet< D > const & parameters() const override
Grants read-only access to the Hagedorn parameter set of the wavepacket.
Definition: hawp_gradient_operator.hpp:52
Component(HaWpGradient const *const owner)
Definition: hawp_gradient_operator.hpp:43
real_t eps_
Definition: hawp_gradient_operator.hpp:252
virtual HaWpParamSet< D > const & parameters() const =0
Grants read-only access to the Hagedorn parameter set of the wavepacket.
Component const & operator[](std::size_t n) const
Grants read-only access to the -th component .
Definition: hawp_gradient_operator.hpp:179
Component & component(std::size_t n)
Grants writeable access to the -th component .
Definition: hawp_gradient_operator.hpp:143
Eigen::Matrix< real_t, R, C > RMatrix
Definition: types.hpp:22
Eigen::Matrix< complex_t, Eigen::Dynamic, 1 > Coefficients
Definition: types.hpp:33
std::shared_ptr< ShapeEnum< D, MultiIndex > > ShapeEnumSharedPtr
Definition: shape_extension_cache.hpp:14
var c
Definition: jquery.js:23
double real_t
Definition: types.hpp:14
Coefficients coefficients_
Definition: hawp_gradient_operator.hpp:83
HaWpParamSet< D > const & parameters() const override
Grants read-only access to the Hagedorn parameter set of the wavepacket.
Definition: hawp_gradient_operator.hpp:113
shapes::ShapeEnumSharedPtr< D, MultiIndex > shape() const override
Retrieves the basis shape of the wavepacket.
Definition: hawp_gradient_operator.hpp:57
virtual real_t eps() const =0
Retrieves the semi-classical scaling parameter of the wavepacket.
shapes::ShapeEnumSharedPtr< D, MultiIndex > extended_shape() const
Computes the extension of the stored basis shape .
Definition: hawp_commons.hpp:104
std::array< Coefficients, std::size_t(D) > apply(const Coefficients &base_coeffs) const
Computes the coefficients of the gradient wavepacket.
Definition: hawp_gradient_evaluator.hpp:52
HaWpParamSet< D > & parameters()
Grants writeable access to the Hagedorn parameter set of the wavepacket.
Definition: hawp_gradient_operator.hpp:108
This class represents the gradient of a (scalar) Hagedorn wavepacket .
Definition: hawp_gradient_operator.hpp:29
real_t & eps()
Grants writeable access to the semi-classical scaling parameter of the wavepacket.
Definition: hawp_gradient_operator.hpp:94
This class represents the Hagedorn parameter set .
Definition: hawp_paramset.hpp:24
Abstract superclass that represents a set of basis function to a scalar Hagedorn wavepacket.
Definition: hawp_commons.hpp:25
HaWpParamSet< D > & parameters()
Grants writeable access to the Hagedorn parameter set of the wavepacket.
Definition: hawp_commons.hpp:230
real_t & eps()
Grants writeable access to the semi-classical scaling parameter of the wavepacket.
Definition: hawp_commons.hpp:216
CArray< 1, N > evaluate(CMatrix< D, N > const &grid) const
Evaluates this wavepacket at complex grid nodes .
Definition: hawp_commons.hpp:155
Component & operator[](std::size_t n)
Grants writeable access to the -th component .
Definition: hawp_gradient_operator.hpp:167
This class is component of a Hagedorn wavepacket gradient.
Definition: hawp_gradient_operator.hpp:40
shapes::ShapeEnumSharedPtr< D, MultiIndex > shape() const override
Retrieves the basis shape of the wavepacket.
Definition: hawp_gradient_operator.hpp:131
HaWpParamSet< D > parameters_
Definition: hawp_gradient_operator.hpp:253
real_t eps() const override
Retrieves the semi-classical scaling parameter of the wavepacket.
Definition: hawp_gradient_operator.hpp:47
shapes::ShapeEnumSharedPtr< D, MultiIndex > & shape()
Grants access to the basis shape of the wavepacket.
Definition: hawp_commons.hpp:248
virtual shapes::ShapeEnumSharedPtr< D, MultiIndex > shape() const =0
Retrieves the basis shape of the wavepacket.
Abstract superclass that represents a scalar (1-component) hagedorn wavepacket.
Definition: hawp_commons.hpp:129
HaWpGradient()
Definition: hawp_gradient_operator.hpp:86
Concrete implementation of a scalar Hagedorn wavepacket.
Definition: hawp_commons.hpp:209
Eigen::Matrix< complex_t, R, C > CMatrix
Definition: types.hpp:19
Coefficients const & coefficients() const
Grants read-only access to the coefficients of the wavepacket.
Definition: hawp_gradient_operator.hpp:75
shapes::ShapeEnumSharedPtr< D, MultiIndex > & shape()
Grants access to the basis shape of the wavepacket.
Definition: hawp_gradient_operator.hpp:126
HaWpGradient const *const owner_
Definition: hawp_gradient_operator.hpp:81
Component const & component(std::size_t n) const
Grants read-only access to the -th component .
Definition: hawp_gradient_operator.hpp:155
HaWpGradient< D, MultiIndex > operator()(AbstractScalarHaWp< D, MultiIndex > const &wp) const
Applies the gradient operator to an arbitrary scalar wavepacket .
Definition: hawp_gradient_operator.hpp:309
int dim_t
Definition: types.hpp:16
virtual Coefficients const & coefficients() const =0
Grants read-only access to the coefficients for all of this wavepacket.
This class applies the gradient operator to an arbitrary scalar wavepacket .
Definition: hawp_gradient_operator.hpp:286
std::vector< Component > components_
Definition: hawp_gradient_operator.hpp:255
real_t eps() const override
Retrieves the semi-classical scaling parameter of the wavepacket.
Definition: hawp_gradient_operator.hpp:99
shapes::ShapeEnumSharedPtr< D, MultiIndex > shape_
Definition: hawp_gradient_operator.hpp:254
Eigen::Array< complex_t, R, C > CArray
Definition: types.hpp:25
CArray< Eigen::Dynamic, N > evaluate(RMatrix< D, N > const &rgrid) const
Evaluates the value of all components at once.
Definition: hawp_gradient_operator.hpp:245
CArray< Eigen::Dynamic, N > evaluate(CMatrix< D, N > const &grid) const
Evaluate the value of all components at once.
Definition: hawp_gradient_operator.hpp:210
This class constructs the coefficients of the Hagedorn gradient wavepacket applied to an arbitrary s...
Definition: hawp_gradient_evaluator.hpp:22