Bayeux  3.4.1
Core Foundation library for SuperNEMO
triangle_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_TRIANGLE_FUNCTION_H
22 #define MYGSL_TRIANGLE_FUNCTION_H
23 
24 // Standard library:
25 #include <limits>
26 
27 // Third party:
28 // - Bayeux/datatools :
29 #include <datatools/i_cloneable.h>
30 
31 // This project:
32 #include <mygsl/i_unary_function.h>
33 
34 namespace mygsl {
35 
52  : public i_unary_function,
54  {
55  public:
56 
59 
61  triangle_function(double full_width_,
62  double center_,
63  double amplitude_);
64 
66  triangle_function(double head_width_,
67  double tail_width_,
68  double center_,
69  double amplitude_);
70 
72  virtual ~triangle_function();
73 
75  virtual bool is_initialized() const;
76 
78  virtual void initialize(const datatools::properties & config_,
79  const unary_function_dict_type & functors_);
80 
82  void reset();
83 
85  void set_head_width(double head_width_);
86 
88  double get_head_width() const;
89 
91  void set_tail_width(double tail_width_);
92 
94  double get_tail_width() const;
95 
97  void set_center(double center_);
98 
100  double get_center() const;
101 
103  void set_amplitude(double amplitude_);
104 
106  double get_amplitude() const;
107 
109  double get_non_zero_domain_min() const;
110 
112  double get_non_zero_domain_max() const;
113 
115  virtual void tree_dump(std::ostream & out_ = std::clog,
116  const std::string & title_ = "",
117  const std::string & indent_ = "",
118  bool inherit_ = false) const;
119 
120  protected:
121 
123  double _eval(double x_) const;
124 
126  void _set_defaults();
127 
128  private:
129 
130  double _center_;
131  double _head_width_;
132  double _tail_width_;
133  double _amplitude_;
134 
137 
138 
140 
141  };
142 
143 } // end of namespace mygsl
144 
145 #endif // MYGSL_TRIANGLE_FUNCTION_H
146 
147 // Local Variables: --
148 // mode: c++ --
149 // c-file-style: "gnu" --
150 // tab-width: 2 --
151 // End: --
void set_head_width(double head_width_)
Set the head width.
#define DATATOOLS_CLONEABLE_DECLARATION(Copyable)
Definition: i_cloneable.h:113
triangle_function()
Default constructor.
double get_non_zero_domain_max() const
The maximum bound of the non-zero domain (default is plus infinity)
void set_amplitude(double amplitude_)
Set the amplitude.
virtual ~triangle_function()
Destructor.
virtual void initialize(const datatools::properties &config_, const unary_function_dict_type &functors_)
Initialization from a container of parameters and a dictionary of functors.
double get_center() const
Return the center.
double get_head_width() const
Return the head width.
double get_non_zero_domain_min() const
The minimum bound of the non-zero domain (default is plus infinity)
double get_tail_width() const
Return the tail width.
void _set_defaults()
Set default attributes values.
Abstract interface for unary functions : R -> R.
Definition: i_unary_function.h:44
double _eval(double x_) const
Evaluation.
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
A pure abstract class (interface) for inherited cloneable classes.
Definition: i_cloneable.h:75
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart printing.
void reset()
Reset the function.
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
void set_tail_width(double tail_width_)
Set the tail width.
double get_amplitude() const
Return the amplitude.
virtual bool is_initialized() const
Check initialization status.
General asymmetric triangle function.
Definition: triangle_function.h:51
void set_center(double center_)
Set the center.
A dictionary of arbitrary properties.
Definition: properties.h:125