Bayeux  3.4.1
Core Foundation library for SuperNEMO
tabulated_sampling.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_TABULATED_SAMPLING_H
22 #define MYGSL_TABULATED_SAMPLING_H
23 
24 // Standard library:
25 #include <vector>
26 
27 // This project:
28 #include <mygsl/base_sampling.h>
29 
30 namespace mygsl {
31 
34  : public base_sampling
35  {
36  public:
37 
40 
42  virtual ~tabulated_sampling();
43 
45  virtual double get_min() const;
46 
48  virtual double get_max() const;
49 
51  std::size_t get_nsteps() const;
52 
54  std::size_t get_nsamples() const;
55 
57  double get_guard() const;
58 
60  double get_min_step() const;
61 
63  double get_max_step() const;
64 
66  virtual bool is_initialized() const;
67 
69  virtual void initialize(const datatools::properties &);
70 
72  virtual void reset();
73 
75  virtual bool value_to_index(const double x_,
76  std::size_t & index_,
77  sampling::index_classification_type & classification_flags_) const;
78 
81  index_to_value(const std::size_t index_,
82  double & value_) const;
83 
85  void set_guard(const double guard_);
86 
88  void append(const double value_);
89 
98  void make_ordered(const std::vector<double> & values_, const double guard_ = 0.0);
99 
101  void lock();
102 
103  private:
104 
105  void _set_guard_(double guard_);
106 
107  void _check_guard_();
108 
109  void _init_();
110 
111  void _reset_();
112 
113  private:
114 
115  // Management:
116  bool _initialized_ = false;
117 
118  // Configuration:
119  std::vector<double> _table_;
120  double _guard_;
121 
122  // Internals:
123  double _min_step_;
124  double _max_step_;
125 
126  };
127 
128 } // end of namespace mygsl
129 
130 #endif // MYGSL_BASE_SAMPLING_H
131 
132 // Local Variables: --
133 // mode: c++ --
134 // c-file-style: "gnu" --
135 // tab-width: 2 --
136 // End: --
virtual void initialize(const datatools::properties &)
Reset/invalidate the sampling.
Base class for all sampling models.
Definition: base_sampling.h:34
virtual bool is_initialized() const
Check the initialization status of the sampling.
void make_ordered(const std::vector< double > &values_, const double guard_=0.0)
std::size_t get_nsamples() const
Return the number of nsamples.
double get_max_step() const
Return the maximum step.
virtual void reset()
Reset/invalidate the sampling.
Base sampling.
double get_guard() const
Return the absolute guard distance around sampling alues.
Tabulated sampling model.
Definition: tabulated_sampling.h:33
void set_guard(const double guard_)
Set the absolute guard distance around sampling alues.
index_classification_type
Definition: sampling_utils.h:53
tabulated_sampling()
Default constructor.
virtual double get_max() const
Return the maximum sample.
double get_min_step() const
Return the minimum step.
virtual double get_min() const
Return the minimum sample.
std::size_t get_nsteps() const
Return the number of steps.
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
virtual bool value_to_index(const double x_, std::size_t &index_, sampling::index_classification_type &classification_flags_) const
Return the index and a classification associated to a value.
virtual ~tabulated_sampling()
Destructor.
void lock()
Lock the sampling table.
virtual sampling::index_classification_type index_to_value(const std::size_t index_, double &value_) const
Return the value associated to a given index.
void append(const double value_)
Add a tabulated value.
A dictionary of arbitrary properties.
Definition: properties.h:125