Bayeux  3.4.1
Core Foundation library for SuperNEMO
convolution_function.h
Go to the documentation of this file.
1 //
4 // Copyright (c) 2016 by François Mauger <mauger@lpccaen.in2p3.fr>
5 //
6 // This file is part of Bayeux.
7 //
8 // Bayeux is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // Bayeux is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Bayeux. If not, see <http://www.gnu.org/licenses/>.
20 
21 #ifndef MYGSL_CONVOLUTION_FUNCTION_H
22 #define MYGSL_CONVOLUTION_FUNCTION_H
23 
24 // This project:
25 #include <mygsl/i_unary_function.h>
26 
27 // Third party:
28 #include <boost/noncopyable.hpp>
29 
30 namespace mygsl {
31 
33 
42  class convolution_function
44  : public i_unary_function
45  , private boost::noncopyable
46  {
47  public:
48 
51 
54  const i_unary_function & g_,
55  std::size_t size_ = 1000);
56 
60  std::size_t size_ = 1000);
61 
63  virtual ~convolution_function();
64 
66  virtual bool is_initialized() const;
67 
69  virtual void initialize(const datatools::properties & config_,
70  const unary_function_dict_type & functors_);
71 
73  void reset();
74 
76  void set_f(const i_unary_function &);
77 
79  void set_g(const i_unary_function &);
80 
82  bool has_f() const;
83 
85  bool has_g() const;
86 
88  const i_unary_function & get_f() const;
89 
91  const i_unary_function & get_g() const;
92 
94  void set_limit(std::size_t size_);
95 
97  std::size_t get_limit() const;
98 
100  virtual void tree_dump(std::ostream & out_ = std::clog,
101  const std::string & title_ = "",
102  const std::string & indent_ = "",
103  bool inherit_ = false) const;
104 
107  {
108  public:
109 
111  convolution_term(const convolution_function & cf_, double t_);
112 
114  /* virtual */ double get_non_zero_domain_min() const;
115 
117  /* virtual */ double get_non_zero_domain_max() const;
118 
120  void print(std::ostream & = std::clog, const std::string & title_ = "") const;
121 
122  protected:
123 
125  virtual double _eval(double) const;
126 
127  private:
128 
129  const convolution_function * _cs_;
130  double _t_;
131  double _tmin_;
132  double _tmax_;
133 
134  };
135 
137  static double convolution_func(double t_, void * params_);
138 
139  protected:
140 
142  double _eval(double x_) const;
143 
144  void _at_init();
145 
146  void _at_reset();
147 
148  private:
149 
152  std::size_t _limit_ = 0;
153 
155  class gsl_pimpl;
156  gsl_pimpl * _gsl_work_ = nullptr;
157 
160 
161  };
162 
163 } // end of namespace mygsl
164 
165 #endif // MYGSL_CONVOLUTION_FUNCTION_H
166 
167 // Local Variables: --
168 // mode: c++ --
169 // c-file-style: "gnu" --
170 // tab-width: 2 --
171 // End: --
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart printing.
void set_f(const i_unary_function &)
Set the first functor.
double get_non_zero_domain_min() const
The minimum bound of the non-zero domain.
virtual void initialize(const datatools::properties &config_, const unary_function_dict_type &functors_)
Initialization from a container of parameters and a dictionary of functors.
void print(std::ostream &=std::clog, const std::string &title_="") const
Smart print.
static double convolution_func(double t_, void *params_)
Interface integrand function for GSL function.
convolution_function()
Default constructor.
virtual double _eval(double) const
Function interface.
Convolution function.
Definition: convolution_function.h:43
const i_unary_function & get_g() const
Return the second functor.
void set_g(const i_unary_function &)
Set the second functor.
virtual bool is_initialized() const
Check initialization status.
void set_limit(std::size_t size_)
Set limit.
i_unary_function(double epsilon_=0.0)
Constructor.
void reset()
Reset the function.
Abstract interface for unary functions : R -> R.
Definition: i_unary_function.h:44
convolution_term(const convolution_function &cf_, double t_)
Constructor.
Smart handle to an unary function object.
Definition: unary_function_utils.h:33
bool has_f() const
Check the first functor.
bool has_g() const
Check the second functor.
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
std::map< std::string, unary_function_handle_type > unary_function_dict_type
Alias for dictionary of handles to unary function objects.
Definition: unary_function_utils.h:30
#define MYGSL_UNARY_FUNCTOR_REGISTRATION_INTERFACE(UnaryFunctorClass)
Definition: i_unary_function.h:206
double get_non_zero_domain_max() const
The minimum bound of the non-zero domain.
double _eval(double x_) const
Evaluation.
const i_unary_function & get_f() const
Return the first functor.
datatools::handle< const i_unary_function > const_unary_function_handle_type
Alias for a handle to a const unary function object.
Definition: unary_function_utils.h:27
virtual ~convolution_function()
Destructor.
std::size_t get_limit() const
Return the limit.
Interface parameters for GSL function.
Definition: convolution_function.h:106
A dictionary of arbitrary properties.
Definition: properties.h:125