Helpers.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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_FUNCTIONS_HH_
18 #define IGNITION_MATH_FUNCTIONS_HH_
19 
20 #include <cmath>
21 #include <algorithm>
22 #include <limits>
23 #include <string>
24 #include <iostream>
25 #include <vector>
26 #include <tuple>
27 #include <cstdint>
28 
29 #include <ignition/math/config.hh>
30 #include "ignition/math/Export.hh"
31 
34 #define IGN_DBL_MAX ignition::math::DPRCT_MAX_D
35 
38 #define IGN_DBL_MIN ignition::math::DPRCT_MIN_D
39 
42 #define IGN_DBL_LOW ignition::math::DPRCT_LOW_D
43 
46 #define IGN_DBL_INF ignition::math::DPRCT_INF_D
47 
50 #define IGN_FLT_MAX ignition::math::DPRCT_MAX_F
51 
54 #define IGN_FLT_MIN ignition::math::DPRCT_MIN_F
55 
58 #define IGN_FLT_LOW ignition::math::DPRCT_LOW_F
59 
62 #define IGN_FLT_INF ignition::math::DPRCT_INF_F
63 
66 #define IGN_UINT16_MAX ignition::math::DPRCT_MAX_UI16
67 
70 #define IGN_UINT16_MIN ignition::math::DPRCT_MIN_UI16
71 
75 #define IGN_UINT16_LOW ignition::math::DPRCT_LOW_UI16
76 
79 #define IGN_UINT16_INF ignition::math::DPRCT_INF_UI16
80 
83 #define IGN_INT16_MAX ignition::math::DPRCT_MAX_I16
84 
87 #define IGN_INT16_MIN ignition::math::DPRCT_MIN_I16
88 
92 #define IGN_INT16_LOW ignition::math::DPRCT_LOW_I16
93 
96 #define IGN_INT16_INF ignition::math::DPRCT_INF_I16
97 
100 #define IGN_UINT32_MAX ignition::math::DPRCT_MAX_UI32
101 
104 #define IGN_UINT32_MIN ignition::math::DPRCT_MIN_UI32
105 
109 #define IGN_UINT32_LOW ignition::math::DPRCT_LOW_UI32
110 
113 #define IGN_UINT32_INF ignition::math::DPRCT_INF_UI32
114 
117 #define IGN_INT32_MAX ignition::math::DPRCT_MAX_I32
118 
121 #define IGN_INT32_MIN ignition::math::DPRCT_MIN_I32
122 
126 #define IGN_INT32_LOW ignition::math::DPRCT_LOW_I32
127 
130 #define IGN_INT32_INF ignition::math::DPRCT_INF_I32
131 
134 #define IGN_UINT64_MAX ignition::math::DPRCT_MAX_UI64
135 
138 #define IGN_UINT64_MIN ignition::math::DPRCT_MIN_UI64
139 
143 #define IGN_UINT64_LOW ignition::math::DPRCT_LOW_UI64
144 
147 #define IGN_UINT64_INF ignition::math::DPRCT_INF_UI64
148 
151 #define IGN_INT64_MAX ignition::math::DPRCT_MAX_I64
152 
155 #define IGN_INT64_MIN ignition::math::DPRCT_MIN_I64
156 
160 #define IGN_INT64_LOW ignition::math::DPRCT_LOW_I64
161 
164 #define IGN_INT64_INF ignition::math::DPRCT_INF_I64
165 
168 #ifdef M_PI
169 #define IGN_PI M_PI
170 #define IGN_PI_2 M_PI_2
171 #define IGN_PI_4 M_PI_4
172 #define IGN_SQRT2 M_SQRT2
173 #else
174 #define IGN_PI 3.14159265358979323846
175 #define IGN_PI_2 1.57079632679489661923
176 #define IGN_PI_4 0.78539816339744830962
177 #define IGN_SQRT2 1.41421356237309504880
178 #endif
179 
183 #if defined __FLT_EVAL_METHOD__ && __FLT_EVAL_METHOD__ == 2
184 #define IGN_FP_VOLATILE volatile
185 #else
186 #define IGN_FP_VOLATILE
187 #endif
188 
191 #define IGN_SPHERE_VOLUME(_radius) (4.0*IGN_PI*std::pow(_radius, 3)/3.0)
192 
196 #define IGN_CYLINDER_VOLUME(_r, _l) (_l * IGN_PI * std::pow(_r, 2))
197 
202 #define IGN_BOX_VOLUME(_x, _y, _z) (_x *_y * _z)
203 
206 #define IGN_BOX_VOLUME_V(_v) (_v.X() *_v.Y() * _v.Z())
207 
208 namespace ignition
209 {
211  namespace math
212  {
213  inline namespace IGNITION_MATH_VERSION_NAMESPACE
214  {
216  static const size_t IGN_ZERO_SIZE_T = 0u;
217 
219  static const size_t IGN_ONE_SIZE_T = 1u;
220 
222  static const size_t IGN_TWO_SIZE_T = 2u;
223 
225  static const size_t IGN_THREE_SIZE_T = 3u;
226 
228  static const size_t IGN_FOUR_SIZE_T = 4u;
229 
231  static const size_t IGN_FIVE_SIZE_T = 5u;
232 
234  static const size_t IGN_SIX_SIZE_T = 6u;
235 
237  static const size_t IGN_SEVEN_SIZE_T = 7u;
238 
240  static const size_t IGN_EIGHT_SIZE_T = 8u;
241 
243  static const size_t IGN_NINE_SIZE_T = 9u;
244 
246  static const double MAX_D = std::numeric_limits<double>::max();
247 
249  static const double MIN_D = std::numeric_limits<double>::min();
250 
252  static const double LOW_D = std::numeric_limits<double>::lowest();
253 
255  static const double INF_D = std::numeric_limits<double>::infinity();
256 
258  static const double NAN_D = std::numeric_limits<double>::quiet_NaN();
259 
261  static const float MAX_F = std::numeric_limits<float>::max();
262 
264  static const float MIN_F = std::numeric_limits<float>::min();
265 
267  static const float LOW_F = std::numeric_limits<float>::lowest();
268 
270  static const float INF_F = std::numeric_limits<float>::infinity();
271 
273  static const float NAN_F = std::numeric_limits<float>::quiet_NaN();
274 
276  static const uint16_t MAX_UI16 = std::numeric_limits<uint16_t>::max();
277 
279  static const uint16_t MIN_UI16 = std::numeric_limits<uint16_t>::min();
280 
283  static const uint16_t LOW_UI16 = std::numeric_limits<uint16_t>::lowest();
284 
286  static const uint16_t INF_UI16 = std::numeric_limits<uint16_t>::infinity();
287 
289  static const int16_t MAX_I16 = std::numeric_limits<int16_t>::max();
290 
292  static const int16_t MIN_I16 = std::numeric_limits<int16_t>::min();
293 
296  static const int16_t LOW_I16 = std::numeric_limits<int16_t>::lowest();
297 
299  static const int16_t INF_I16 = std::numeric_limits<int16_t>::infinity();
300 
302  static const uint32_t MAX_UI32 = std::numeric_limits<uint32_t>::max();
303 
305  static const uint32_t MIN_UI32 = std::numeric_limits<uint32_t>::min();
306 
309  static const uint32_t LOW_UI32 = std::numeric_limits<uint32_t>::lowest();
310 
312  static const uint32_t INF_UI32 = std::numeric_limits<uint32_t>::infinity();
313 
315  static const int32_t MAX_I32 = std::numeric_limits<int32_t>::max();
316 
318  static const int32_t MIN_I32 = std::numeric_limits<int32_t>::min();
319 
322  static const int32_t LOW_I32 = std::numeric_limits<int32_t>::lowest();
323 
325  static const int32_t INF_I32 = std::numeric_limits<int32_t>::infinity();
326 
328  static const uint64_t MAX_UI64 = std::numeric_limits<uint64_t>::max();
329 
331  static const uint64_t MIN_UI64 = std::numeric_limits<uint64_t>::min();
332 
335  static const uint64_t LOW_UI64 = std::numeric_limits<uint64_t>::lowest();
336 
338  static const uint64_t INF_UI64 = std::numeric_limits<uint64_t>::infinity();
339 
341  static const int64_t MAX_I64 = std::numeric_limits<int64_t>::max();
342 
344  static const int64_t MIN_I64 = std::numeric_limits<int64_t>::min();
345 
348  static const int64_t LOW_I64 = std::numeric_limits<int64_t>::lowest();
349 
351  static const int64_t INF_I64 = std::numeric_limits<int64_t>::infinity();
352 
354  static const int NAN_I = std::numeric_limits<int>::quiet_NaN();
355 
356  // variables created to deprecate macros in this file
357  static const double IGN_DEPRECATED(3) DPRCT_MAX_D = MAX_D;
358  static const double IGN_DEPRECATED(3) DPRCT_MIN_D = MIN_D;
359  static const double IGN_DEPRECATED(3) DPRCT_LOW_D = LOW_D;
360  static const double IGN_DEPRECATED(3) DPRCT_INF_D = INF_D;
361  static const float IGN_DEPRECATED(3) DPRCT_MAX_F = MAX_F;
362  static const float IGN_DEPRECATED(3) DPRCT_MIN_F = MIN_F;
363  static const float IGN_DEPRECATED(3) DPRCT_LOW_F = LOW_F;
364  static const float IGN_DEPRECATED(3) DPRCT_INF_F = INF_F;
365  static const uint16_t IGN_DEPRECATED(3) DPRCT_MAX_UI16 = MAX_UI16;
366  static const uint16_t IGN_DEPRECATED(3) DPRCT_MIN_UI16 = MIN_UI16;
367  static const uint16_t IGN_DEPRECATED(3) DPRCT_LOW_UI16 = LOW_UI16;
368  static const uint16_t IGN_DEPRECATED(3) DPRCT_INF_UI16 = INF_UI16;
369  static const int16_t IGN_DEPRECATED(3) DPRCT_MAX_I16 = MAX_I16;
370  static const int16_t IGN_DEPRECATED(3) DPRCT_MIN_I16 = MIN_I16;
371  static const int16_t IGN_DEPRECATED(3) DPRCT_LOW_I16 = LOW_I16;
372  static const int16_t IGN_DEPRECATED(3) DPRCT_INF_I16 = INF_I16;
373  static const uint32_t IGN_DEPRECATED(3) DPRCT_MAX_UI32 = MAX_UI32;
374  static const uint32_t IGN_DEPRECATED(3) DPRCT_MIN_UI32 = MIN_UI32;
375  static const uint32_t IGN_DEPRECATED(3) DPRCT_LOW_UI32 = LOW_UI32;
376  static const uint32_t IGN_DEPRECATED(3) DPRCT_INF_UI32 = INF_UI32;
377  static const int32_t IGN_DEPRECATED(3) DPRCT_MAX_I32 = MAX_I32;
378  static const int32_t IGN_DEPRECATED(3) DPRCT_MIN_I32 = MIN_I32;
379  static const int32_t IGN_DEPRECATED(3) DPRCT_LOW_I32 = LOW_I32;
380  static const int32_t IGN_DEPRECATED(3) DPRCT_INF_I32 = INF_I32;
381  static const uint64_t IGN_DEPRECATED(3) DPRCT_MAX_UI64 = MAX_UI64;
382  static const uint64_t IGN_DEPRECATED(3) DPRCT_MIN_UI64 = MIN_UI64;
383  static const uint64_t IGN_DEPRECATED(3) DPRCT_LOW_UI64 = LOW_UI64;
384  static const uint64_t IGN_DEPRECATED(3) DPRCT_INF_UI64 = INF_UI64;
385  static const int64_t IGN_DEPRECATED(3) DPRCT_MAX_I64 = MAX_I64;
386  static const int64_t IGN_DEPRECATED(3) DPRCT_MIN_I64 = MIN_I64;
387  static const int64_t IGN_DEPRECATED(3) DPRCT_LOW_I64 = LOW_I64;
388  static const int64_t IGN_DEPRECATED(3) DPRCT_INF_I64 = INF_I64;
389 
394  template<typename T>
395  inline T clamp(T _v, T _min, T _max)
396  {
397  return std::max(std::min(_v, _max), _min);
398  }
399 
403  inline bool isnan(float _v)
404  {
405  return (std::isnan)(_v);
406  }
407 
411  inline bool isnan(double _v)
412  {
413  return (std::isnan)(_v);
414  }
415 
419  inline float fixnan(float _v)
420  {
421  return isnan(_v) || std::isinf(_v) ? 0.0f : _v;
422  }
423 
427  inline double fixnan(double _v)
428  {
429  return isnan(_v) || std::isinf(_v) ? 0.0 : _v;
430  }
431 
435  inline bool isEven(const int _v)
436  {
437  return !(_v % 2);
438  }
439 
443  inline bool isEven(const unsigned int _v)
444  {
445  return !(_v % 2);
446  }
447 
451  inline bool isOdd(const int _v)
452  {
453  return (_v % 2) != 0;
454  }
455 
459  inline bool isOdd(const unsigned int _v)
460  {
461  return (_v % 2) != 0;
462  }
463 
470  template<typename T>
471  inline int sgn(T _value)
472  {
473  return (T(0) < _value) - (_value < T(0));
474  }
475 
482  template<typename T>
483  inline int signum(T _value)
484  {
485  return sgn(_value);
486  }
487 
491  template<typename T>
492  inline T mean(const std::vector<T> &_values)
493  {
494  T sum = 0;
495  for (unsigned int i = 0; i < _values.size(); ++i)
496  sum += _values[i];
497  return sum / _values.size();
498  }
499 
503  template<typename T>
504  inline T variance(const std::vector<T> &_values)
505  {
506  T avg = mean<T>(_values);
507 
508  T sum = 0;
509  for (unsigned int i = 0; i < _values.size(); ++i)
510  sum += (_values[i] - avg) * (_values[i] - avg);
511  return sum / _values.size();
512  }
513 
517  template<typename T>
518  inline T max(const std::vector<T> &_values)
519  {
521  for (unsigned int i = 0; i < _values.size(); ++i)
522  if (_values[i] > max)
523  max = _values[i];
524  return max;
525  }
526 
530  template<typename T>
531  inline T min(const std::vector<T> &_values)
532  {
534  for (unsigned int i = 0; i < _values.size(); ++i)
535  if (_values[i] < min)
536  min = _values[i];
537  return min;
538  }
539 
544  template<typename T>
545  inline bool equal(const T &_a, const T &_b,
546  const T &_epsilon = T(1e-6))
547  {
548  IGN_FP_VOLATILE T diff = std::abs(_a - _b);
549  return diff <= _epsilon;
550  }
551 
556  template<typename T>
557  inline bool lessOrNearEqual(const T &_a, const T &_b,
558  const T &_epsilon = 1e-6)
559  {
560  return _a < _b + _epsilon;
561  }
562 
567  template<typename T>
568  inline bool greaterOrNearEqual(const T &_a, const T &_b,
569  const T &_epsilon = 1e-6)
570  {
571  return _a > _b - _epsilon;
572  }
573 
578  template<typename T>
579  inline T precision(const T &_a, const unsigned int &_precision)
580  {
581  auto p = std::pow(10, _precision);
582  return static_cast<T>(std::round(_a * p) / p);
583  }
584 
588  template<typename T>
589  inline void sort2(T &_a, T &_b)
590  {
591  using std::swap;
592  if (_b < _a)
593  swap(_a, _b);
594  }
595 
600  template<typename T>
601  inline void sort3(T &_a, T &_b, T &_c)
602  {
603  // _a <= _b
604  sort2(_a, _b);
605  // _a <= _c, _b <= _c
606  sort2(_b, _c);
607  // _a <= _b <= _c
608  sort2(_a, _b);
609  }
610 
614  inline bool isPowerOfTwo(unsigned int _x)
615  {
616  return ((_x != 0) && ((_x & (~_x + 1)) == _x));
617  }
618 
624  inline unsigned int roundUpPowerOfTwo(unsigned int _x)
625  {
626  if (_x == 0)
627  return 1;
628 
629  if (isPowerOfTwo(_x))
630  return _x;
631 
632  while (_x & (_x - 1))
633  _x = _x & (_x - 1);
634 
635  _x = _x << 1;
636 
637  return _x;
638  }
639 
643  inline int parseInt(const std::string &_input)
644  {
645  // Return NAN_I if it is empty
646  if (_input.empty())
647  {
648  return NAN_I;
649  }
650  // Return 0 if it is all spaces
651  else if (_input.find_first_not_of(' ') == std::string::npos)
652  {
653  return 0;
654  }
655 
656  // Otherwise try standard library
657  try
658  {
659  return std::stoi(_input);
660  }
661  // if that fails, return NAN_I
662  catch(...)
663  {
664  return NAN_I;
665  }
666  }
667 
672  inline double parseFloat(const std::string &_input)
673  {
674  // Return NAN_D if it is empty
675  if (_input.empty())
676  {
677  return NAN_D;
678  }
679  // Return 0 if it is all spaces
680  else if (_input.find_first_not_of(' ') == std::string::npos)
681  {
682  return 0;
683  }
684 
685  // Otherwise try standard library
686  try
687  {
688  return std::stod(_input);
689  }
690  // if that fails, return NAN_D
691  catch(...)
692  {
693  return NAN_D;
694  }
695  }
696 
697 
698  // Degrade precision on Windows, which cannot handle 'long double'
699  // values properly. See the implementation of Unpair.
700  // 32 bit ARM processors also define 'long double' to be the same
701  // size as 'double', and must also be degraded
702 #if defined _MSC_VER || defined __arm__
703  using PairInput = uint16_t;
704  using PairOutput = uint32_t;
705 #else
706  using PairInput = uint32_t;
707  using PairOutput = uint64_t;
708 #endif
709 
719  PairOutput IGNITION_MATH_VISIBLE Pair(
720  const PairInput _a, const PairInput _b);
721 
733  std::tuple<PairInput, PairInput> IGNITION_MATH_VISIBLE Unpair(
734  const PairOutput _key);
735  }
736  }
737 }
738 
739 #endif
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::isnan
bool isnan(float _v)
check if a float is NaN
Definition: Helpers.hh:403
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_SIX_SIZE_T
static const size_t IGN_SIX_SIZE_T
size_t type with a value of 6
Definition: Helpers.hh:234
ignition
Definition: Angle.hh:39
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::fixnan
float fixnan(float _v)
Fix a nan value.
Definition: Helpers.hh:419
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::INF_I32
static const int32_t INF_I32
32-bit unsigned integer positive infinite value
Definition: Helpers.hh:325
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::signum
int signum(T _value)
The signum function.
Definition: Helpers.hh:483
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::precision
T precision(const T &_a, const unsigned int &_precision)
get value at a specified precision
Definition: Helpers.hh:579
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MIN_I32
static const int32_t MIN_I32
32bit unsigned integer minimum value
Definition: Helpers.hh:318
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ONE_SIZE_T
static const size_t IGN_ONE_SIZE_T
size_t type with a value of 1
Definition: Helpers.hh:219
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MAX_UI64
static const uint64_t MAX_UI64
64bit unsigned integer maximum value
Definition: Helpers.hh:328
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::INF_I16
static const int16_t INF_I16
16-bit unsigned integer positive infinite value
Definition: Helpers.hh:299
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MIN_D
static const double MIN_D
Double min value. This value will be similar to 2.22507e-308.
Definition: Helpers.hh:249
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MIN_F
static const float MIN_F
Float minimum value. This value will be similar to 1.17549e-38.
Definition: Helpers.hh:264
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_SEVEN_SIZE_T
static const size_t IGN_SEVEN_SIZE_T
size_t type with a value of 7
Definition: Helpers.hh:237
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::sort2
void sort2(T &_a, T &_b)
Sort two numbers, such that _a <= _b.
Definition: Helpers.hh:589
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::min
T min(const std::vector< T > &_values)
get the minimum value of vector of values
Definition: Helpers.hh:531
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MIN_UI64
static const uint64_t MIN_UI64
64bit unsigned integer minimum value
Definition: Helpers.hh:331
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::mean
T mean(const std::vector< T > &_values)
get mean of vector of values
Definition: Helpers.hh:492
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MAX_I32
static const int32_t MAX_I32
32bit unsigned integer maximum value
Definition: Helpers.hh:315
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::lessOrNearEqual
bool lessOrNearEqual(const T &_a, const T &_b, const T &_epsilon=1e-6)
inequality test, within a tolerance
Definition: Helpers.hh:557
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::INF_D
static const double INF_D
Double positive infinite value.
Definition: Helpers.hh:255
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MAX_I16
static const int16_t MAX_I16
16bit unsigned integer maximum value
Definition: Helpers.hh:289
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::PairOutput
uint64_t PairOutput
Definition: Helpers.hh:707
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MIN_I64
static const int64_t MIN_I64
64bit unsigned integer minimum value
Definition: Helpers.hh:344
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_FIVE_SIZE_T
static const size_t IGN_FIVE_SIZE_T
size_t type with a value of 5
Definition: Helpers.hh:231
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MIN_I16
static const int16_t MIN_I16
16bit unsigned integer minimum value
Definition: Helpers.hh:292
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::LOW_F
static const float LOW_F
Float low value, equivalent to -MAX_F.
Definition: Helpers.hh:267
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::roundUpPowerOfTwo
unsigned int roundUpPowerOfTwo(unsigned int _x)
Get the smallest power of two that is greater or equal to a given value.
Definition: Helpers.hh:624
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::equal
bool equal(const T &_a, const T &_b, const T &_epsilon=T(1e-6))
check if two values are equal, within a tolerance
Definition: Helpers.hh:545
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::INF_F
static const float INF_F
float positive infinite value
Definition: Helpers.hh:270
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::variance
T variance(const std::vector< T > &_values)
get variance of vector of values
Definition: Helpers.hh:504
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::LOW_I32
static const int32_t LOW_I32
32bit unsigned integer lowest value.
Definition: Helpers.hh:322
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::sgn
int sgn(T _value)
The signum function.
Definition: Helpers.hh:471
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::INF_UI64
static const uint64_t INF_UI64
64-bit unsigned integer positive infinite value
Definition: Helpers.hh:338
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::INF_UI16
static const uint16_t INF_UI16
16-bit unsigned integer positive infinite value
Definition: Helpers.hh:286
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MAX_D
static const double MAX_D
Double maximum value. This value will be similar to 1.79769e+308.
Definition: Helpers.hh:246
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MIN_UI32
static const uint32_t MIN_UI32
32bit unsigned integer minimum value
Definition: Helpers.hh:305
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::isnan
bool isnan(double _v)
check if a double is NaN
Definition: Helpers.hh:411
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::isOdd
bool isOdd(const int _v)
Check if parameter is odd.
Definition: Helpers.hh:451
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::LOW_I64
static const int64_t LOW_I64
64bit unsigned integer lowest value.
Definition: Helpers.hh:348
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MAX_UI16
static const uint16_t MAX_UI16
16bit unsigned integer maximum value
Definition: Helpers.hh:276
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::isEven
bool isEven(const int _v)
Check if parameter is even.
Definition: Helpers.hh:435
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::LOW_UI64
static const uint64_t LOW_UI64
64bit unsigned integer lowest value.
Definition: Helpers.hh:335
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ZERO_SIZE_T
static const size_t IGN_ZERO_SIZE_T
size_t type with a value of 0
Definition: Helpers.hh:216
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::NAN_F
static const float NAN_F
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:273
IGN_FP_VOLATILE
#define IGN_FP_VOLATILE
Define IGN_FP_VOLATILE for FP equality comparisons Use volatile parameters when checking floating poi...
Definition: Helpers.hh:186
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Pair
PairOutput IGNITION_MATH_VISIBLE Pair(const PairInput _a, const PairInput _b)
A pairing function that maps two values to a unique third value.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_THREE_SIZE_T
static const size_t IGN_THREE_SIZE_T
size_t type with a value of 3
Definition: Helpers.hh:225
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MAX_F
static const float MAX_F
Float maximum value. This value will be similar to 3.40282e+38.
Definition: Helpers.hh:261
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::PairInput
uint32_t PairInput
Definition: Helpers.hh:706
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::sort3
void sort3(T &_a, T &_b, T &_c)
Sort three numbers, such that _a <= _b <= _c.
Definition: Helpers.hh:601
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Unpair
std::tuple< PairInput, PairInput > IGNITION_MATH_VISIBLE Unpair(const PairOutput _key)
The reverse of the Pair function.
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::parseFloat
double parseFloat(const std::string &_input)
parse string into float
Definition: Helpers.hh:672
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MIN_UI16
static const uint16_t MIN_UI16
16bit unsigned integer minimum value
Definition: Helpers.hh:279
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_FOUR_SIZE_T
static const size_t IGN_FOUR_SIZE_T
size_t type with a value of 4
Definition: Helpers.hh:228
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::isPowerOfTwo
bool isPowerOfTwo(unsigned int _x)
Is this a power of 2?
Definition: Helpers.hh:614
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MAX_I64
static const int64_t MAX_I64
64bit unsigned integer maximum value
Definition: Helpers.hh:341
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::NAN_I
static const int NAN_I
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:354
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::greaterOrNearEqual
bool greaterOrNearEqual(const T &_a, const T &_b, const T &_epsilon=1e-6)
inequality test, within a tolerance
Definition: Helpers.hh:568
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::LOW_UI32
static const uint32_t LOW_UI32
32bit unsigned integer lowest value.
Definition: Helpers.hh:309
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::max
T max(const std::vector< T > &_values)
get the maximum value of vector of values
Definition: Helpers.hh:518
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::LOW_I16
static const int16_t LOW_I16
16bit unsigned integer lowest value.
Definition: Helpers.hh:296
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_DEPRECATED
static const double IGN_DEPRECATED(3) DPRCT_MAX_D
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::parseInt
int parseInt(const std::string &_input)
parse string into an integer
Definition: Helpers.hh:643
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_NINE_SIZE_T
static const size_t IGN_NINE_SIZE_T
size_t type with a value of 9
Definition: Helpers.hh:243
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::INF_UI32
static const uint32_t INF_UI32
32-bit unsigned integer positive infinite value
Definition: Helpers.hh:312
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_TWO_SIZE_T
static const size_t IGN_TWO_SIZE_T
size_t type with a value of 2
Definition: Helpers.hh:222
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::LOW_D
static const double LOW_D
Double low value, equivalent to -MAX_D.
Definition: Helpers.hh:252
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::clamp
T clamp(T _v, T _min, T _max)
Simple clamping function.
Definition: Helpers.hh:395
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::NAN_D
static const double NAN_D
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:258
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::LOW_UI16
static const uint16_t LOW_UI16
16bit unsigned integer lowest value.
Definition: Helpers.hh:283
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::INF_I64
static const int64_t INF_I64
64-bit unsigned integer positive infinite value
Definition: Helpers.hh:351
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::MAX_UI32
static const uint32_t MAX_UI32
32bit unsigned integer maximum value
Definition: Helpers.hh:302
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_EIGHT_SIZE_T
static const size_t IGN_EIGHT_SIZE_T
size_t type with a value of 8
Definition: Helpers.hh:240