refactor: quantity::value() renamed to quantity::numerical_value()
According to https://jcgm.bipm.org/vim/en/1.19.html "quantity value" also contains a unit. According to https://jcgm.bipm.org/vim/en/1.20.html "numerical value" is the correct term for just a number. Resolves #423
This commit is contained in:
1 parent
24803a96cc
commit
f1c2c74ab0
19 files changed
+405
-379
No files matched your search
@@ -226,7 +226,7 @@ struct quantity_formatter {
|
||||
|
||||
explicit quantity_formatter(OutputIt o, quantity<Reference, Rep> q, const quantity_format_specs<CharT>& fspecs,
|
||||
Locale lc) :
|
||||
out(o), val(std::move(q).value()), specs(fspecs), loc(std::move(lc))
|
||||
out(o), val(std::move(q).numerical_value()), specs(fspecs), loc(std::move(lc))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ private:
|
||||
|
||||
if (begin == end || *begin == '}') {
|
||||
// default format should print value followed by the unit separated with 1 space
|
||||
out = mp_units::detail::format_units_quantity_value<CharT>(out, q.value(), specs.rep, ctx.locale());
|
||||
out = mp_units::detail::format_units_quantity_value<CharT>(out, q.numerical_value(), specs.rep, ctx.locale());
|
||||
if constexpr (mp_units::detail::has_unit_symbol(get_unit(Reference))) {
|
||||
*out++ = CharT(' ');
|
||||
out = unit_symbol_to<CharT>(out, get_unit(Reference));
|
||||
|
||||
@@ -36,9 +36,9 @@ void to_stream(std::basic_ostream<CharT, Traits>& os, const quantity<R, Rep>& q)
|
||||
{
|
||||
if constexpr (is_same_v<Rep, std::uint8_t> || is_same_v<Rep, std::int8_t>)
|
||||
// promote the value to int
|
||||
os << +q.value();
|
||||
os << +q.numerical_value();
|
||||
else
|
||||
os << q.value();
|
||||
os << q.numerical_value();
|
||||
if constexpr (has_unit_symbol(get_unit(R))) {
|
||||
os << " ";
|
||||
unit_symbol_to<CharT>(std::ostream_iterator<CharT>(os), get_unit(R));
|
||||
@@ -49,7 +49,7 @@ void to_stream(std::basic_ostream<CharT, Traits>& os, const quantity<R, Rep>& q)
|
||||
|
||||
template<typename CharT, typename Traits, auto R, typename Rep>
|
||||
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const quantity<R, Rep>& q)
|
||||
requires requires { os << q.value(); }
|
||||
requires requires { os << q.numerical_value(); }
|
||||
{
|
||||
if (os.width()) {
|
||||
// std::setw() applies to the whole quantity output so it has to be first put into std::string
|
||||
|
||||
@@ -51,9 +51,9 @@ template<QuantitySpec auto ToQS, typename Q>
|
||||
{
|
||||
if constexpr (detail::QuantityKindSpec<std::remove_const_t<decltype(ToQS)>> &&
|
||||
AssociatedUnit<std::remove_const_t<decltype(Q::unit)>>)
|
||||
return make_quantity<Q::unit>(std::forward<Q>(q).value());
|
||||
return make_quantity<Q::unit>(std::forward<Q>(q).numerical_value());
|
||||
else
|
||||
return make_quantity<reference<ToQS, Q::unit>{}>(std::forward<Q>(q).value());
|
||||
return make_quantity<reference<ToQS, Q::unit>{}>(std::forward<Q>(q).numerical_value());
|
||||
}
|
||||
|
||||
} // namespace mp_units
|
||||
@@ -63,10 +63,10 @@ template<Quantity To, typename From>
|
||||
if constexpr (q_unit == To::unit) {
|
||||
// no scaling of the number needed
|
||||
return make_quantity<To::reference>(static_cast<MP_UNITS_TYPENAME To::rep>(
|
||||
std::forward<From>(q).value())); // this is the only (and recommended) way to do
|
||||
// a truncating conversion on a number, so we are
|
||||
// using static_cast to suppress all the compiler
|
||||
// warnings on conversions
|
||||
std::forward<From>(q).numerical_value())); // this is the only (and recommended) way to do
|
||||
// a truncating conversion on a number, so we are
|
||||
// using static_cast to suppress all the compiler
|
||||
// warnings on conversions
|
||||
} else {
|
||||
// scale the number
|
||||
constexpr Magnitude auto c_mag = get_canonical_unit(q_unit).mag / get_canonical_unit(To::unit).mag;
|
||||
@@ -78,8 +78,8 @@ template<Quantity To, typename From>
|
||||
using multiplier_type =
|
||||
conditional<treat_as_floating_point<c_rep_type>, std::common_type_t<c_mag_type, long double>, c_mag_type>;
|
||||
constexpr auto val = [](Magnitude auto m) { return get_value<multiplier_type>(m); };
|
||||
return static_cast<MP_UNITS_TYPENAME To::rep>(static_cast<c_rep_type>(std::forward<From>(q).value()) * val(num) /
|
||||
val(den) * val(irr)) *
|
||||
return static_cast<MP_UNITS_TYPENAME To::rep>(static_cast<c_rep_type>(std::forward<From>(q).numerical_value()) *
|
||||
val(num) / val(den) * val(irr)) *
|
||||
To::reference;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
|
||||
template<detail::QuantityConvertibleTo<quantity> Q>
|
||||
constexpr explicit(!std::convertible_to<typename Q::rep, Rep>) quantity(const Q& q) :
|
||||
value_(detail::sudo_cast<quantity>(q).value())
|
||||
value_(detail::sudo_cast<quantity>(q).numerical_value())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -149,17 +149,17 @@ public:
|
||||
return std::forward<Self>(self).value_;
|
||||
}
|
||||
#else
|
||||
[[nodiscard]] constexpr rep& value() & noexcept { return value_; }
|
||||
[[nodiscard]] constexpr const rep& value() const& noexcept { return value_; }
|
||||
[[nodiscard]] constexpr rep&& value() && noexcept { return std::move(value_); }
|
||||
[[nodiscard]] constexpr const rep&& value() const&& noexcept { return std::move(value_); }
|
||||
[[nodiscard]] constexpr rep& numerical_value() & noexcept { return value_; }
|
||||
[[nodiscard]] constexpr const rep& numerical_value() const& noexcept { return value_; }
|
||||
[[nodiscard]] constexpr rep&& numerical_value() && noexcept { return std::move(value_); }
|
||||
[[nodiscard]] constexpr const rep&& numerical_value() const&& noexcept { return std::move(value_); }
|
||||
#endif
|
||||
|
||||
template<Unit U>
|
||||
requires requires(quantity q) { q.in(U{}); }
|
||||
[[nodiscard]] constexpr rep value_in(U) const noexcept
|
||||
[[nodiscard]] constexpr rep numerical_value_in(U) const noexcept
|
||||
{
|
||||
return (*this).in(U{}).value();
|
||||
return (*this).in(U{}).numerical_value();
|
||||
}
|
||||
|
||||
template<Unit U>
|
||||
@@ -177,7 +177,7 @@ public:
|
||||
} -> std::common_with<rep>;
|
||||
}
|
||||
{
|
||||
return make_quantity<reference>(+value());
|
||||
return make_quantity<reference>(+numerical_value());
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Quantity auto operator-() const
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
} -> std::common_with<rep>;
|
||||
}
|
||||
{
|
||||
return make_quantity<reference>(-value());
|
||||
return make_quantity<reference>(-numerical_value());
|
||||
}
|
||||
|
||||
constexpr quantity& operator++()
|
||||
@@ -239,7 +239,7 @@ public:
|
||||
} -> std::same_as<rep&>;
|
||||
}
|
||||
{
|
||||
value_ += q.value();
|
||||
value_ += q.numerical_value();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
} -> std::same_as<rep&>;
|
||||
}
|
||||
{
|
||||
value_ -= q.value();
|
||||
value_ -= q.numerical_value();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ public:
|
||||
}
|
||||
constexpr quantity& operator*=(const Q& rhs)
|
||||
{
|
||||
value_ *= rhs.value();
|
||||
value_ *= rhs.numerical_value();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -299,8 +299,8 @@ public:
|
||||
}
|
||||
constexpr quantity& operator/=(const Q& rhs)
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.value() != quantity_values<typename Q::rep>::zero());
|
||||
value_ /= rhs.value();
|
||||
gsl_ExpectsAudit(rhs.numerical_value() != quantity_values<typename Q::rep>::zero());
|
||||
value_ /= rhs.numerical_value();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -311,8 +311,8 @@ public:
|
||||
} -> std::same_as<rep&>;
|
||||
}
|
||||
{
|
||||
gsl_ExpectsAudit(q.value() != quantity_values<rep>::zero());
|
||||
value_ %= q.value();
|
||||
gsl_ExpectsAudit(q.numerical_value() != quantity_values<rep>::zero());
|
||||
value_ %= q.numerical_value();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
[[nodiscard]] constexpr Quantity auto operator+(const quantity<R1, Rep1>& lhs, const quantity<R2, Rep2>& rhs)
|
||||
{
|
||||
using ret = detail::common_quantity_for<std::plus<>, quantity<R1, Rep1>, quantity<R2, Rep2>>;
|
||||
return make_quantity<ret::reference>(ret(lhs).value() + ret(rhs).value());
|
||||
return make_quantity<ret::reference>(ret(lhs).numerical_value() + ret(rhs).numerical_value());
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
@@ -349,7 +349,7 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
[[nodiscard]] constexpr Quantity auto operator-(const quantity<R1, Rep1>& lhs, const quantity<R2, Rep2>& rhs)
|
||||
{
|
||||
using ret = detail::common_quantity_for<std::minus<>, quantity<R1, Rep1>, quantity<R2, Rep2>>;
|
||||
return make_quantity<ret::reference>(ret(lhs).value() - ret(rhs).value());
|
||||
return make_quantity<ret::reference>(ret(lhs).numerical_value() - ret(rhs).numerical_value());
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
@@ -357,7 +357,7 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
Rep2>
|
||||
[[nodiscard]] constexpr Quantity auto operator*(const quantity<R1, Rep1>& lhs, const quantity<R2, Rep2>& rhs)
|
||||
{
|
||||
return make_quantity<R1 * R2>(lhs.value() * rhs.value());
|
||||
return make_quantity<R1 * R2>(lhs.numerical_value() * rhs.numerical_value());
|
||||
}
|
||||
|
||||
template<auto R, typename Rep, typename Value>
|
||||
@@ -365,7 +365,7 @@ template<auto R, typename Rep, typename Value>
|
||||
detail::InvokeResultOf<get_quantity_spec(R).character, std::multiplies<>, Rep, const Value&>
|
||||
[[nodiscard]] constexpr Quantity auto operator*(const quantity<R, Rep>& q, const Value& v)
|
||||
{
|
||||
return make_quantity<R>(q.value() * v);
|
||||
return make_quantity<R>(q.numerical_value() * v);
|
||||
}
|
||||
|
||||
template<typename Value, auto R, typename Rep>
|
||||
@@ -373,15 +373,15 @@ template<typename Value, auto R, typename Rep>
|
||||
detail::InvokeResultOf<get_quantity_spec(R).character, std::multiplies<>, const Value&, Rep>
|
||||
[[nodiscard]] constexpr Quantity auto operator*(const Value& v, const quantity<R, Rep>& q)
|
||||
{
|
||||
return make_quantity<R>(v * q.value());
|
||||
return make_quantity<R>(v * q.numerical_value());
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
requires detail::InvokeResultOf<(get_quantity_spec(R1) / get_quantity_spec(R2)).character, std::divides<>, Rep1, Rep2>
|
||||
[[nodiscard]] constexpr Quantity auto operator/(const quantity<R1, Rep1>& lhs, const quantity<R2, Rep2>& rhs)
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.value() != quantity_values<Rep2>::zero());
|
||||
return make_quantity<R1 / R2>(lhs.value() / rhs.value());
|
||||
gsl_ExpectsAudit(rhs.numerical_value() != quantity_values<Rep2>::zero());
|
||||
return make_quantity<R1 / R2>(lhs.numerical_value() / rhs.numerical_value());
|
||||
}
|
||||
|
||||
template<auto R, typename Rep, typename Value>
|
||||
@@ -390,7 +390,7 @@ template<auto R, typename Rep, typename Value>
|
||||
[[nodiscard]] constexpr Quantity auto operator/(const quantity<R, Rep>& q, const Value& v)
|
||||
{
|
||||
gsl_ExpectsAudit(v != quantity_values<Value>::zero());
|
||||
return make_quantity<R>(q.value() / v);
|
||||
return make_quantity<R>(q.numerical_value() / v);
|
||||
}
|
||||
|
||||
template<typename Value, auto R, typename Rep>
|
||||
@@ -398,7 +398,7 @@ template<typename Value, auto R, typename Rep>
|
||||
detail::InvokeResultOf<get_quantity_spec(R).character, std::divides<>, const Value&, Rep>
|
||||
[[nodiscard]] constexpr Quantity auto operator/(const Value& v, const quantity<R, Rep>& q)
|
||||
{
|
||||
return make_quantity<::mp_units::one / R>(v / q.value());
|
||||
return make_quantity<::mp_units::one / R>(v / q.numerical_value());
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
@@ -406,9 +406,9 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
detail::InvocableQuantities<std::modulus<>, quantity<R1, Rep1>, quantity<R2, Rep2>>
|
||||
[[nodiscard]] constexpr Quantity auto operator%(const quantity<R1, Rep1>& lhs, const quantity<R2, Rep2>& rhs)
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.value() != quantity_values<Rep1>::zero());
|
||||
gsl_ExpectsAudit(rhs.numerical_value() != quantity_values<Rep1>::zero());
|
||||
using ret = detail::common_quantity_for<std::modulus<>, quantity<R1, Rep1>, quantity<R2, Rep2>>;
|
||||
return make_quantity<ret::reference>(ret(lhs).value() % ret(rhs).value());
|
||||
return make_quantity<ret::reference>(ret(lhs).numerical_value() % ret(rhs).numerical_value());
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
@@ -417,7 +417,7 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
[[nodiscard]] constexpr bool operator==(const quantity<R1, Rep1>& lhs, const quantity<R2, Rep2>& rhs)
|
||||
{
|
||||
using ct = std::common_type_t<quantity<R1, Rep1>, quantity<R2, Rep2>>;
|
||||
return ct(lhs).value() == ct(rhs).value();
|
||||
return ct(lhs).numerical_value() == ct(rhs).numerical_value();
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
@@ -426,7 +426,7 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
[[nodiscard]] constexpr auto operator<=>(const quantity<R1, Rep1>& lhs, const quantity<R2, Rep2>& rhs)
|
||||
{
|
||||
using ct = std::common_type_t<quantity<R1, Rep1>, quantity<R2, Rep2>>;
|
||||
return ct(lhs).value() <=> ct(rhs).value();
|
||||
return ct(lhs).numerical_value() <=> ct(rhs).numerical_value();
|
||||
}
|
||||
|
||||
// make_quantity
|
||||
|
||||
@@ -111,7 +111,7 @@ struct quantity_spec_interface {
|
||||
requires Quantity<std::remove_cvref_t<Q>> &&
|
||||
(explicitly_convertible(std::remove_reference_t<Q>::quantity_spec, self))
|
||||
{
|
||||
return make_quantity<reference<self, std::remove_cvref_t<Q>::unit>{}>(std::forward<Q>(q).value());
|
||||
return make_quantity<reference<self, std::remove_cvref_t<Q>::unit>{}>(std::forward<Q>(q).numerical_value());
|
||||
}
|
||||
#else
|
||||
template<typename Self_ = Self, UnitOf<Self_{}> U>
|
||||
@@ -128,7 +128,7 @@ struct quantity_spec_interface {
|
||||
(explicitly_convertible(std::remove_reference_t<Q>::quantity_spec, Self_{}))
|
||||
[[nodiscard]] constexpr Quantity auto operator()(Q&& q) const
|
||||
{
|
||||
return make_quantity<reference<Self{}, std::remove_cvref_t<Q>::unit>{}>(std::forward<Q>(q).value());
|
||||
return make_quantity<reference<Self{}, std::remove_cvref_t<Q>::unit>{}>(std::forward<Q>(q).numerical_value());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
@@ -307,7 +307,7 @@ struct quantity_spec<Self, QS, Args...> : std::remove_const_t<decltype(QS)> {
|
||||
(explicitly_convertible(std::remove_reference_t<Q>::quantity_spec, Self_{}))
|
||||
[[nodiscard]] constexpr Quantity auto operator()(Q&& q) const
|
||||
{
|
||||
return make_quantity<reference<Self{}, std::remove_cvref_t<Q>::unit>{}>(std::forward<Q>(q).value());
|
||||
return make_quantity<reference<Self{}, std::remove_cvref_t<Q>::unit>{}>(std::forward<Q>(q).numerical_value());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -92,7 +92,7 @@ template<QuantityOf<isq::time> Q>
|
||||
{
|
||||
constexpr auto canonical = detail::get_canonical_unit(Q::unit);
|
||||
constexpr ratio r = as_ratio(canonical.mag);
|
||||
return std::chrono::duration<typename Q::rep, std::ratio<r.num, r.den>>{q.value()};
|
||||
return std::chrono::duration<typename Q::rep, std::ratio<r.num, r.den>>{q.numerical_value()};
|
||||
}
|
||||
|
||||
template<QuantityPointOf<isq::time> QP>
|
||||
|
||||
@@ -54,7 +54,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, auto R, typename Rep>
|
||||
requires detail::non_zero<Den> &&
|
||||
requires { quantity_values<Rep>::one(); }
|
||||
[[nodiscard]] constexpr quantity<pow<Num, Den>(R), Rep> pow(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { pow(q.value(), 1.0); } || requires { std::pow(q.value(), 1.0); }
|
||||
requires requires { pow(q.numerical_value(), 1.0); } || requires { std::pow(q.numerical_value(), 1.0); }
|
||||
{
|
||||
if constexpr (Num == 0) {
|
||||
return quantity<pow<Num, Den>(R), Rep>::one();
|
||||
@@ -63,7 +63,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, auto R, typename Rep>
|
||||
} else {
|
||||
using std::pow;
|
||||
return make_quantity<pow<Num, Den>(R)>(
|
||||
static_cast<Rep>(pow(q.value(), static_cast<double>(Num) / static_cast<double>(Den))));
|
||||
static_cast<Rep>(pow(q.numerical_value(), static_cast<double>(Num) / static_cast<double>(Den))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,10 +77,10 @@ template<std::intmax_t Num, std::intmax_t Den = 1, auto R, typename Rep>
|
||||
*/
|
||||
template<auto R, typename Rep>
|
||||
[[nodiscard]] constexpr quantity<sqrt(R), Rep> sqrt(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { sqrt(q.value()); } || requires { std::sqrt(q.value()); }
|
||||
requires requires { sqrt(q.numerical_value()); } || requires { std::sqrt(q.numerical_value()); }
|
||||
{
|
||||
using std::sqrt;
|
||||
return make_quantity<sqrt(R)>(static_cast<Rep>(sqrt(q.value())));
|
||||
return make_quantity<sqrt(R)>(static_cast<Rep>(sqrt(q.numerical_value())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,10 +93,10 @@ template<auto R, typename Rep>
|
||||
*/
|
||||
template<auto R, typename Rep>
|
||||
[[nodiscard]] constexpr quantity<cbrt(R), Rep> cbrt(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { cbrt(q.value()); } || requires { std::cbrt(q.value()); }
|
||||
requires requires { cbrt(q.numerical_value()); } || requires { std::cbrt(q.numerical_value()); }
|
||||
{
|
||||
using std::cbrt;
|
||||
return make_quantity<cbrt(R)>(static_cast<Rep>(cbrt(q.value())));
|
||||
return make_quantity<cbrt(R)>(static_cast<Rep>(cbrt(q.numerical_value())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,11 +109,11 @@ template<auto R, typename Rep>
|
||||
*/
|
||||
template<ReferenceOf<dimensionless> auto R, typename Rep>
|
||||
[[nodiscard]] constexpr quantity<R, Rep> exp(const quantity<R, Rep>& q)
|
||||
requires requires { exp(q.value()); } || requires { std::exp(q.value()); }
|
||||
requires requires { exp(q.numerical_value()); } || requires { std::exp(q.numerical_value()); }
|
||||
{
|
||||
using std::exp;
|
||||
return value_cast<get_unit(R)>(
|
||||
make_quantity<detail::clone_reference_with<one>(R)>(static_cast<Rep>(exp(value_cast<one>(q).value()))));
|
||||
make_quantity<detail::clone_reference_with<one>(R)>(static_cast<Rep>(exp(value_cast<one>(q).numerical_value()))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,10 +124,10 @@ template<ReferenceOf<dimensionless> auto R, typename Rep>
|
||||
*/
|
||||
template<auto R, typename Rep>
|
||||
[[nodiscard]] constexpr quantity<R, Rep> abs(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { abs(q.value()); } || requires { std::abs(q.value()); }
|
||||
requires requires { abs(q.numerical_value()); } || requires { std::abs(q.numerical_value()); }
|
||||
{
|
||||
using std::abs;
|
||||
return make_quantity<R>(static_cast<Rep>(abs(q.value())));
|
||||
return make_quantity<R>(static_cast<Rep>(abs(q.numerical_value())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +153,8 @@ template<Representation Rep, Reference R>
|
||||
*/
|
||||
template<Unit auto To, auto R, typename Rep>
|
||||
[[nodiscard]] constexpr quantity<detail::clone_reference_with<To>(R), Rep> floor(const quantity<R, Rep>& q) noexcept
|
||||
requires((!treat_as_floating_point<Rep>) || requires { floor(q.value()); } || requires { std::floor(q.value()); }) &&
|
||||
requires((!treat_as_floating_point<Rep>) || requires { floor(q.numerical_value()); } ||
|
||||
requires { std::floor(q.numerical_value()); }) &&
|
||||
(To == get_unit(R) || requires {
|
||||
::mp_units::value_cast<To>(q);
|
||||
quantity_values<Rep>::one();
|
||||
@@ -168,10 +169,10 @@ template<Unit auto To, auto R, typename Rep>
|
||||
if constexpr (treat_as_floating_point<Rep>) {
|
||||
using std::floor;
|
||||
if constexpr (To == get_unit(R)) {
|
||||
return make_quantity<detail::clone_reference_with<To>(R)>(static_cast<Rep>(floor(q.value())));
|
||||
return make_quantity<detail::clone_reference_with<To>(R)>(static_cast<Rep>(floor(q.numerical_value())));
|
||||
} else {
|
||||
return handle_signed_results(
|
||||
make_quantity<detail::clone_reference_with<To>(R)>(static_cast<Rep>(floor(value_cast<To>(q).value()))));
|
||||
return handle_signed_results(make_quantity<detail::clone_reference_with<To>(R)>(
|
||||
static_cast<Rep>(floor(value_cast<To>(q).numerical_value()))));
|
||||
}
|
||||
} else {
|
||||
if constexpr (To == get_unit(R)) {
|
||||
@@ -190,7 +191,8 @@ template<Unit auto To, auto R, typename Rep>
|
||||
*/
|
||||
template<Unit auto To, auto R, typename Rep>
|
||||
[[nodiscard]] constexpr quantity<detail::clone_reference_with<To>(R), Rep> ceil(const quantity<R, Rep>& q) noexcept
|
||||
requires((!treat_as_floating_point<Rep>) || requires { ceil(q.value()); } || requires { std::ceil(q.value()); }) &&
|
||||
requires((!treat_as_floating_point<Rep>) || requires { ceil(q.numerical_value()); } ||
|
||||
requires { std::ceil(q.numerical_value()); }) &&
|
||||
(To == get_unit(R) || requires {
|
||||
::mp_units::value_cast<To>(q);
|
||||
quantity_values<Rep>::one();
|
||||
@@ -205,10 +207,10 @@ template<Unit auto To, auto R, typename Rep>
|
||||
if constexpr (treat_as_floating_point<Rep>) {
|
||||
using std::ceil;
|
||||
if constexpr (To == get_unit(R)) {
|
||||
return make_quantity<detail::clone_reference_with<To>(R)>(static_cast<Rep>(ceil(q.value())));
|
||||
return make_quantity<detail::clone_reference_with<To>(R)>(static_cast<Rep>(ceil(q.numerical_value())));
|
||||
} else {
|
||||
return handle_signed_results(
|
||||
make_quantity<detail::clone_reference_with<To>(R)>(static_cast<Rep>(ceil(value_cast<To>(q).value()))));
|
||||
return handle_signed_results(make_quantity<detail::clone_reference_with<To>(R)>(
|
||||
static_cast<Rep>(ceil(value_cast<To>(q).numerical_value()))));
|
||||
}
|
||||
} else {
|
||||
if constexpr (To == get_unit(R)) {
|
||||
@@ -229,7 +231,8 @@ template<Unit auto To, auto R, typename Rep>
|
||||
*/
|
||||
template<Unit auto To, auto R, typename Rep>
|
||||
[[nodiscard]] constexpr quantity<detail::clone_reference_with<To>(R), Rep> round(const quantity<R, Rep>& q) noexcept
|
||||
requires((!treat_as_floating_point<Rep>) || requires { round(q.value()); } || requires { std::round(q.value()); }) &&
|
||||
requires((!treat_as_floating_point<Rep>) || requires { round(q.numerical_value()); } ||
|
||||
requires { std::round(q.numerical_value()); }) &&
|
||||
(To == get_unit(R) || requires {
|
||||
::mp_units::floor<To>(q);
|
||||
quantity_values<Rep>::one();
|
||||
@@ -238,7 +241,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
if constexpr (To == get_unit(R)) {
|
||||
if constexpr (treat_as_floating_point<Rep>) {
|
||||
using std::round;
|
||||
return make_quantity<detail::clone_reference_with<To>(R)>(static_cast<Rep>(round(q.value())));
|
||||
return make_quantity<detail::clone_reference_with<To>(R)>(static_cast<Rep>(round(q.numerical_value())));
|
||||
} else {
|
||||
return value_cast<To>(q);
|
||||
}
|
||||
@@ -248,7 +251,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
const auto diff0 = q - res_low;
|
||||
const auto diff1 = res_high - q;
|
||||
if (diff0 == diff1) {
|
||||
if (static_cast<int>(res_low.value()) & 1) {
|
||||
if (static_cast<int>(res_low.numerical_value()) & 1) {
|
||||
return res_high;
|
||||
}
|
||||
return res_low;
|
||||
@@ -269,12 +272,13 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
const quantity<R1, Rep1>& x, const quantity<R2, Rep2>& y) noexcept
|
||||
requires requires { common_reference(R1, R2); } &&
|
||||
(
|
||||
requires { hypot(x.value(), y.value()); } || requires { std::hypot(x.value(), y.value()); })
|
||||
requires { hypot(x.numerical_value(), y.numerical_value()); } ||
|
||||
requires { std::hypot(x.numerical_value(), y.numerical_value()); })
|
||||
{
|
||||
constexpr auto ref = common_reference(R1, R2);
|
||||
constexpr auto unit = get_unit(ref);
|
||||
using std::hypot;
|
||||
return make_quantity<ref>(hypot(x.value_in(unit), y.value_in(unit)));
|
||||
return make_quantity<ref>(hypot(x.numerical_value_in(unit), y.numerical_value_in(unit)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,100 +288,101 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2, auto R3, typename Rep3>
|
||||
[[nodiscard]] constexpr QuantityOf<get_quantity_spec(common_reference(R1, R2, R3))> auto hypot(
|
||||
const quantity<R1, Rep1>& x, const quantity<R2, Rep2>& y, const quantity<R3, Rep3>& z) noexcept
|
||||
requires requires { common_reference(R1, R2, R3); } && (
|
||||
requires { hypot(x.value(), y.value(), z.value()); } ||
|
||||
requires { std::hypot(x.value(), y.value(), z.value()); })
|
||||
requires requires { common_reference(R1, R2, R3); } &&
|
||||
(
|
||||
requires { hypot(x.numerical_value(), y.numerical_value(), z.numerical_value()); } ||
|
||||
requires { std::hypot(x.numerical_value(), y.numerical_value(), z.numerical_value()); })
|
||||
{
|
||||
constexpr auto ref = common_reference(R1, R2);
|
||||
constexpr auto unit = get_unit(ref);
|
||||
using std::hypot;
|
||||
return make_quantity<ref>(hypot(x.value_in(unit), y.value_in(unit), z.value_in(unit)));
|
||||
return make_quantity<ref>(hypot(x.numerical_value_in(unit), y.numerical_value_in(unit), z.numerical_value_in(unit)));
|
||||
}
|
||||
|
||||
namespace isq {
|
||||
|
||||
template<ReferenceOf<angular_measure> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<dimensionless> auto sin(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { sin(q.value()); } || requires { std::sin(q.value()); }
|
||||
requires requires { sin(q.numerical_value()); } || requires { std::sin(q.numerical_value()); }
|
||||
{
|
||||
using std::sin;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(sin(value_cast<si::radian>(q).value()));
|
||||
using rep = decltype(sin(value_cast<si::radian>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<one>(sin(value_cast<rep>(q).value_in(si::radian)));
|
||||
return make_quantity<one>(sin(value_cast<rep>(q).numerical_value_in(si::radian)));
|
||||
} else
|
||||
return make_quantity<one>(sin(q.value_in(si::radian)));
|
||||
return make_quantity<one>(sin(q.numerical_value_in(si::radian)));
|
||||
}
|
||||
|
||||
template<ReferenceOf<angular_measure> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<dimensionless> auto cos(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { cos(q.value()); } || requires { std::cos(q.value()); }
|
||||
requires requires { cos(q.numerical_value()); } || requires { std::cos(q.numerical_value()); }
|
||||
{
|
||||
using std::cos;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(cos(value_cast<si::radian>(q).value()));
|
||||
using rep = decltype(cos(value_cast<si::radian>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<one>(cos(value_cast<rep>(q).value_in(si::radian)));
|
||||
return make_quantity<one>(cos(value_cast<rep>(q).numerical_value_in(si::radian)));
|
||||
} else
|
||||
return make_quantity<one>(cos(q.value_in(si::radian)));
|
||||
return make_quantity<one>(cos(q.numerical_value_in(si::radian)));
|
||||
}
|
||||
|
||||
template<ReferenceOf<angular_measure> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<dimensionless> auto tan(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { tan(q.value()); } || requires { std::tan(q.value()); }
|
||||
requires requires { tan(q.numerical_value()); } || requires { std::tan(q.numerical_value()); }
|
||||
{
|
||||
using std::tan;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(tan(value_cast<si::radian>(q).value()));
|
||||
using rep = decltype(tan(value_cast<si::radian>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<one>(tan(value_cast<rep>(q).value_in(si::radian)));
|
||||
return make_quantity<one>(tan(value_cast<rep>(q).numerical_value_in(si::radian)));
|
||||
} else
|
||||
return make_quantity<one>(tan(q.value_in(si::radian)));
|
||||
return make_quantity<one>(tan(q.numerical_value_in(si::radian)));
|
||||
}
|
||||
|
||||
template<ReferenceOf<dimensionless> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<isq::angular_measure> auto asin(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { asin(q.value()); } || requires { std::asin(q.value()); }
|
||||
requires requires { asin(q.numerical_value()); } || requires { std::asin(q.numerical_value()); }
|
||||
{
|
||||
using std::asin;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(asin(value_cast<one>(q).value()));
|
||||
using rep = decltype(asin(value_cast<one>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<si::radian>(asin(value_cast<rep>(q).value_in(one)));
|
||||
return make_quantity<si::radian>(asin(value_cast<rep>(q).numerical_value_in(one)));
|
||||
} else
|
||||
return make_quantity<si::radian>(asin(q.value_in(one)));
|
||||
return make_quantity<si::radian>(asin(q.numerical_value_in(one)));
|
||||
}
|
||||
|
||||
template<ReferenceOf<dimensionless> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<isq::angular_measure> auto acos(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { acos(q.value()); } || requires { std::acos(q.value()); }
|
||||
requires requires { acos(q.numerical_value()); } || requires { std::acos(q.numerical_value()); }
|
||||
{
|
||||
using std::acos;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(acos(value_cast<one>(q).value()));
|
||||
using rep = decltype(acos(value_cast<one>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<si::radian>(acos(value_cast<rep>(q).value_in(one)));
|
||||
return make_quantity<si::radian>(acos(value_cast<rep>(q).numerical_value_in(one)));
|
||||
} else
|
||||
return make_quantity<si::radian>(acos(q.value_in(one)));
|
||||
return make_quantity<si::radian>(acos(q.numerical_value_in(one)));
|
||||
}
|
||||
|
||||
template<ReferenceOf<dimensionless> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<isq::angular_measure> auto atan(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { atan(q.value()); } || requires { std::atan(q.value()); }
|
||||
requires requires { atan(q.numerical_value()); } || requires { std::atan(q.numerical_value()); }
|
||||
{
|
||||
using std::atan;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(atan(value_cast<one>(q).value()));
|
||||
using rep = decltype(atan(value_cast<one>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<si::radian>(atan(value_cast<rep>(q).value_in(one)));
|
||||
return make_quantity<si::radian>(atan(value_cast<rep>(q).numerical_value_in(one)));
|
||||
} else
|
||||
return make_quantity<si::radian>(atan(q.value_in(one)));
|
||||
return make_quantity<si::radian>(atan(q.numerical_value_in(one)));
|
||||
}
|
||||
|
||||
} // namespace isq
|
||||
@@ -386,86 +391,86 @@ namespace angular {
|
||||
|
||||
template<ReferenceOf<angle> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<dimensionless> auto sin(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { sin(q.value()); } || requires { std::sin(q.value()); }
|
||||
requires requires { sin(q.numerical_value()); } || requires { std::sin(q.numerical_value()); }
|
||||
{
|
||||
using std::sin;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(sin(value_cast<radian>(q).value()));
|
||||
using rep = decltype(sin(value_cast<radian>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<one>(sin(value_cast<rep>(q).value_in(radian)));
|
||||
return make_quantity<one>(sin(value_cast<rep>(q).numerical_value_in(radian)));
|
||||
} else
|
||||
return make_quantity<one>(sin(q.value_in(radian)));
|
||||
return make_quantity<one>(sin(q.numerical_value_in(radian)));
|
||||
}
|
||||
|
||||
template<ReferenceOf<angle> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<dimensionless> auto cos(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { cos(q.value()); } || requires { std::cos(q.value()); }
|
||||
requires requires { cos(q.numerical_value()); } || requires { std::cos(q.numerical_value()); }
|
||||
{
|
||||
using std::cos;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(cos(value_cast<radian>(q).value()));
|
||||
using rep = decltype(cos(value_cast<radian>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<one>(cos(value_cast<rep>(q).value_in(radian)));
|
||||
return make_quantity<one>(cos(value_cast<rep>(q).numerical_value_in(radian)));
|
||||
} else
|
||||
return make_quantity<one>(cos(q.value_in(radian)));
|
||||
return make_quantity<one>(cos(q.numerical_value_in(radian)));
|
||||
}
|
||||
|
||||
template<ReferenceOf<angle> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<dimensionless> auto tan(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { tan(q.value()); } || requires { std::tan(q.value()); }
|
||||
requires requires { tan(q.numerical_value()); } || requires { std::tan(q.numerical_value()); }
|
||||
{
|
||||
using std::tan;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(tan(value_cast<radian>(q).value()));
|
||||
using rep = decltype(tan(value_cast<radian>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<one>(tan(value_cast<rep>(q).value_in(radian)));
|
||||
return make_quantity<one>(tan(value_cast<rep>(q).numerical_value_in(radian)));
|
||||
} else
|
||||
return make_quantity<one>(tan(q.value_in(radian)));
|
||||
return make_quantity<one>(tan(q.numerical_value_in(radian)));
|
||||
}
|
||||
|
||||
template<ReferenceOf<dimensionless> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<angle> auto asin(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { asin(q.value()); } || requires { std::asin(q.value()); }
|
||||
requires requires { asin(q.numerical_value()); } || requires { std::asin(q.numerical_value()); }
|
||||
{
|
||||
using std::asin;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(asin(value_cast<one>(q).value()));
|
||||
using rep = decltype(asin(value_cast<one>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<radian>(asin(value_cast<rep>(q).value_in(one)));
|
||||
return make_quantity<radian>(asin(value_cast<rep>(q).numerical_value_in(one)));
|
||||
} else
|
||||
return make_quantity<radian>(asin(q.value_in(one)));
|
||||
return make_quantity<radian>(asin(q.numerical_value_in(one)));
|
||||
}
|
||||
|
||||
template<ReferenceOf<dimensionless> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<angle> auto acos(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { acos(q.value()); } || requires { std::acos(q.value()); }
|
||||
requires requires { acos(q.numerical_value()); } || requires { std::acos(q.numerical_value()); }
|
||||
{
|
||||
using std::acos;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(acos(value_cast<one>(q).value()));
|
||||
using rep = decltype(acos(value_cast<one>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<radian>(acos(value_cast<rep>(q).value_in(one)));
|
||||
return make_quantity<radian>(acos(value_cast<rep>(q).numerical_value_in(one)));
|
||||
} else
|
||||
return make_quantity<radian>(acos(q.value_in(one)));
|
||||
return make_quantity<radian>(acos(q.numerical_value_in(one)));
|
||||
}
|
||||
|
||||
template<ReferenceOf<dimensionless> auto R, typename Rep>
|
||||
[[nodiscard]] inline QuantityOf<angle> auto atan(const quantity<R, Rep>& q) noexcept
|
||||
requires requires { atan(q.value()); } || requires { std::atan(q.value()); }
|
||||
requires requires { atan(q.numerical_value()); } || requires { std::atan(q.numerical_value()); }
|
||||
{
|
||||
using std::atan;
|
||||
if constexpr (!treat_as_floating_point<Rep>) {
|
||||
// check what is the return type when called with the integral value
|
||||
using rep = decltype(atan(value_cast<one>(q).value()));
|
||||
using rep = decltype(atan(value_cast<one>(q).numerical_value()));
|
||||
// use this type ahead of calling the function to prevent narrowing if a unit conversion is needed
|
||||
return make_quantity<radian>(atan(value_cast<rep>(q).value_in(one)));
|
||||
return make_quantity<radian>(atan(value_cast<rep>(q).numerical_value_in(one)));
|
||||
} else
|
||||
return make_quantity<radian>(atan(q.value_in(one)));
|
||||
return make_quantity<radian>(atan(q.numerical_value_in(one)));
|
||||
}
|
||||
|
||||
} // namespace angular
|
||||
|
||||
@@ -35,7 +35,7 @@ static std::vector<typename Q::rep> i_qty_to_rep(InputIt first, InputIt last)
|
||||
std::vector<typename Q::rep> intervals_rep;
|
||||
intervals_rep.reserve(static_cast<size_t>(std::distance(first, last)));
|
||||
for (auto itr = first; itr != last; ++itr) {
|
||||
intervals_rep.push_back(itr->value());
|
||||
intervals_rep.push_back(itr->numerical_value());
|
||||
}
|
||||
return intervals_rep;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ static std::vector<typename Q::rep> bl_qty_to_rep(std::initializer_list<Q>& bl)
|
||||
std::vector<typename Q::rep> bl_rep;
|
||||
bl_rep.reserve(bl.size());
|
||||
for (const Q& qty : bl) {
|
||||
bl_rep.push_back(qty.value());
|
||||
bl_rep.push_back(qty.numerical_value());
|
||||
}
|
||||
return bl_rep;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ struct uniform_int_distribution : public std::uniform_int_distribution<typename
|
||||
using base = MP_UNITS_TYPENAME std::uniform_int_distribution<rep>;
|
||||
|
||||
uniform_int_distribution() : base() {}
|
||||
uniform_int_distribution(const Q& a, const Q& b) : base(a.value(), b.value()) {}
|
||||
uniform_int_distribution(const Q& a, const Q& b) : base(a.numerical_value(), b.numerical_value()) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g)
|
||||
@@ -110,7 +110,7 @@ struct uniform_real_distribution : public std::uniform_real_distribution<typenam
|
||||
using base = MP_UNITS_TYPENAME std::uniform_real_distribution<rep>;
|
||||
|
||||
uniform_real_distribution() : base() {}
|
||||
uniform_real_distribution(const Q& a, const Q& b) : base(a.value(), b.value()) {}
|
||||
uniform_real_distribution(const Q& a, const Q& b) : base(a.numerical_value(), b.numerical_value()) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g)
|
||||
@@ -132,7 +132,7 @@ struct binomial_distribution : public std::binomial_distribution<typename Q::rep
|
||||
using base = MP_UNITS_TYPENAME std::binomial_distribution<rep>;
|
||||
|
||||
binomial_distribution() : base() {}
|
||||
binomial_distribution(const Q& t, double p) : base(t.value(), p) {}
|
||||
binomial_distribution(const Q& t, double p) : base(t.numerical_value(), p) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g)
|
||||
@@ -153,7 +153,7 @@ struct negative_binomial_distribution : public std::negative_binomial_distributi
|
||||
using base = MP_UNITS_TYPENAME std::negative_binomial_distribution<rep>;
|
||||
|
||||
negative_binomial_distribution() : base() {}
|
||||
negative_binomial_distribution(const Q& k, double p) : base(k.value(), p) {}
|
||||
negative_binomial_distribution(const Q& k, double p) : base(k.numerical_value(), p) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g)
|
||||
@@ -269,7 +269,7 @@ struct extreme_value_distribution : public std::extreme_value_distribution<typen
|
||||
using base = MP_UNITS_TYPENAME std::extreme_value_distribution<rep>;
|
||||
|
||||
extreme_value_distribution() : base() {}
|
||||
extreme_value_distribution(const Q& a, const rep& b) : base(a.value(), b) {}
|
||||
extreme_value_distribution(const Q& a, const rep& b) : base(a.numerical_value(), b) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g)
|
||||
@@ -290,7 +290,7 @@ struct normal_distribution : public std::normal_distribution<typename Q::rep> {
|
||||
using base = MP_UNITS_TYPENAME std::normal_distribution<rep>;
|
||||
|
||||
normal_distribution() : base() {}
|
||||
normal_distribution(const Q& mean, const Q& stddev) : base(mean.value(), stddev.value()) {}
|
||||
normal_distribution(const Q& mean, const Q& stddev) : base(mean.numerical_value(), stddev.numerical_value()) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g)
|
||||
@@ -312,7 +312,7 @@ struct lognormal_distribution : public std::lognormal_distribution<typename Q::r
|
||||
using base = MP_UNITS_TYPENAME std::lognormal_distribution<rep>;
|
||||
|
||||
lognormal_distribution() : base() {}
|
||||
lognormal_distribution(const Q& m, const Q& s) : base(m.value(), s.value()) {}
|
||||
lognormal_distribution(const Q& m, const Q& s) : base(m.numerical_value(), s.numerical_value()) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g)
|
||||
@@ -353,7 +353,7 @@ struct cauchy_distribution : public std::cauchy_distribution<typename Q::rep> {
|
||||
using base = MP_UNITS_TYPENAME std::cauchy_distribution<rep>;
|
||||
|
||||
cauchy_distribution() : base() {}
|
||||
cauchy_distribution(const Q& a, const Q& b) : base(a.value(), b.value()) {}
|
||||
cauchy_distribution(const Q& a, const Q& b) : base(a.numerical_value(), b.numerical_value()) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g)
|
||||
@@ -470,7 +470,7 @@ public:
|
||||
|
||||
template<typename UnaryOperation>
|
||||
piecewise_constant_distribution(std::size_t nw, const Q& xmin, const Q& xmax, UnaryOperation fw) :
|
||||
base(nw, xmin.value(), xmax.value(), [fw](rep val) { return fw(val * Q::reference); })
|
||||
base(nw, xmin.numerical_value(), xmax.numerical_value(), [fw](rep val) { return fw(val * Q::reference); })
|
||||
{
|
||||
}
|
||||
|
||||
@@ -528,7 +528,7 @@ public:
|
||||
|
||||
template<typename UnaryOperation>
|
||||
piecewise_linear_distribution(std::size_t nw, const Q& xmin, const Q& xmax, UnaryOperation fw) :
|
||||
base(nw, xmin.value(), xmax.value(), [fw](rep val) { return fw(val * Q::reference); })
|
||||
base(nw, xmin.numerical_value(), xmax.numerical_value(), [fw](rep val) { return fw(val * Q::reference); })
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user