mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-01 03:14:29 +02:00
feat: 💥 quantity_spec
and its kind should not compare equal
This commit is contained in:
@@ -92,7 +92,7 @@ constexpr mp_units::quantity<mp_units::dimensionless[mp_units::one]> kalman_gain
|
||||
|
||||
// state update
|
||||
template<typename Q, QuantityOrQuantityPoint QM, mp_units::QuantityOf<mp_units::dimensionless> K>
|
||||
requires(Q::quantity_spec == QM::quantity_spec)
|
||||
requires(implicitly_convertible(QM::quantity_spec, Q::quantity_spec))
|
||||
constexpr state<Q> state_update(const state<Q>& predicted, QM measured, K gain)
|
||||
{
|
||||
return {get<0>(predicted) + gain * (measured - get<0>(predicted))};
|
||||
@@ -100,7 +100,7 @@ constexpr state<Q> state_update(const state<Q>& predicted, QM measured, K gain)
|
||||
|
||||
template<typename Q1, typename Q2, QuantityOrQuantityPoint QM, mp_units::QuantityOf<mp_units::dimensionless> K,
|
||||
mp_units::QuantityOf<mp_units::isq::time> T>
|
||||
requires(Q1::quantity_spec == QM::quantity_spec)
|
||||
requires(implicitly_convertible(QM::quantity_spec, Q1::quantity_spec))
|
||||
constexpr state<Q1, Q2> state_update(const state<Q1, Q2>& predicted, QM measured, std::array<K, 2> gain, T interval)
|
||||
{
|
||||
const auto q1 = get<0>(predicted) + get<0>(gain) * (measured - get<0>(predicted));
|
||||
@@ -110,7 +110,7 @@ constexpr state<Q1, Q2> state_update(const state<Q1, Q2>& predicted, QM measured
|
||||
|
||||
template<typename Q1, typename Q2, typename Q3, QuantityOrQuantityPoint QM,
|
||||
mp_units::QuantityOf<mp_units::dimensionless> K, mp_units::QuantityOf<mp_units::isq::time> T>
|
||||
requires(Q1::quantity_spec == QM::quantity_spec)
|
||||
requires(implicitly_convertible(QM::quantity_spec, Q1::quantity_spec))
|
||||
constexpr state<Q1, Q2, Q3> state_update(const state<Q1, Q2, Q3>& predicted, QM measured, std::array<K, 3> gain,
|
||||
T interval)
|
||||
{
|
||||
|
@@ -516,18 +516,6 @@ template<QuantitySpec Lhs, QuantitySpec Rhs>
|
||||
return is_same_v<Lhs, Rhs>;
|
||||
}
|
||||
|
||||
template<detail::QuantityKindSpec Lhs, detail::QuantityKindSpec Rhs>
|
||||
[[nodiscard]] consteval bool operator==(Lhs, Rhs)
|
||||
{
|
||||
return is_same_v<Lhs, Rhs>;
|
||||
}
|
||||
|
||||
template<QuantitySpec Lhs, detail::QuantityKindSpec Rhs>
|
||||
[[nodiscard]] consteval bool operator==(Lhs, Rhs rhs)
|
||||
{
|
||||
return is_same_v<Lhs, std::remove_const_t<decltype(remove_kind(rhs))>>;
|
||||
}
|
||||
|
||||
[[nodiscard]] consteval QuantitySpec auto inverse(QuantitySpec auto q) { return dimensionless / q; }
|
||||
|
||||
|
||||
|
@@ -105,15 +105,15 @@ static_assert(is_of_type<(kind_of<length> / kind_of<time>)[metre / second], deri
|
||||
|
||||
// Unit as a reference
|
||||
static_assert(is_of_type<42 * metre, quantity<metre, int>>);
|
||||
static_assert(quantity<metre, int>::quantity_spec == length);
|
||||
static_assert(quantity<metre, int>::quantity_spec == kind_of<length>);
|
||||
static_assert(is_of_type<42 * square(metre), quantity<square(metre), int>>);
|
||||
static_assert(quantity<square(metre), int>::quantity_spec == pow<2>(length));
|
||||
static_assert(quantity<square(metre), int>::quantity_spec == kind_of<pow<2>(length)>);
|
||||
static_assert(is_of_type<42 * metre / second, quantity<metre / second, int>>);
|
||||
static_assert(quantity<metre / second, int>::quantity_spec == length / time);
|
||||
static_assert(quantity<metre / second, int>::quantity_spec == kind_of<length / time>);
|
||||
static_assert(is_of_type<42 * newton, quantity<newton, int>>);
|
||||
static_assert(quantity<newton, int>::quantity_spec == mass * length / pow<2>(time));
|
||||
static_assert(quantity<newton, int>::quantity_spec == kind_of<mass * length / pow<2>(time)>);
|
||||
static_assert(is_of_type<42 * hertz, quantity<hertz, int>>);
|
||||
static_assert(quantity<hertz, int>::quantity_spec == frequency);
|
||||
static_assert(quantity<hertz, int>::quantity_spec == kind_of<frequency>);
|
||||
|
||||
// Named quantity/dimension and unit
|
||||
static_assert(is_of_type<5 * power[watt], quantity<reference<power, watt>{}, int>>);
|
||||
@@ -240,13 +240,13 @@ static_assert(invalid_nu_unit<mass * length / time, kilogram * nu::second / nu::
|
||||
static_assert(invalid_nu_unit<force, kilogram * nu::second / nu::second>);
|
||||
|
||||
// mixing associated units and references
|
||||
static_assert(second == time[second]);
|
||||
static_assert(time[second] == second);
|
||||
static_assert(second * second == time[second] * time[second]);
|
||||
static_assert(second != time[second]);
|
||||
static_assert(time[second] != second);
|
||||
static_assert(second * second != time[second] * time[second]);
|
||||
static_assert(second * time[second] == time[second] * second);
|
||||
static_assert(is_of_type<second * time[second], decltype(time[second] * second)>);
|
||||
static_assert(is_of_type<second * time[second], decltype(time[second] * time[second])>);
|
||||
static_assert(metre / second == length[metre] / time[second]);
|
||||
static_assert(metre / second != length[metre] / time[second]);
|
||||
static_assert(metre / time[second] == length[metre] / second);
|
||||
static_assert(is_of_type<metre / time[second], decltype(length[metre] / second)>);
|
||||
static_assert(is_of_type<metre / time[second], decltype(length[metre] / time[second])>);
|
||||
|
Reference in New Issue
Block a user