Bayeux  3.4.1
Core Foundation library for SuperNEMO
base_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_BASE_SAMPLING_H
22 #define MYGSL_BASE_SAMPLING_H
23 
24 // Third party:
25 // - Bayeux/datatools:
26 #include <datatools/properties.h>
27 
28 // This project:
29 #include <mygsl/sampling_utils.h>
30 
31 namespace mygsl {
32 
35  {
36  public:
37 
39  base_sampling();
40 
42  virtual ~base_sampling();
43 
45  virtual double get_min() const = 0;
46 
48  virtual double get_max() const = 0;
49 
51  virtual std::size_t get_nsteps() const = 0;
52 
54  virtual std::size_t get_nsamples() const = 0;
55 
57  virtual bool is_initialized() const = 0;
58 
60  virtual void initialize(const datatools::properties &) = 0;
61 
63  virtual void reset() = 0;
64 
66  virtual bool value_to_index(const double x_,
67  std::size_t & left_sample_index_,
68  sampling::index_classification_type & classification_) const = 0;
69 
71  bool value_to_index(const double x_, std::size_t & left_sample_index_) const;
72 
75  index_to_value(const std::size_t sample_index_, double & value_) const = 0;
76 
78  virtual bool has_index(const double value_, const std::size_t sample_index_) const;
79 
81  std::size_t get_first_index() const;
82 
84  std::size_t get_last_index() const;
85 
87  std::size_t get_first_step_index() const;
88 
90  std::size_t get_last_step_index() const;
91 
93  bool index_is_valid(const std::size_t sample_index_) const;
94 
96  bool value_is_valid(const double value_) const;
97 
99  bool compute_step_bounds(const std::size_t step_index_, double & min_, double & max_) const;
100 
101  };
102 
103 } // end of namespace mygsl
104 
105 #endif // MYGSL_BASE_SAMPLING_H
106 
107 // Local Variables: --
108 // mode: c++ --
109 // c-file-style: "gnu" --
110 // tab-width: 2 --
111 // End: --
virtual sampling::index_classification_type index_to_value(const std::size_t sample_index_, double &value_) const =0
Return the value associated to a given sample index.
virtual double get_max() const =0
Return the maximum sample.
std::size_t get_first_step_index() const
Return the first step index.
virtual bool has_index(const double value_, const std::size_t sample_index_) const
Check if the checked value is associated to the given sample index.
bool index_is_valid(const std::size_t sample_index_) const
Check if a sample index is valid.
Base class for all sampling models.
Definition: base_sampling.h:34
bool compute_step_bounds(const std::size_t step_index_, double &min_, double &max_) const
Compute the bounds of step with given index.
virtual bool is_initialized() const =0
Check the initialization status of the sampling.
virtual bool value_to_index(const double x_, std::size_t &left_sample_index_, sampling::index_classification_type &classification_) const =0
Return the left sample index and a classification associated to a value.
std::size_t get_last_step_index() const
Return the last step index.
index_classification_type
Definition: sampling_utils.h:53
virtual void reset()=0
Reset/invalidate the sampling.
std::size_t get_first_index() const
Return the first sample index.
virtual ~base_sampling()
Destructor.
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
std::size_t get_last_index() const
Return the last sample index.
base_sampling()
Default constructor.
Sampling utilities.
bool value_is_valid(const double value_) const
Check if a value is in the sampling domain.
virtual std::size_t get_nsteps() const =0
Return the number of steps.
virtual double get_min() const =0
Return the minimum sample.
virtual void initialize(const datatools::properties &)=0
Initialize from a set of properties.
virtual std::size_t get_nsamples() const =0
Return the number of samples.
A dictionary of arbitrary properties.
Definition: properties.h:125