Go to the documentation of this file.
25 #include "spdlog/fmt/ostr.h"
26 #include "spdlog/spdlog.h"
39 #define AD_PHYSICS_WEIGHT_THROWS_EXCEPTION 1
41 #if SAFE_DATATYPES_EXPLICIT_CONVERSION
45 #define _AD_PHYSICS_WEIGHT_EXPLICIT_CONVERSION_ explicit
50 #define _AD_PHYSICS_WEIGHT_EXPLICIT_CONVERSION_
85 : mWeight(std::numeric_limits<double>::quiet_NaN())
166 return (mWeight > other.mWeight) &&
operator!=(other);
182 return (mWeight < other.mWeight) &&
operator!=(other);
198 return ((mWeight > other.mWeight) ||
operator==(other));
214 return ((mWeight < other.mWeight) ||
operator==(other));
231 Weight const result(mWeight + other.mWeight);
250 mWeight += other.mWeight;
269 Weight const result(mWeight - other.mWeight);
288 mWeight -= other.mWeight;
306 Weight const result(mWeight * scalar);
323 Weight const scalarWeight(scalar);
324 Weight const result(
operator/(scalarWeight));
344 double const result = mWeight / other.mWeight;
359 Weight const result(-mWeight);
384 auto const valueClass = std::fpclassify(mWeight);
385 return ((valueClass == FP_NORMAL) || (valueClass == FP_ZERO)) && (
cMinValue <= mWeight) && (mWeight <=
cMaxValue);
398 spdlog::info(
"ensureValid(::ad::physics::Weight)>> {} value out of range", *
this);
399 #if (AD_PHYSICS_WEIGHT_THROWS_EXCEPTION == 1)
400 throw std::out_of_range(
"Weight value out of range");
414 if (
operator==(
Weight(0.)))
416 spdlog::info(
"ensureValid(::ad::physics::Weight)>> {} value is zero", *
this);
417 #if (AD_PHYSICS_WEIGHT_THROWS_EXCEPTION == 1)
418 throw std::out_of_range(
"Weight value is zero");
469 return value.operator*(other);
480 inline ::ad::physics::Weight
fabs(const ::ad::physics::Weight other)
500 static inline ::ad::physics::Weight
lowest()
502 return ::ad::physics::Weight::getMin();
507 static inline ::ad::physics::Weight
max()
509 return ::ad::physics::Weight::getMax();
517 return ::ad::physics::Weight::getPrecision();
526 #ifndef GEN_GUARD_AD_PHYSICS_WEIGHT
527 #define GEN_GUARD_AD_PHYSICS_WEIGHT
548 return os << double(_value);
560 return to_string(
static_cast<double>(value));
563 #endif // GEN_GUARD_AD_PHYSICS_WEIGHT
static const double cMaxValue
constant defining the maximum valid Weight value (used in isValid())
Definition: Weight.hpp:70
namespace ad
Definition: Acceleration.hpp:30
bool isValid() const
Definition: Weight.hpp:382
static Weight getMin()
get minimum valid Weight (i.e. cMinValue)
Definition: Weight.hpp:426
_AD_PHYSICS_WEIGHT_EXPLICIT_CONVERSION_ Weight(double const iWeight)
standard constructor
Definition: Weight.hpp:94
double operator/(const Weight &other) const
standard arithmetic operator
Definition: Weight.hpp:340
Weight operator-=(const Weight &other)
standard arithmetic operator
Definition: Weight.hpp:284
Weight operator-() const
standard arithmetic operator
Definition: Weight.hpp:356
Weight operator-(const Weight &other) const
standard arithmetic operator
Definition: Weight.hpp:265
Weight operator*(const double &scalar) const
standard arithmetic operator
Definition: Weight.hpp:303
bool operator<(const Weight &other) const
standard comparison operator
Definition: Weight.hpp:178
Weight()
default constructor
Definition: Weight.hpp:84
static inline ::ad::physics::Weight epsilon()
Definition: Weight.hpp:515
inline ::ad::physics::Weight operator*(const double &other, ::ad::physics::Weight const &value)
standard arithmetic operator
Definition: Weight.hpp:467
bool operator>(const Weight &other) const
standard comparison operator
Definition: Weight.hpp:162
bool operator==(const Weight &other) const
standard comparison operator
Definition: Weight.hpp:134
Weight operator+(const Weight &other) const
standard arithmetic operator
Definition: Weight.hpp:227
static Weight getPrecision()
get assumed accuracy of Weight (i.e. cPrecisionValue)
Definition: Weight.hpp:442
Weight & operator=(const Weight &other)=default
standard assignment operator
static Weight getMax()
get maximum valid Weight (i.e. cMaxValue)
Definition: Weight.hpp:434
static inline ::ad::physics::Weight lowest()
Definition: Weight.hpp:500
#define _AD_PHYSICS_WEIGHT_EXPLICIT_CONVERSION_
Enable/Disable explicit conversion. Currently set to "implicit conversion allowed".
Definition: Weight.hpp:50
Weight operator/(const double &scalar) const
standard arithmetic operator
Definition: Weight.hpp:321
void ensureValidNonZero() const
ensure that the Weight is valid and non zero
Definition: Weight.hpp:411
DataType Weight.
Definition: Weight.hpp:59
inline ::ad::physics::Weight fabs(const ::ad::physics::Weight other)
overload of the std::fabs for Weight
Definition: Weight.hpp:480
static const double cPrecisionValue
constant defining the assumed Weight value accuracy (used in comparison operator==(),...
Definition: Weight.hpp:76
inline ::ad::physics::Acceleration fabs(const ::ad::physics::Acceleration other)
overload of the std::fabs for Acceleration
Definition: Acceleration.hpp:481
static inline ::ad::physics::Weight max()
Definition: Weight.hpp:507
static const double cMinValue
constant defining the minimum valid Weight value (used in isValid())
Definition: Weight.hpp:65
std::string to_string(::ad::physics::Acceleration const &value)
overload of the std::to_string for Acceleration
Definition: Acceleration.hpp:559
bool operator<=(const Weight &other) const
standard comparison operator
Definition: Weight.hpp:210
bool operator!=(const Weight &other) const
standard comparison operator
Definition: Weight.hpp:148
void ensureValid() const
ensure that the Weight is valid
Definition: Weight.hpp:394
std::ostream & operator<<(std::ostream &os, Acceleration const &_value)
standard ostream operator
Definition: Acceleration.hpp:547
Weight & operator+=(const Weight &other)
standard arithmetic operator
Definition: Weight.hpp:246
bool operator>=(const Weight &other) const
standard comparison operator
Definition: Weight.hpp:194