SignalStats.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_MATH_SIGNALSTATS_HH_
18 #define IGNITION_MATH_SIGNALSTATS_HH_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <ignition/math/Helpers.hh>
24 #include <ignition/math/config.hh>
25 
26 namespace ignition
27 {
28  namespace math
29  {
30  inline namespace IGNITION_MATH_VERSION_NAMESPACE
31  {
33  class SignalStatisticPrivate;
34 
37  class IGNITION_MATH_VISIBLE SignalStatistic
38  {
40  public: SignalStatistic();
41 
43  public: virtual ~SignalStatistic();
44 
47  public: SignalStatistic(const SignalStatistic &_ss);
48 
51  public: virtual double Value() const = 0;
52 
55  public: virtual std::string ShortName() const = 0;
56 
59  public: virtual size_t Count() const;
60 
63  public: virtual void InsertData(const double _data) = 0;
64 
66  public: virtual void Reset();
67 
68 #ifdef _WIN32
69 // Disable warning C4251 which is triggered by
70 // std::unique_ptr
71 #pragma warning(push)
72 #pragma warning(disable: 4251)
73 #endif
74  protected: std::unique_ptr<SignalStatisticPrivate> dataPtr;
76 #ifdef _WIN32
77 #pragma warning(pop)
78 #endif
79  };
81 
84  class IGNITION_MATH_VISIBLE SignalMaximum : public SignalStatistic
85  {
86  // Documentation inherited.
87  public: virtual double Value() const;
88 
91  public: virtual std::string ShortName() const;
92 
93  // Documentation inherited.
94  public: virtual void InsertData(const double _data);
95  };
97 
100  class IGNITION_MATH_VISIBLE SignalMean : public SignalStatistic
101  {
102  // Documentation inherited.
103  public: virtual double Value() const;
104 
107  public: virtual std::string ShortName() const;
108 
109  // Documentation inherited.
110  public: virtual void InsertData(const double _data);
111  };
113 
116  class IGNITION_MATH_VISIBLE SignalMinimum : public SignalStatistic
117  {
118  // Documentation inherited.
119  public: virtual double Value() const;
120 
123  public: virtual std::string ShortName() const;
124 
125  // Documentation inherited.
126  public: virtual void InsertData(const double _data);
127  };
129 
133  class IGNITION_MATH_VISIBLE SignalRootMeanSquare : public SignalStatistic
134  {
135  // Documentation inherited.
136  public: virtual double Value() const;
137 
140  public: virtual std::string ShortName() const;
141 
142  // Documentation inherited.
143  public: virtual void InsertData(const double _data);
144  };
146 
152  class IGNITION_MATH_VISIBLE SignalMaxAbsoluteValue : public SignalStatistic
153  {
154  // Documentation inherited.
155  public: virtual double Value() const;
156 
159  public: virtual std::string ShortName() const;
160 
161  // Documentation inherited.
162  public: virtual void InsertData(const double _data);
163  };
165 
169  class IGNITION_MATH_VISIBLE SignalVariance : public SignalStatistic
170  {
171  // Documentation inherited.
172  public: virtual double Value() const;
173 
176  public: virtual std::string ShortName() const;
177 
178  // Documentation inherited.
179  public: virtual void InsertData(const double _data);
180  };
182 
184  class SignalStatsPrivate;
185 
188  class IGNITION_MATH_VISIBLE SignalStats
189  {
191  public: SignalStats();
192 
194  public: ~SignalStats();
195 
198  public: SignalStats(const SignalStats &_ss);
199 
205  public: size_t Count() const;
206 
211  public: std::map<std::string, double> Map() const;
212 
215  public: void InsertData(const double _data);
216 
226  public: bool InsertStatistic(const std::string &_name);
227 
235  public: bool InsertStatistics(const std::string &_names);
236 
238  public: void Reset();
239 
243  public: SignalStats &operator=(const SignalStats &_s);
244 
245 #ifdef _WIN32
246 // Disable warning C4251 which is triggered by
247 // std::unique_ptr
248 #pragma warning(push)
249 #pragma warning(disable: 4251)
250 #endif
251  private: std::unique_ptr<SignalStatsPrivate> dataPtr;
253 #ifdef _WIN32
254 #pragma warning(pop)
255 #endif
256  };
257  }
259  }
260 }
261 #endif
262 
Statistical properties of a discrete time scalar signal.
Definition: SignalStats.hh:37
Computing the minimum value of a discretely sampled signal.
Definition: SignalStats.hh:116
Collection of statistics for a scalar signal.
Definition: SignalStats.hh:188
Computing the mean value of a discretely sampled signal.
Definition: SignalStats.hh:100
Computing the maximum value of a discretely sampled signal.
Definition: SignalStats.hh:84
Computing the square root of the mean squared value of a discretely sampled signal.
Definition: SignalStats.hh:133
Definition: Angle.hh:39
Computing the incremental variance of a discretely sampled signal.
Definition: SignalStats.hh:169
ignition/math/SignalStats.hh
Definition: SignalStats.hh:152