Bayeux  3.4.1
Core Foundation library for SuperNEMO
linear_combination_function.h
Go to the documentation of this file.
1 //
4 // Copyright (c) 2015 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_LINEAR_COMBINATION_FUNCTION_H
22 #define MYGSL_LINEAR_COMBINATION_FUNCTION_H
23 
24 // This project:
25 #include <mygsl/i_unary_function.h>
26 
27 namespace mygsl {
28 
30 
38  {
39  public:
40 
43 
45  linear_combination_function(double w1_,
47  double w2_,
49 
52 
54  virtual bool is_initialized() const;
55 
57  virtual void initialize(const datatools::properties & config_,
58  const unary_function_dict_type & functors_);
59 
61  void reset();
62 
64  std::size_t add(double weight_, const i_unary_function &);
65 
67  std::size_t add(double weight_, const const_unary_function_handle_type &);
68 
70  void change_weight(int term_index_, double weight_);
71 
73  virtual bool has_explicit_domain_of_definition() const;
74 
76  virtual bool is_in_domain_of_definition(double x_) const;
77 
79  virtual double get_non_zero_domain_min() const;
80 
82  virtual double get_non_zero_domain_max() const;
83 
85  virtual void tree_dump(std::ostream & out_ = std::clog,
86  const std::string & title_ = "",
87  const std::string & indent_ = "",
88  bool inherit_ = false) const;
89 
90  protected :
91 
93  double _eval(double x_) const;
94 
96  void _set_defaults();
97 
98  private:
99 
101  void _recompute_();
102 
103  private:
104 
105  // Working data:
106  struct term_type;
107  std::vector<term_type> _terms_;
108  bool _explicit_domain_of_definition_;
109  double _non_zero_domain_min_;
110  double _non_zero_domain_max_;
111 
114 
115  };
116 
117 } // end of namespace mygsl
118 
119 #endif // MYGSL_LINEAR_COMBINATION_FUNCTION_H
120 
121 // Local Variables:
122 // mode: c++
123 // coding: utf-8
124 // End:
virtual ~linear_combination_function()
Destructor.
std::size_t add(double weight_, const i_unary_function &)
Add a weighted term.
virtual bool is_initialized() const
Check initialization status.
void change_weight(int term_index_, double weight_)
Change weight.
A linear combination function.
Definition: linear_combination_function.h:37
void reset()
Reset the composite function.
virtual double get_non_zero_domain_min() const
The minimum bound of the non-zero domain (default is minus infinity)
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart printing.
Abstract interface for unary functions : R -> R.
Definition: i_unary_function.h:44
virtual bool is_in_domain_of_definition(double x_) const
Check if a value is in the explicit domain of definition (default: true)
double _eval(double x_) const
Evaluation.
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
virtual bool has_explicit_domain_of_definition() const
Check if the function has an explicit domain of definition (default: false)
linear_combination_function()
Default constructor.
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
void _set_defaults()
Set default attributes values.
#define MYGSL_UNARY_FUNCTOR_REGISTRATION_INTERFACE(UnaryFunctorClass)
Definition: i_unary_function.h:206
virtual double get_non_zero_domain_max() const
The maximum bound of the non-zero domain (default is plus infinity)
virtual void initialize(const datatools::properties &config_, const unary_function_dict_type &functors_)
Initialization from a container of parameters and a dictionary of functors.
A dictionary of arbitrary properties.
Definition: properties.h:125