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:
Mateusz Pusz committed 2023-08-30 11:30:35 +02:00
1 parent 24803a96cc
commit f1c2c74ab0
19 files changed
+405 -379

No files matched your search

+3 -2
View File
@@ -33,7 +33,7 @@ template<mp_units::Quantity Target, mp_units::Quantity Source>
requires std::constructible_from<Target, Source>
inline constexpr double conversion_factor(Target, Source)
{
return mp_units::value_cast<Target::unit>(1. * Source::reference).value();
return mp_units::value_cast<Target::unit>(1. * Source::reference).numerical_value();
}
} // namespace
@@ -56,5 +56,6 @@ int main()
std::cout << MP_UNITS_STD_FMT::format("conversion factor from lengthA::unit of {:%q} to lengthB::unit of {:%q}:\n\n",
lengthA, lengthB)
<< MP_UNITS_STD_FMT::format("lengthB.value( {} ) == lengthA.value( {} ) * conversion_factor( {} )\n",
lengthB.value(), lengthA.value(), conversion_factor(lengthB, lengthA));
lengthB.numerical_value(), lengthA.numerical_value(),
conversion_factor(lengthB, lengthA));
}
+3 -2
View File
@@ -75,14 +75,15 @@ template<Unit auto From, Unit auto To>
template<ReferenceOf<currency> auto To, ReferenceOf<currency> auto From, typename Rep>
quantity<To, Rep> exchange_to(quantity<From, Rep> q)
{
return static_cast<Rep>(exchange_rate<q.unit, get_unit(To)>() * q.value()) * To;
return static_cast<Rep>(exchange_rate<q.unit, get_unit(To)>() * q.numerical_value()) * To;
}
template<ReferenceOf<currency> auto To, ReferenceOf<currency> auto From, auto PO, typename Rep>
quantity_point<To, PO, Rep> exchange_to(quantity_point<From, PO, Rep> q)
{
return quantity_point{
zero + static_cast<Rep>(exchange_rate<q.unit, get_unit(To)>() * (q - q.absolute_point_origin).value()) * To};
zero +
static_cast<Rep>(exchange_rate<q.unit, get_unit(To)>() * (q - q.absolute_point_origin).numerical_value()) * To};
}
int main()
+10 -8
View File
@@ -74,19 +74,19 @@ using longitude =
template<class CharT, class Traits, typename T>
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const latitude<T>& lat)
{
if (lat.value() > 0)
return os << "N" << lat.value();
if (lat.numerical_value() > 0)
return os << "N" << lat.numerical_value();
else
return os << "S" << -lat.value();
return os << "S" << -lat.numerical_value();
}
template<class CharT, class Traits, typename T>
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const longitude<T>& lon)
{
if (lon.value() > 0)
return os << "E" << lon.value();
if (lon.numerical_value() > 0)
return os << "E" << lon.numerical_value();
else
return os << "W" << -lon.value();
return os << "W" << -lon.numerical_value();
}
inline namespace literals {
@@ -129,7 +129,8 @@ struct MP_UNITS_STD_FMT::formatter<geographic::latitude<T>> : formatter<T> {
auto format(geographic::latitude<T> lat, FormatContext& ctx)
{
MP_UNITS_STD_FMT::format_to(ctx.out(), "{}", lat > geographic::latitude<T>::zero() ? 'N' : 'S');
return formatter<T>::format(lat > geographic::latitude<T>::zero() ? lat.value() : -lat.value(), ctx);
return formatter<T>::format(lat > geographic::latitude<T>::zero() ? lat.numerical_value() : -lat.numerical_value(),
ctx);
}
};
@@ -139,7 +140,8 @@ struct MP_UNITS_STD_FMT::formatter<geographic::longitude<T>> : formatter<T> {
auto format(geographic::longitude<T> lon, FormatContext& ctx)
{
MP_UNITS_STD_FMT::format_to(ctx.out(), "{}", lon > geographic::longitude<T>::zero() ? 'E' : 'W');
return formatter<T>::format(lon > geographic::longitude<T>::zero() ? lon.value() : -lon.value(), ctx);
return formatter<T>::format(lon > geographic::longitude<T>::zero() ? lon.numerical_value() : -lon.numerical_value(),
ctx);
}
};
+3 -2
View File
@@ -96,8 +96,9 @@ double GeographicLibWhatsMyOffset(long double /* lat */, long double /* lon */)
template<earth_gravity_model M>
hae_altitude<M> to_hae(msl_altitude msl, position<long double> pos)
{
const auto geoid_undulation =
isq::height(GeographicLibWhatsMyOffset(pos.lat.value_in(si::degree), pos.lon.value_in(si::degree)) * si::metre);
const auto geoid_undulation = isq::height(
GeographicLibWhatsMyOffset(pos.lat.numerical_value_in(si::degree), pos.lon.numerical_value_in(si::degree)) *
si::metre);
return height_above_ellipsoid<M> + (msl - mean_sea_level - geoid_undulation);
}