mirror of
https://github.com/mpusz/mp-units.git
synced 2025-06-25 01:01:33 +02:00
@ -148,12 +148,6 @@ public:
|
||||
return {representation_values<rep>::zero(), R};
|
||||
}
|
||||
|
||||
[[nodiscard]] static constexpr quantity one() noexcept
|
||||
requires requires { representation_values<rep>::one(); }
|
||||
{
|
||||
return {representation_values<rep>::one(), R};
|
||||
}
|
||||
|
||||
[[nodiscard]] static constexpr quantity min() noexcept
|
||||
requires requires { representation_values<rep>::min(); }
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, auto R, typename Rep>
|
||||
|
||||
{
|
||||
if constexpr (Num == 0) {
|
||||
return quantity<pow<Num, Den>(R), Rep>::one();
|
||||
return {representation_values<Rep>::one(), pow<0>(R)};
|
||||
} else if constexpr (Num == Den) {
|
||||
return q;
|
||||
} else {
|
||||
@ -341,7 +341,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
{
|
||||
const auto handle_signed_results = [&]<typename T>(const T& res) {
|
||||
if (res > q) {
|
||||
return res - T::one();
|
||||
return res - representation_values<Rep>::one() * T::reference;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
@ -378,7 +378,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
{
|
||||
const auto handle_signed_results = [&]<typename T>(const T& res) {
|
||||
if (res < q) {
|
||||
return res + T::one();
|
||||
return res + representation_values<Rep>::one() * T::reference;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
@ -424,7 +424,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
}
|
||||
} else {
|
||||
const auto res_low = mp_units::floor<To>(q);
|
||||
const auto res_high = res_low + res_low.one();
|
||||
const auto res_high = res_low + representation_values<Rep>::one() * res_low.reference;
|
||||
const auto diff0 = q - res_low;
|
||||
const auto diff1 = res_high - q;
|
||||
if (diff0 == diff1) {
|
||||
|
@ -83,7 +83,7 @@ TEST_CASE("distributions", "[random][distribution]")
|
||||
auto dist = mp_units::uniform_real_distribution<q>();
|
||||
|
||||
CHECK(dist.a() == q::zero());
|
||||
CHECK(dist.b() == q::one());
|
||||
CHECK(dist.b() == 1 * si::metre);
|
||||
}
|
||||
|
||||
SECTION("parametrized")
|
||||
@ -111,7 +111,7 @@ TEST_CASE("distributions", "[random][distribution]")
|
||||
auto dist = mp_units::binomial_distribution<q>();
|
||||
|
||||
CHECK(dist.p() == 0.5);
|
||||
CHECK(dist.t() == q::one());
|
||||
CHECK(dist.t() == 1 * si::metre);
|
||||
}
|
||||
|
||||
SECTION("parametrized")
|
||||
@ -139,7 +139,7 @@ TEST_CASE("distributions", "[random][distribution]")
|
||||
auto dist = mp_units::negative_binomial_distribution<q>();
|
||||
|
||||
CHECK(dist.p() == 0.5);
|
||||
CHECK(dist.k() == q::one());
|
||||
CHECK(dist.k() == 1 * si::metre);
|
||||
}
|
||||
|
||||
SECTION("parametrized")
|
||||
@ -326,7 +326,7 @@ TEST_CASE("distributions", "[random][distribution]")
|
||||
auto dist = mp_units::normal_distribution<q>();
|
||||
|
||||
CHECK(dist.mean() == q::zero());
|
||||
CHECK(dist.stddev() == q::one());
|
||||
CHECK(dist.stddev() == 1 * si::metre);
|
||||
}
|
||||
|
||||
SECTION("parametrized")
|
||||
@ -354,7 +354,7 @@ TEST_CASE("distributions", "[random][distribution]")
|
||||
auto dist = mp_units::lognormal_distribution<q>();
|
||||
|
||||
CHECK(dist.m() == q::zero());
|
||||
CHECK(dist.s() == q::one());
|
||||
CHECK(dist.s() == 1 * si::metre);
|
||||
}
|
||||
|
||||
SECTION("parametrized")
|
||||
@ -407,7 +407,7 @@ TEST_CASE("distributions", "[random][distribution]")
|
||||
auto dist = mp_units::cauchy_distribution<q>();
|
||||
|
||||
CHECK(dist.a() == q::zero());
|
||||
CHECK(dist.b() == q::one());
|
||||
CHECK(dist.b() == 1 * si::metre);
|
||||
}
|
||||
|
||||
SECTION("parametrized")
|
||||
|
@ -162,11 +162,9 @@ static_assert(is_same_v<decltype(quantity(vint, m))::rep, std::int16_t>);
|
||||
////////////////////////////
|
||||
|
||||
static_assert(quantity<isq::length[m], int>::zero().numerical_value_in(m) == 0);
|
||||
static_assert(quantity<isq::length[m], int>::one().numerical_value_in(m) == 1);
|
||||
static_assert(quantity<isq::length[m], int>::min().numerical_value_in(m) == std::numeric_limits<int>::lowest());
|
||||
static_assert(quantity<isq::length[m], int>::max().numerical_value_in(m) == std::numeric_limits<int>::max());
|
||||
static_assert(quantity<isq::length[m], double>::zero().numerical_value_in(m) == 0.0);
|
||||
static_assert(quantity<isq::length[m], double>::one().numerical_value_in(m) == 1.0);
|
||||
static_assert(quantity<isq::length[m], double>::min().numerical_value_in(m) == std::numeric_limits<double>::lowest());
|
||||
static_assert(quantity<isq::length[m], double>::max().numerical_value_in(m) == std::numeric_limits<double>::max());
|
||||
|
||||
|
Reference in New Issue
Block a user