mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 02:17:16 +02:00
feat: preventing possible future units
crash when using namespace std;
Resolves #317
This commit is contained in:
@ -20,18 +20,18 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/quantity_io.h>
|
||||
#include <units/systems/cgs/cgs.h>
|
||||
#include <units/systems/international/international.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/quantity_io.h>
|
||||
#include <mp_units/systems/cgs/cgs.h>
|
||||
#include <mp_units/systems/international/international.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
constexpr quantity<isq::speed[m / s], int> fixed_int_si_avg_speed(quantity<isq::length[m], int> d,
|
||||
quantity<isq::time[s], int> t)
|
||||
@ -87,7 +87,7 @@ void example()
|
||||
|
||||
// Customary Units (int)
|
||||
{
|
||||
using namespace units::international::unit_symbols;
|
||||
using namespace mp_units::international::unit_symbols;
|
||||
|
||||
constexpr auto distance = isq::length(140, mi);
|
||||
constexpr auto duration = isq::time(2, h);
|
||||
@ -103,7 +103,7 @@ void example()
|
||||
|
||||
// Customary Units (double)
|
||||
{
|
||||
using namespace units::international::unit_symbols;
|
||||
using namespace mp_units::international::unit_symbols;
|
||||
|
||||
constexpr auto distance = isq::length(140., mi);
|
||||
constexpr auto duration = isq::time(2., h);
|
||||
|
@ -20,24 +20,24 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/format.h>
|
||||
#include <units/systems/isq/mechanics.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/constants.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <units/systems/si/units.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/systems/isq/mechanics.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/constants.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
template<class T>
|
||||
requires units::is_scalar<T>
|
||||
inline constexpr bool units::is_vector<T> = true;
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
inline constexpr auto g = si::standard_gravity(1);
|
||||
inline constexpr auto air_density = isq::mass_density(1.225, kg / m3);
|
||||
@ -82,7 +82,7 @@ public:
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::si;
|
||||
using namespace mp_units::si;
|
||||
|
||||
constexpr auto mm = isq::length[unit_symbols::mm]; // helper reference object
|
||||
|
||||
|
@ -20,16 +20,16 @@
|
||||
physical_quantities
|
||||
*/
|
||||
|
||||
#include <units/math.h> // IWYU pragma: keep
|
||||
#include <units/quantity_io.h>
|
||||
#include <units/systems/isq/electromagnetism.h>
|
||||
#include <units/systems/si/si.h>
|
||||
#include <mp_units/math.h> // IWYU pragma: keep
|
||||
#include <mp_units/quantity_io.h>
|
||||
#include <mp_units/systems/isq/electromagnetism.h>
|
||||
#include <mp_units/systems/si/si.h>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units;
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
std::cout << "mp-units capacitor time curve example...\n";
|
||||
std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
|
||||
@ -40,7 +40,7 @@ int main()
|
||||
constexpr auto R = isq::resistance(4.7, si::kilo<si::ohm>);
|
||||
|
||||
for (auto t = isq::time(0, ms); t <= isq::time(50, ms); ++t) {
|
||||
const weak_quantity_of<isq::voltage> auto Vt = V0 * units::exp(-t / (R * C));
|
||||
const weak_quantity_of<isq::voltage> auto Vt = V0 * mp_units::exp(-t / (R * C));
|
||||
|
||||
std::cout << "at " << t << " voltage is ";
|
||||
|
||||
|
@ -15,24 +15,24 @@
|
||||
along with this program. If not, see http://www.gnu.org/licenses./
|
||||
*/
|
||||
|
||||
#include <units/format.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <units/systems/iau/iau.h>
|
||||
#include <units/systems/imperial/imperial.h>
|
||||
#include <units/systems/international/international.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/si.h>
|
||||
#include <units/systems/typographic/typographic.h>
|
||||
#include <units/systems/usc/usc.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/quantity_io.h>
|
||||
#include <mp_units/systems/iau/iau.h>
|
||||
#include <mp_units/systems/imperial/imperial.h>
|
||||
#include <mp_units/systems/international/international.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/si.h>
|
||||
#include <mp_units/systems/typographic/typographic.h>
|
||||
#include <mp_units/systems/usc/usc.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
|
||||
void simple_quantities()
|
||||
{
|
||||
using namespace units;
|
||||
using namespace units::si;
|
||||
using namespace units::international;
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si;
|
||||
using namespace mp_units::international;
|
||||
|
||||
using distance = quantity<isq::distance[kilo<metre>]>;
|
||||
using duration = quantity<isq::duration[second]>;
|
||||
@ -55,9 +55,9 @@ void simple_quantities()
|
||||
|
||||
void quantities_with_typed_units()
|
||||
{
|
||||
using namespace units;
|
||||
using namespace units::si;
|
||||
using namespace units::international;
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si;
|
||||
using namespace mp_units::international;
|
||||
|
||||
constexpr auto km = isq::distance[kilo<metre>](1.0);
|
||||
constexpr auto miles = isq::distance[mile](1.0);
|
||||
@ -103,8 +103,8 @@ void quantities_with_typed_units()
|
||||
|
||||
void calcs_comparison()
|
||||
{
|
||||
using namespace units;
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
std::cout << "\nA distinct unit for each type is efficient and accurate\n"
|
||||
"when adding two values of the same very big\n"
|
||||
|
@ -15,9 +15,9 @@
|
||||
along with this program. If not, see http://www.gnu.org/licenses./
|
||||
*/
|
||||
|
||||
#include <units/format.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/units.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
#include <iostream>
|
||||
#include <type_traits>
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
template<units::Quantity Target, units::Quantity Source>
|
||||
template<mp_units::Quantity Target, mp_units::Quantity Source>
|
||||
requires std::constructible_from<Target, Source>
|
||||
inline constexpr double conversion_factor(Target, Source)
|
||||
{
|
||||
@ -39,7 +39,7 @@ inline constexpr double conversion_factor(Target, Source)
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
std::cout << "conversion factor in mp-units...\n\n";
|
||||
|
||||
|
@ -20,17 +20,17 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/format.h>
|
||||
#include <units/systems/imperial/imperial.h>
|
||||
#include <units/systems/international/international.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/systems/imperial/imperial.h>
|
||||
#include <mp_units/systems/international/international.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
|
||||
using namespace units;
|
||||
using namespace units::international::unit_symbols;
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::international::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
|
||||
// Some basic specs for the warship
|
||||
@ -74,7 +74,7 @@ void print_details(std::string_view description, const Ship& ship)
|
||||
|
||||
int main()
|
||||
{
|
||||
using units::international::unit_symbols::ft; // collides with si::femto<si::tonne>
|
||||
using mp_units::international::unit_symbols::ft; // collides with si::femto<si::tonne>
|
||||
|
||||
// KMS Bismark, using the units the Germans would use, taken from Wiki
|
||||
auto bismark = Ship{.length{isq::length[m](251.)},
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
namespace glide_computer {
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
task::legs task::make_legs(const waypoints& wpts)
|
||||
{
|
||||
|
@ -23,10 +23,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "ranged_representation.h"
|
||||
#include <units/bits/fmt_hacks.h>
|
||||
#include <units/quantity.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/units.h>
|
||||
#include <mp_units/bits/fmt_hacks.h>
|
||||
#include <mp_units/quantity.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
#include <compare>
|
||||
#include <limits>
|
||||
#include <numbers>
|
||||
@ -35,10 +35,12 @@
|
||||
namespace geographic {
|
||||
|
||||
template<typename T = double>
|
||||
using latitude = units::quantity<units::isq::angular_measure[units::si::degree], ranged_representation<T, -90, 90>>;
|
||||
using latitude =
|
||||
mp_units::quantity<mp_units::isq::angular_measure[mp_units::si::degree], ranged_representation<T, -90, 90>>;
|
||||
|
||||
template<typename T = double>
|
||||
using longitude = units::quantity<units::isq::angular_measure[units::si::degree], ranged_representation<T, -180, 180>>;
|
||||
using longitude =
|
||||
mp_units::quantity<mp_units::isq::angular_measure[mp_units::si::degree], ranged_representation<T, -180, 180>>;
|
||||
|
||||
template<class CharT, class Traits, typename T>
|
||||
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const latitude<T>& lat)
|
||||
@ -125,7 +127,7 @@ struct STD_FMT::formatter<geographic::longitude<T>> : formatter<T> {
|
||||
|
||||
namespace geographic {
|
||||
|
||||
using distance = units::quantity<units::isq::distance[units::si::kilo<units::si::metre>]>;
|
||||
using distance = mp_units::quantity<mp_units::isq::distance[mp_units::si::kilo<mp_units::si::metre>]>;
|
||||
|
||||
template<typename T>
|
||||
struct position {
|
||||
@ -136,7 +138,7 @@ struct position {
|
||||
template<typename T>
|
||||
distance spherical_distance(position<T> from, position<T> to)
|
||||
{
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
constexpr auto earth_radius = 6371 * isq::radius[si::kilo<si::metre>];
|
||||
|
||||
constexpr auto p = std::numbers::pi_v<T> / 180;
|
||||
|
@ -23,11 +23,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "geographic.h"
|
||||
#include <units/chrono.h>
|
||||
#include <units/format.h>
|
||||
#include <units/math.h> // IWYU pragma: keep
|
||||
#include <units/quantity_point.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/chrono.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/math.h> // IWYU pragma: keep
|
||||
#include <mp_units/quantity_point.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <initializer_list>
|
||||
@ -54,23 +54,23 @@
|
||||
namespace glide_computer {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Flight_planning#Units_of_measurement
|
||||
inline constexpr struct mean_sea_level : units::absolute_point_origin<units::isq::height> {
|
||||
inline constexpr struct mean_sea_level : mp_units::absolute_point_origin<mp_units::isq::height> {
|
||||
} mean_sea_level;
|
||||
QUANTITY_SPEC(rate_of_climb_speed, units::isq::height / units::isq::time);
|
||||
QUANTITY_SPEC(rate_of_climb_speed, mp_units::isq::height / mp_units::isq::time);
|
||||
|
||||
// length
|
||||
using distance = units::quantity<units::isq::distance[units::si::kilo<units::si::metre>]>;
|
||||
using height = units::quantity<units::isq::height[units::si::metre]>;
|
||||
using altitude = units::quantity_point<units::isq::altitude[units::si::metre], mean_sea_level>;
|
||||
using distance = mp_units::quantity<mp_units::isq::distance[mp_units::si::kilo<mp_units::si::metre>]>;
|
||||
using height = mp_units::quantity<mp_units::isq::height[mp_units::si::metre]>;
|
||||
using altitude = mp_units::quantity_point<mp_units::isq::altitude[mp_units::si::metre], mean_sea_level>;
|
||||
|
||||
// time
|
||||
using duration = units::quantity<units::isq::duration[units::si::second]>;
|
||||
using timestamp =
|
||||
units::quantity_point<units::isq::time[units::si::second], units::chrono_point_origin<std::chrono::system_clock>{}>;
|
||||
using duration = mp_units::quantity<mp_units::isq::duration[mp_units::si::second]>;
|
||||
using timestamp = mp_units::quantity_point<mp_units::isq::time[mp_units::si::second],
|
||||
mp_units::chrono_point_origin<std::chrono::system_clock>{}>;
|
||||
|
||||
// speed
|
||||
using velocity = units::quantity<units::isq::speed[units::si::kilo<units::si::metre> / units::si::hour]>;
|
||||
using rate_of_climb = units::quantity<rate_of_climb_speed[units::si::metre / units::si::second]>;
|
||||
using velocity = mp_units::quantity<mp_units::isq::speed[mp_units::si::kilo<mp_units::si::metre> / mp_units::si::hour]>;
|
||||
using rate_of_climb = mp_units::quantity<rate_of_climb_speed[mp_units::si::metre / mp_units::si::second]>;
|
||||
|
||||
// text output
|
||||
template<class CharT, class Traits>
|
||||
@ -83,11 +83,11 @@ std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>&
|
||||
|
||||
template<>
|
||||
struct STD_FMT::formatter<glide_computer::altitude> :
|
||||
formatter<units::quantity<units::isq::altitude[units::si::metre]>> {
|
||||
formatter<mp_units::quantity<mp_units::isq::altitude[mp_units::si::metre]>> {
|
||||
template<typename FormatContext>
|
||||
auto format(const glide_computer::altitude& a, FormatContext& ctx)
|
||||
{
|
||||
formatter<units::quantity<units::isq::altitude[units::si::metre]>>::format(a.absolute(), ctx);
|
||||
formatter<mp_units::quantity<mp_units::isq::altitude[mp_units::si::metre]>>::format(a.absolute(), ctx);
|
||||
return STD_FMT::format_to(ctx.out(), " AMSL");
|
||||
}
|
||||
};
|
||||
@ -105,7 +105,7 @@ struct glider {
|
||||
std::array<polar_point, 1> polar;
|
||||
};
|
||||
|
||||
constexpr units::weak_quantity_of<units::dimensionless> auto glide_ratio(const glider::polar_point& polar)
|
||||
constexpr mp_units::weak_quantity_of<mp_units::dimensionless> auto glide_ratio(const glider::polar_point& polar)
|
||||
{
|
||||
return polar.v / -polar.climb;
|
||||
}
|
||||
@ -193,10 +193,11 @@ altitude terrain_level_alt(const task& t, const flight_point& pos);
|
||||
|
||||
constexpr height agl(altitude glider_alt, altitude terrain_level) { return glider_alt - terrain_level; }
|
||||
|
||||
inline units::quantity<units::isq::length[units::si::kilo<units::si::metre>]> length_3d(distance dist, height h)
|
||||
inline mp_units::quantity<mp_units::isq::length[mp_units::si::kilo<mp_units::si::metre>]> length_3d(distance dist,
|
||||
height h)
|
||||
{
|
||||
// TODO Should we be able to calculate this on quantity of different kinds? What to return?
|
||||
return hypot(quantity_cast<units::isq::length>(dist), quantity_cast<units::isq::length>(h));
|
||||
return hypot(quantity_cast<mp_units::isq::length>(dist), quantity_cast<mp_units::isq::length>(h));
|
||||
}
|
||||
|
||||
distance glide_distance(const flight_point& pos, const glider& g, const task& t, const safety& s, altitude ground_alt);
|
||||
|
@ -21,11 +21,11 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "glide_computer.h"
|
||||
#include <units/bits/fmt_hacks.h>
|
||||
#include <units/chrono.h>
|
||||
#include <units/systems/international/international.h>
|
||||
#include <units/math.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/bits/fmt_hacks.h>
|
||||
#include <mp_units/chrono.h>
|
||||
#include <mp_units/math.h>
|
||||
#include <mp_units/systems/international/international.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <array>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
@ -38,11 +38,11 @@ namespace {
|
||||
|
||||
using namespace glide_computer;
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
auto get_gliders()
|
||||
{
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
UNITS_DIAGNOSTIC_PUSH
|
||||
UNITS_DIAGNOSTIC_IGNORE_MISSING_BRACES
|
||||
static const std::array gliders = {
|
||||
@ -56,7 +56,7 @@ auto get_gliders()
|
||||
|
||||
auto get_weather_conditions()
|
||||
{
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
static const std::array weather_conditions = {
|
||||
std::pair{"Good", weather{1900 * isq::height[m], 4.3 * rate_of_climb_speed[m / s]}},
|
||||
std::pair{"Medium", weather{1550 * isq::height[m], 2.8 * rate_of_climb_speed[m / s]}},
|
||||
@ -67,7 +67,7 @@ auto get_weather_conditions()
|
||||
auto get_waypoints()
|
||||
{
|
||||
using namespace geographic::literals;
|
||||
using namespace units::international::unit_symbols;
|
||||
using namespace mp_units::international::unit_symbols;
|
||||
static const std::array waypoints = {
|
||||
waypoint{"EPPR", {54.24772_N, 18.6745_E}, altitude{16. * isq::altitude[ft]}}, // N54°14'51.8" E18°40'28.2"
|
||||
waypoint{"EPGI", {53.52442_N, 18.84947_E}, altitude{115. * isq::altitude[ft]}} // N53°31'27.9" E18°50'58.1"
|
||||
@ -157,7 +157,7 @@ void print(const aircraft_tow& tow)
|
||||
|
||||
void example()
|
||||
{
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
const safety sfty = {300 * isq::height[m]};
|
||||
const auto gliders = get_gliders();
|
||||
|
@ -20,14 +20,14 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/format.h>
|
||||
#include <units/systems/international/international.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/quantity_io.h>
|
||||
#include <mp_units/systems/international/international.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
constexpr quantity_of<isq::speed> auto avg_speed(quantity_of<isq::distance> auto d, quantity_of<isq::duration> auto t)
|
||||
{
|
||||
@ -36,8 +36,8 @@ constexpr quantity_of<isq::speed> auto avg_speed(quantity_of<isq::distance> auto
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace units::international::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
using namespace mp_units::international::unit_symbols;
|
||||
|
||||
constexpr auto v1 = isq::speed(110, km / h);
|
||||
constexpr auto v2 = isq::speed(70., mph);
|
||||
|
@ -23,8 +23,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "validated_type.h"
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
@ -44,7 +44,7 @@ public:
|
||||
};
|
||||
|
||||
template<typename T, auto Min, auto Max>
|
||||
inline constexpr bool units::is_scalar<ranged_representation<T, Min, Max>> = units::is_scalar<T>;
|
||||
inline constexpr bool mp_units::is_scalar<ranged_representation<T, Min, Max>> = mp_units::is_scalar<T>;
|
||||
|
||||
template<typename T, auto Min, auto Max>
|
||||
struct std::common_type<std::intmax_t, ranged_representation<T, Min, Max>> :
|
||||
|
@ -23,7 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <utility>
|
||||
|
||||
inline constexpr struct validated_tag {
|
||||
|
@ -22,28 +22,28 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/fmt_hacks.h>
|
||||
#include <units/format.h>
|
||||
#include <units/math.h>
|
||||
#include <units/quantity.h>
|
||||
#include <units/quantity_point.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/bits/fmt_hacks.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/math.h>
|
||||
#include <mp_units/quantity.h>
|
||||
#include <mp_units/quantity_point.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <tuple>
|
||||
|
||||
namespace kalman {
|
||||
|
||||
template<typename T>
|
||||
concept QuantityOrQuantityPoint = units::Quantity<T> || units::QuantityPoint<T>;
|
||||
concept QuantityOrQuantityPoint = mp_units::Quantity<T> || mp_units::QuantityPoint<T>;
|
||||
|
||||
template<units::Dimension auto... Ds>
|
||||
template<mp_units::Dimension auto... Ds>
|
||||
inline constexpr bool are_time_derivatives = false;
|
||||
|
||||
template<units::Dimension auto D>
|
||||
template<mp_units::Dimension auto D>
|
||||
inline constexpr bool are_time_derivatives<D> = true;
|
||||
|
||||
template<units::Dimension auto D1, units::Dimension auto D2, units::Dimension auto... Ds>
|
||||
template<mp_units::Dimension auto D1, mp_units::Dimension auto D2, mp_units::Dimension auto... Ds>
|
||||
inline constexpr bool are_time_derivatives<D1, D2, Ds...> =
|
||||
(D1 / D2 == units::isq::dim_time) && are_time_derivatives<D2, Ds...>;
|
||||
(D1 / D2 == mp_units::isq::dim_time) && are_time_derivatives<D2, Ds...>;
|
||||
|
||||
// state
|
||||
template<QuantityOrQuantityPoint... QQPs>
|
||||
@ -54,7 +54,7 @@ struct state {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
concept State = units::is_specialization_of<T, state>;
|
||||
concept State = mp_units::is_specialization_of<T, state>;
|
||||
|
||||
template<std::size_t Idx, typename... Qs>
|
||||
constexpr auto& get(state<Qs...>& s)
|
||||
@ -73,7 +73,7 @@ template<QuantityOrQuantityPoint QQP, QuantityOrQuantityPoint... QQPs>
|
||||
struct estimation {
|
||||
private:
|
||||
static constexpr auto uncertainty_ref = QQP::reference * QQP::reference;
|
||||
using uncertainty_type = units::quantity<uncertainty_ref, typename QQP::rep>;
|
||||
using uncertainty_type = mp_units::quantity<uncertainty_ref, typename QQP::rep>;
|
||||
public:
|
||||
kalman::state<QQP, QQPs...> state; // TODO extend kalman functions to work with this variadic parameter list
|
||||
uncertainty_type uncertainty;
|
||||
@ -81,29 +81,29 @@ public:
|
||||
|
||||
#if UNITS_COMP_CLANG <= 14
|
||||
|
||||
template<QuantityOrQuantityPoint QQP, units::Quantity U>
|
||||
template<QuantityOrQuantityPoint QQP, mp_units::Quantity U>
|
||||
estimation(state<QQP>, U) -> estimation<QQP>;
|
||||
|
||||
#endif
|
||||
|
||||
// kalman gain
|
||||
template<units::Quantity Q>
|
||||
constexpr units::quantity<units::dimensionless[units::one]> kalman_gain(Q estimate_uncertainty,
|
||||
Q measurement_uncertainty)
|
||||
template<mp_units::Quantity Q>
|
||||
constexpr mp_units::quantity<mp_units::dimensionless[mp_units::one]> kalman_gain(Q estimate_uncertainty,
|
||||
Q measurement_uncertainty)
|
||||
{
|
||||
return estimate_uncertainty / (estimate_uncertainty + measurement_uncertainty);
|
||||
}
|
||||
|
||||
// state update
|
||||
template<typename Q, QuantityOrQuantityPoint QM, units::quantity_of<units::dimensionless> K>
|
||||
template<typename Q, QuantityOrQuantityPoint QM, mp_units::quantity_of<mp_units::dimensionless> K>
|
||||
requires(Q::quantity_spec == QM::quantity_spec)
|
||||
constexpr state<Q> state_update(const state<Q>& predicted, QM measured, K gain)
|
||||
{
|
||||
return {get<0>(predicted) + gain * (measured - get<0>(predicted))};
|
||||
}
|
||||
|
||||
template<typename Q1, typename Q2, QuantityOrQuantityPoint QM, units::quantity_of<units::dimensionless> K,
|
||||
units::quantity_of<units::isq::time> T>
|
||||
template<typename Q1, typename Q2, QuantityOrQuantityPoint QM, mp_units::quantity_of<mp_units::dimensionless> K,
|
||||
mp_units::quantity_of<mp_units::isq::time> T>
|
||||
requires(Q1::quantity_spec == QM::quantity_spec)
|
||||
constexpr state<Q1, Q2> state_update(const state<Q1, Q2>& predicted, QM measured, std::array<K, 2> gain, T interval)
|
||||
{
|
||||
@ -112,8 +112,8 @@ constexpr state<Q1, Q2> state_update(const state<Q1, Q2>& predicted, QM measured
|
||||
return {q1, q2};
|
||||
}
|
||||
|
||||
template<typename Q1, typename Q2, typename Q3, QuantityOrQuantityPoint QM, units::quantity_of<units::dimensionless> K,
|
||||
units::quantity_of<units::isq::time> T>
|
||||
template<typename Q1, typename Q2, typename Q3, QuantityOrQuantityPoint QM,
|
||||
mp_units::quantity_of<mp_units::dimensionless> K, mp_units::quantity_of<mp_units::isq::time> T>
|
||||
requires(Q1::quantity_spec == QM::quantity_spec)
|
||||
constexpr state<Q1, Q2, Q3> state_update(const state<Q1, Q2, Q3>& predicted, QM measured, std::array<K, 3> gain,
|
||||
T interval)
|
||||
@ -125,14 +125,14 @@ constexpr state<Q1, Q2, Q3> state_update(const state<Q1, Q2, Q3>& predicted, QM
|
||||
}
|
||||
|
||||
// covariance update
|
||||
template<units::Quantity Q, units::quantity_of<units::dimensionless> K>
|
||||
template<mp_units::Quantity Q, mp_units::quantity_of<mp_units::dimensionless> K>
|
||||
constexpr Q covariance_update(Q uncertainty, K gain)
|
||||
{
|
||||
return (1 - gain) * uncertainty;
|
||||
}
|
||||
|
||||
// state extrapolation
|
||||
template<typename Q1, typename Q2, units::quantity_of<units::isq::time> T>
|
||||
template<typename Q1, typename Q2, mp_units::quantity_of<mp_units::isq::time> T>
|
||||
constexpr state<Q1, Q2> state_extrapolation(const state<Q1, Q2>& estimated, T interval)
|
||||
{
|
||||
const auto q1 = get<0>(estimated) + get<1>(estimated) * interval;
|
||||
@ -140,7 +140,7 @@ constexpr state<Q1, Q2> state_extrapolation(const state<Q1, Q2>& estimated, T in
|
||||
return {q1, q2};
|
||||
}
|
||||
|
||||
template<typename Q1, typename Q2, typename Q3, units::quantity_of<units::isq::time> T>
|
||||
template<typename Q1, typename Q2, typename Q3, mp_units::quantity_of<mp_units::isq::time> T>
|
||||
constexpr state<Q1, Q2, Q3> state_extrapolation(const state<Q1, Q2, Q3>& estimated, T interval)
|
||||
{
|
||||
const auto q1 = get<0>(estimated) + get<1>(estimated) * interval + get<2>(estimated) * pow<2>(interval) / 2;
|
||||
@ -150,7 +150,7 @@ constexpr state<Q1, Q2, Q3> state_extrapolation(const state<Q1, Q2, Q3>& estimat
|
||||
}
|
||||
|
||||
// covariance extrapolation
|
||||
template<units::Quantity Q>
|
||||
template<mp_units::Quantity Q>
|
||||
constexpr Q covariance_extrapolation(Q uncertainty, Q process_noise_variance)
|
||||
{
|
||||
return uncertainty + process_noise_variance;
|
||||
@ -162,8 +162,8 @@ template<typename... Qs>
|
||||
struct STD_FMT::formatter<kalman::state<Qs...>> {
|
||||
constexpr auto parse(format_parse_context& ctx)
|
||||
{
|
||||
units::detail::dynamic_specs_handler handler(specs, ctx);
|
||||
return units::detail::parse_format_specs(ctx.begin(), ctx.end(), handler);
|
||||
mp_units::detail::dynamic_specs_handler handler(specs, ctx);
|
||||
return mp_units::detail::parse_format_specs(ctx.begin(), ctx.end(), handler);
|
||||
}
|
||||
|
||||
template<typename FormatContext>
|
||||
@ -191,28 +191,28 @@ struct STD_FMT::formatter<kalman::state<Qs...>> {
|
||||
}
|
||||
|
||||
std::string global_format_buffer;
|
||||
units::detail::quantity_global_format_specs<char> global_specs = {specs.fill, specs.align, specs.width};
|
||||
units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs);
|
||||
mp_units::detail::quantity_global_format_specs<char> global_specs = {specs.fill, specs.align, specs.width};
|
||||
mp_units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs);
|
||||
|
||||
return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(value_buffer));
|
||||
}
|
||||
private:
|
||||
units::detail::dynamic_format_specs<char> specs;
|
||||
mp_units::detail::dynamic_format_specs<char> specs;
|
||||
};
|
||||
|
||||
template<typename Q>
|
||||
struct STD_FMT::formatter<kalman::estimation<Q>> {
|
||||
constexpr auto parse(format_parse_context& ctx)
|
||||
{
|
||||
units::detail::dynamic_specs_handler handler(specs, ctx);
|
||||
return units::detail::parse_format_specs(ctx.begin(), ctx.end(), handler);
|
||||
mp_units::detail::dynamic_specs_handler handler(specs, ctx);
|
||||
return mp_units::detail::parse_format_specs(ctx.begin(), ctx.end(), handler);
|
||||
}
|
||||
|
||||
template<typename FormatContext>
|
||||
auto format(kalman::estimation<Q> e, FormatContext& ctx)
|
||||
{
|
||||
units::Quantity auto q = [](const Q& t) {
|
||||
if constexpr (units::Quantity<Q>)
|
||||
mp_units::Quantity auto q = [](const Q& t) {
|
||||
if constexpr (mp_units::Quantity<Q>)
|
||||
return t;
|
||||
else
|
||||
return t.relative();
|
||||
@ -227,11 +227,11 @@ struct STD_FMT::formatter<kalman::estimation<Q>> {
|
||||
}
|
||||
|
||||
std::string global_format_buffer;
|
||||
units::detail::quantity_global_format_specs<char> global_specs = {specs.fill, specs.align, specs.width};
|
||||
units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs);
|
||||
mp_units::detail::quantity_global_format_specs<char> global_specs = {specs.fill, specs.align, specs.width};
|
||||
mp_units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs);
|
||||
|
||||
return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(value_buffer));
|
||||
}
|
||||
private:
|
||||
units::detail::dynamic_format_specs<char> specs;
|
||||
mp_units::detail::dynamic_format_specs<char> specs;
|
||||
};
|
||||
|
@ -21,15 +21,15 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "kalman.h"
|
||||
#include <units/format.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
|
||||
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex1
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
void print_header(const kalman::State auto& initial)
|
||||
{
|
||||
@ -46,7 +46,7 @@ void print(auto iteration, quantity_of<dimensionless> auto gain, Quantity auto m
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
using state = kalman::state<quantity<isq::mass[g]>>;
|
||||
|
||||
const state initial = {1 * isq::mass[kg]};
|
||||
|
@ -21,19 +21,19 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "kalman.h"
|
||||
#include <units/format.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
|
||||
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex2
|
||||
|
||||
template<class T>
|
||||
requires units::is_scalar<T>
|
||||
inline constexpr bool units::is_vector<T> = true;
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
void print_header(const kalman::State auto& initial)
|
||||
{
|
||||
@ -48,7 +48,7 @@ void print(auto iteration, Quantity auto measured, const kalman::State auto& cur
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
using state = kalman::state<quantity<isq::position_vector[m]>, quantity<isq::velocity[m / s]>>;
|
||||
|
||||
const auto interval = 5 * isq::period_duration[s];
|
||||
|
@ -21,19 +21,19 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "kalman.h"
|
||||
#include <units/format.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
|
||||
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex3
|
||||
|
||||
template<class T>
|
||||
requires units::is_scalar<T>
|
||||
inline constexpr bool units::is_vector<T> = true;
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
void print_header(const kalman::State auto& initial)
|
||||
{
|
||||
@ -48,7 +48,7 @@ void print(auto iteration, Quantity auto measured, const kalman::State auto& cur
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
using state = kalman::state<quantity<isq::position_vector[m]>, quantity<isq::velocity[m / s]>>;
|
||||
|
||||
const auto interval = 5 * isq::period_duration[s];
|
||||
|
@ -21,19 +21,19 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "kalman.h"
|
||||
#include <units/format.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
|
||||
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex4
|
||||
|
||||
template<class T>
|
||||
requires units::is_scalar<T>
|
||||
inline constexpr bool units::is_vector<T> = true;
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
void print_header(const kalman::State auto& initial)
|
||||
{
|
||||
@ -48,7 +48,7 @@ void print(auto iteration, Quantity auto measured, const kalman::State auto& cur
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
using state = kalman::state<quantity<isq::position_vector[m]>, quantity<isq::velocity[m / s]>,
|
||||
quantity<isq::acceleration[m / s2]>>;
|
||||
const auto interval = 5. * isq::period_duration[s];
|
||||
|
@ -21,16 +21,16 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "kalman.h"
|
||||
#include <units/format.h>
|
||||
#include <units/math.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/math.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
|
||||
// Based on: https://www.kalmanfilter.net/kalman1d.html#ex5
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
template<Quantity Q>
|
||||
void print_header(kalman::estimation<Q> initial)
|
||||
@ -50,7 +50,7 @@ void print(auto iteration, K gain, Q measured, kalman::estimation<Q> current, ka
|
||||
int main()
|
||||
{
|
||||
using namespace kalman;
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
const estimation initial = {state{60. * isq::height[m]}, pow<2>(15. * isq::height[m])};
|
||||
const std::array measurements = {48.54 * isq::height[m], 47.11 * isq::height[m], 55.01 * isq::height[m],
|
||||
|
@ -21,17 +21,17 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "kalman.h"
|
||||
#include <units/format.h>
|
||||
#include <units/math.h>
|
||||
#include <units/quantity_point.h>
|
||||
#include <units/systems/isq/thermodynamics.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/math.h>
|
||||
#include <mp_units/quantity_point.h>
|
||||
#include <mp_units/systems/isq/thermodynamics.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
|
||||
// Based on: https://www.kalmanfilter.net/kalman1d.html#ex6
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
template<QuantityPoint QP>
|
||||
void print_header(kalman::estimation<QP> initial)
|
||||
|
@ -21,17 +21,17 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "kalman.h"
|
||||
#include <units/format.h>
|
||||
#include <units/math.h>
|
||||
#include <units/quantity_point.h>
|
||||
#include <units/systems/isq/thermodynamics.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/math.h>
|
||||
#include <mp_units/quantity_point.h>
|
||||
#include <mp_units/systems/isq/thermodynamics.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
|
||||
// Based on: https://www.kalmanfilter.net/kalman1d.html#ex7
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
template<QuantityPoint QP>
|
||||
void print_header(kalman::estimation<QP> initial)
|
||||
|
@ -21,17 +21,17 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "kalman.h"
|
||||
#include <units/format.h>
|
||||
#include <units/math.h>
|
||||
#include <units/quantity_point.h>
|
||||
#include <units/systems/isq/thermodynamics.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/math.h>
|
||||
#include <mp_units/quantity_point.h>
|
||||
#include <mp_units/systems/isq/thermodynamics.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
|
||||
// Based on: https://www.kalmanfilter.net/kalman1d.html#ex8
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
template<QuantityPoint QP>
|
||||
void print_header(kalman::estimation<QP> initial)
|
||||
|
@ -22,11 +22,13 @@
|
||||
|
||||
#include <linear_algebra.hpp>
|
||||
// linear_algebra.hpp has to be included first otherwise the header will fail to compile!
|
||||
#include <units/format.h>
|
||||
#include <units/isq/mechanics.h>
|
||||
#include <units/isq/space_and_time.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <units/si/units.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/quantity_io.h>
|
||||
#include <mp_units/systems/isq/mechanics.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace STD_LA {
|
||||
@ -57,170 +59,81 @@ std::ostream& operator<<(std::ostream& os, const matrix<ET, OT>& v)
|
||||
|
||||
} // namespace STD_LA
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
|
||||
template<typename Rep = double>
|
||||
using vector = std::math::fs_vector<Rep, 3>;
|
||||
|
||||
template<typename Rep = double>
|
||||
using matrix = std::math::fs_matrix<Rep, 3, 3>;
|
||||
template<typename Rep>
|
||||
inline constexpr bool mp_units::is_vector<vector<Rep>> = true;
|
||||
|
||||
constexpr auto mm = isq::length[si::milli<si::metre>];
|
||||
constexpr auto m = isq::length[si::metre];
|
||||
constexpr auto km = isq::length[si::kilo<si::metre>];
|
||||
constexpr auto N = isq::force[si::newton];
|
||||
namespace {
|
||||
|
||||
void vector_of_quantity_add()
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
// template<typename Rep = double>
|
||||
// using matrix = std::math::fs_matrix<Rep, 3, 3>;
|
||||
|
||||
|
||||
// constexpr auto mm = isq::length[si::milli<si::metre>];
|
||||
// constexpr auto m = isq::length[si::metre];
|
||||
// constexpr auto km = isq::length[si::kilo<si::metre>];
|
||||
// constexpr auto N = isq::force[si::newton];
|
||||
|
||||
// template<Unit auto U = si::metre, Representation Rep = double>
|
||||
// using length_v = quantity<isq::length[U], vector<Rep>>;
|
||||
|
||||
// template<Unit auto U = si::newton, Representation Rep = double>
|
||||
// using force_v = quantity<isq::force[U], vector<Rep>>;
|
||||
|
||||
void quantity_of_vector_cast()
|
||||
{
|
||||
std::cout << "\nvector_of_quantity_add:\n";
|
||||
std::cout << "\nquantity_of_vector_cast:\n";
|
||||
|
||||
vector<quantity<m>> v = {1 * m, 2 * m, 3 * m};
|
||||
vector<quantity<m>> u = {3 * m, 2 * m, 1 * m};
|
||||
vector<quantity<km>> t = {3 * km, 2 * km, 1 * km};
|
||||
|
||||
std::cout << "v = " << v << "\n";
|
||||
std::cout << "u = " << u << "\n";
|
||||
std::cout << "t = " << t << "\n";
|
||||
|
||||
std::cout << "v + u = " << v + u << "\n";
|
||||
std::cout << "v + t = " << v + t << "\n";
|
||||
std::cout << "t[m] = " << vector<quantity<m>>(t) << "\n";
|
||||
}
|
||||
|
||||
void vector_of_quantity_multiply_same()
|
||||
{
|
||||
std::cout << "\nvector_of_quantity_multiply_same:\n";
|
||||
|
||||
vector<quantity<m>> v = {1 * m, 2 * m, 3 * m};
|
||||
vector<quantity<m>> u = {3 * m, 2 * m, 1 * m};
|
||||
quantity<isq::position_vector[m], vector<int>> v{vector<int>{1001, 1002, 1003}};
|
||||
quantity<isq::position_vector[km], vector<int>> u{vector<int>{3, 2, 1}};
|
||||
|
||||
std::cout << "v = " << v << "\n";
|
||||
std::cout << "u = " << u << "\n";
|
||||
|
||||
std::cout << "v * u = " << v * u << "\n";
|
||||
std::cout << "2 * m * v = " << 2. * m * v << "\n";
|
||||
std::cout << "v[km] = " << quantity_cast<km>(v) << "\n";
|
||||
std::cout << "u[m] = " << u[m] << "\n";
|
||||
}
|
||||
|
||||
void vector_of_quantity_multiply_different()
|
||||
void quantity_of_vector_multiply_by_scalar_value()
|
||||
{
|
||||
std::cout << "\nvector_of_quantity_multiply_different:\n";
|
||||
std::cout << "\nquantity_of_vector_multiply_scalar_value:\n";
|
||||
|
||||
vector<quantity<N>> v = {1 * N, 2 * N, 3 * N};
|
||||
vector<quantity<m>> u = {3 * m, 2 * m, 1 * m};
|
||||
|
||||
std::cout << "v = " << v << "\n";
|
||||
std::cout << "u = " << u << "\n";
|
||||
|
||||
std::cout << "v * u = " << v * u << "\n";
|
||||
std::cout << "2 * N * u = " << 2. * N * u << "\n";
|
||||
std::cout << "2 * u = " << 2 * u << "\n";
|
||||
}
|
||||
|
||||
void vector_of_quantity_divide_by_scalar()
|
||||
{
|
||||
std::cout << "\nvector_of_quantity_divide_by_scalar:\n";
|
||||
|
||||
vector<quantity<m>> v = {4 * m, 8 * m, 12 * m};
|
||||
quantity<isq::position_vector[m], vector<int>> v{vector<int>{1, 2, 3}};
|
||||
|
||||
std::cout << "v = " << v << "\n";
|
||||
|
||||
// TODO Uncomment when bug in the LA is fixed
|
||||
// std::cout << "v / (2 * s) = " << v / (2 * s) << "\n";
|
||||
// std::cout << "v / 2 = " << v / 2 << "\n";
|
||||
std::cout << "2 * v = " << 2 * v << "\n";
|
||||
}
|
||||
|
||||
void vector_of_quantity_tests()
|
||||
void quantity_of_vector_divide_by_scalar_value()
|
||||
{
|
||||
vector_of_quantity_add();
|
||||
vector_of_quantity_multiply_same();
|
||||
vector_of_quantity_multiply_different();
|
||||
vector_of_quantity_divide_by_scalar();
|
||||
std::cout << "\nquantity_of_vector_divide_scalar_value:\n";
|
||||
|
||||
quantity<isq::position_vector[m], vector<int>> v{vector<int>{2, 4, 6}};
|
||||
|
||||
std::cout << "v = " << v << "\n";
|
||||
|
||||
std::cout << "v / 2 = " << v / 2 << "\n";
|
||||
}
|
||||
|
||||
void matrix_of_quantity_add()
|
||||
{
|
||||
std::cout << "\nmatrix_of_quantity_add:\n";
|
||||
|
||||
matrix<quantity<m>> v = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}};
|
||||
matrix<quantity<m>> u = {{3 * m, 2 * m, 1 * m}, {3 * m, 2 * m, 1 * m}, {3 * m, 2 * m, 1 * m}};
|
||||
matrix<quantity<mm>> t = {{3 * mm, 2 * mm, 1 * mm}, {3 * mm, 2 * mm, 1 * mm}, {3 * mm, 2 * mm, 1 * mm}};
|
||||
|
||||
std::cout << "v =\n" << v << "\n";
|
||||
std::cout << "u =\n" << u << "\n";
|
||||
std::cout << "t =\n" << t << "\n";
|
||||
|
||||
std::cout << "v + u =\n" << v + u << "\n";
|
||||
std::cout << "v + t =\n" << v + t << "\n";
|
||||
|
||||
// TODO Uncomment when fixed in the LA lib
|
||||
// std::cout << "v[mm] =\n" << matrix<si::length<si::millimetre>>(v) << "\n";
|
||||
}
|
||||
|
||||
void matrix_of_quantity_multiply_same()
|
||||
{
|
||||
std::cout << "\nmatrix_of_quantity_multiply_same:\n";
|
||||
|
||||
matrix<quantity<m>> v = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}};
|
||||
vector<quantity<m>> u = {3 * m, 2 * m, 1 * m};
|
||||
|
||||
std::cout << "v =\n" << v << "\n";
|
||||
std::cout << "u =\n" << u << "\n";
|
||||
|
||||
std::cout << "v * u =\n" << v * u << "\n";
|
||||
std::cout << "2 * m * u =\n" << 2. * m * u << "\n";
|
||||
}
|
||||
|
||||
void matrix_of_quantity_multiply_different()
|
||||
{
|
||||
std::cout << "\nmatrix_of_quantity_multiply_different:\n";
|
||||
|
||||
vector<quantity<N>> v = {1 * N, 2 * N, 3 * N};
|
||||
matrix<quantity<m>> u = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}};
|
||||
|
||||
std::cout << "v =\n" << v << "\n";
|
||||
std::cout << "u =\n" << u << "\n";
|
||||
|
||||
std::cout << "v * u =\n" << v * u << "\n";
|
||||
std::cout << "2 * N * u =\n" << 2. * N * u << "\n";
|
||||
std::cout << "2 * u =\n" << 2 * u << "\n";
|
||||
}
|
||||
|
||||
void matrix_of_quantity_divide_by_scalar()
|
||||
{
|
||||
std::cout << "\nmatrix_of_quantity_divide_by_scalar:\n";
|
||||
|
||||
matrix<quantity<m>> v = {{2 * m, 4 * m, 6 * m}, {4 * m, 6 * m, 8 * m}, {8 * m, 4 * m, 2 * m}};
|
||||
|
||||
std::cout << "v =\n" << v << "\n";
|
||||
|
||||
// TODO Uncomment when bug in the LA is fixed
|
||||
// std::cout << "v / (2 * s) =\n" << v / (2 * s) << "\n";
|
||||
// std::cout << "v / 2 =\n" << v / 2 << "\n";
|
||||
}
|
||||
|
||||
void matrix_of_quantity_tests()
|
||||
{
|
||||
matrix_of_quantity_add();
|
||||
matrix_of_quantity_multiply_same();
|
||||
matrix_of_quantity_multiply_different();
|
||||
matrix_of_quantity_divide_by_scalar();
|
||||
}
|
||||
|
||||
template<Unit auto U = si::metre, Representation Rep = double>
|
||||
using length_v = quantity<isq::length[U], vector<Rep>>;
|
||||
|
||||
template<Unit auto U = si::newton, Representation Rep = double>
|
||||
using force_v = quantity<isq::force[U], vector<Rep>>;
|
||||
|
||||
void quantity_of_vector_add()
|
||||
{
|
||||
std::cout << "\nquantity_of_vector_add:\n";
|
||||
|
||||
length_v<> v(vector<>{1, 2, 3});
|
||||
length_v<> u(vector<>{3, 2, 1});
|
||||
length_v<si::kilo<si::metre>> t(vector<>{3, 2, 1});
|
||||
// TODO Does not compile (LA bug)
|
||||
// auto v = vector<int>{1, 2, 3} * isq::position_vector[m];
|
||||
// auto u = vector<int>{3, 2, 1} * isq::position_vector[m];
|
||||
// auto t = vector<int>{3, 2, 1} * isq::position_vector[km];
|
||||
|
||||
// quantity<isq::distance[m], vector<int>> v{vector<int>{1, 2, 3}}; // should not compile
|
||||
quantity<isq::position_vector[m], vector<int>> v{vector<int>{1, 2, 3}};
|
||||
quantity<isq::position_vector[m], vector<int>> u{vector<int>{3, 2, 1}};
|
||||
quantity<isq::position_vector[km], vector<int>> t{vector<int>{3, 2, 1}};
|
||||
|
||||
std::cout << "v = " << v << "\n";
|
||||
std::cout << "u = " << u << "\n";
|
||||
@ -228,137 +141,310 @@ void quantity_of_vector_add()
|
||||
|
||||
std::cout << "v + u = " << v + u << "\n";
|
||||
std::cout << "v + t = " << v + t << "\n";
|
||||
std::cout << "t[m] = " << quantity_cast<si::metre>(t) << "\n";
|
||||
}
|
||||
|
||||
void quantity_of_vector_multiply_same()
|
||||
void quantity_of_vector_subtract()
|
||||
{
|
||||
std::cout << "\nquantity_of_vector_multiply_same:\n";
|
||||
std::cout << "\nquantity_of_vector_subtract:\n";
|
||||
|
||||
length_v<> v(vector<>{1, 2, 3});
|
||||
length_v<> u(vector<>{3, 2, 1});
|
||||
quantity<isq::position_vector[m], vector<int>> v{vector<int>{1, 2, 3}};
|
||||
quantity<isq::position_vector[m], vector<int>> u{vector<int>{3, 2, 1}};
|
||||
quantity<isq::position_vector[km], vector<int>> t{vector<int>{3, 2, 1}};
|
||||
|
||||
std::cout << "v = " << v << "\n";
|
||||
std::cout << "u = " << u << "\n";
|
||||
std::cout << "t = " << t << "\n";
|
||||
|
||||
std::cout << "v * u = " << v * u << "\n";
|
||||
std::cout << "2 * m * v = " << 2. * m * v << "\n";
|
||||
std::cout << "v - u = " << v - u << "\n";
|
||||
std::cout << "v - t = " << v - t << "\n";
|
||||
}
|
||||
|
||||
void quantity_of_vector_multiply_different()
|
||||
void quantity_of_vector_divide_by_scalar_quantity()
|
||||
{
|
||||
std::cout << "\nquantity_of_vector_multiply_different:\n";
|
||||
std::cout << "\nquantity_of_vector_divide_scalar:\n";
|
||||
|
||||
force_v<> v(vector<>{1, 2, 3});
|
||||
length_v<> u(vector<>{3, 2, 1});
|
||||
quantity<isq::position_vector[km], vector<int>> pos{vector<int>{30, 20, 10}};
|
||||
auto dur = 2 * isq::duration[h];
|
||||
quantity<isq::velocity[km / h], vector<int>> v = pos / dur;
|
||||
|
||||
std::cout << "pos = " << pos << "\n";
|
||||
std::cout << "dur = " << dur << "\n";
|
||||
|
||||
std::cout << "pos / dur = " << pos / dur << "\n";
|
||||
std::cout << "v = " << v << "\n";
|
||||
std::cout << "u = " << u << "\n";
|
||||
|
||||
std::cout << "v * u = " << v * u << "\n";
|
||||
std::cout << "2 * N * u = " << 2. * N * u << "\n";
|
||||
std::cout << "2 * u = " << 2 * u << "\n";
|
||||
}
|
||||
|
||||
void quantity_of_vector_divide_by_scalar()
|
||||
{
|
||||
std::cout << "\nquantity_of_vector_divide_by_scalar:\n";
|
||||
|
||||
length_v<> v(vector<>{4, 8, 12});
|
||||
// void quantity_of_vector_multiply_same()
|
||||
// {
|
||||
// std::cout << "\nquantity_of_vector_multiply_same:\n";
|
||||
|
||||
std::cout << "v = " << v << "\n";
|
||||
// length_v<> v(vector<>{1, 2, 3});
|
||||
// length_v<> u(vector<>{3, 2, 1});
|
||||
|
||||
// TODO Uncomment when bug in the LA is fixed
|
||||
// std::cout << "v / 2 * s = " << v / 2 * s << "\n";
|
||||
// std::cout << "v / 2 = " << v / 2 << "\n";
|
||||
}
|
||||
// std::cout << "v = " << v << "\n";
|
||||
// std::cout << "u = " << u << "\n";
|
||||
|
||||
// std::cout << "v * u = " << v * u << "\n";
|
||||
// std::cout << "2 * m * v = " << 2. * m * v << "\n";
|
||||
// }
|
||||
|
||||
// void quantity_of_vector_multiply_different()
|
||||
// {
|
||||
// std::cout << "\nquantity_of_vector_multiply_different:\n";
|
||||
|
||||
// force_v<> v(vector<>{1, 2, 3});
|
||||
// length_v<> u(vector<>{3, 2, 1});
|
||||
|
||||
// std::cout << "v = " << v << "\n";
|
||||
// std::cout << "u = " << u << "\n";
|
||||
|
||||
// std::cout << "v * u = " << v * u << "\n";
|
||||
// std::cout << "2 * N * u = " << 2. * N * u << "\n";
|
||||
// std::cout << "2 * u = " << 2 * u << "\n";
|
||||
// }
|
||||
|
||||
// void quantity_of_vector_divide_by_scalar()
|
||||
// {
|
||||
// std::cout << "\nquantity_of_vector_divide_by_scalar:\n";
|
||||
|
||||
// length_v<> v(vector<>{4, 8, 12});
|
||||
|
||||
// std::cout << "v = " << v << "\n";
|
||||
|
||||
// // TODO Uncomment when bug in the LA is fixed
|
||||
// // std::cout << "v / 2 * s = " << v / 2 * s << "\n";
|
||||
// // std::cout << "v / 2 = " << v / 2 << "\n";
|
||||
// }
|
||||
|
||||
void quantity_of_vector_tests()
|
||||
{
|
||||
quantity_of_vector_cast();
|
||||
quantity_of_vector_multiply_by_scalar_value();
|
||||
quantity_of_vector_divide_by_scalar_value();
|
||||
quantity_of_vector_add();
|
||||
quantity_of_vector_multiply_same();
|
||||
quantity_of_vector_multiply_different();
|
||||
quantity_of_vector_divide_by_scalar();
|
||||
quantity_of_vector_subtract();
|
||||
quantity_of_vector_divide_by_scalar_quantity();
|
||||
// quantity_of_vector_multiply_same();
|
||||
// quantity_of_vector_multiply_different();
|
||||
// quantity_of_vector_divide_by_scalar();
|
||||
}
|
||||
|
||||
template<Unit auto U = si::metre, Representation Rep = double>
|
||||
using length_m = quantity<isq::length[U], matrix<Rep>>;
|
||||
// template<Unit auto U = si::metre, Representation Rep = double>
|
||||
// using length_m = quantity<isq::length[U], matrix<Rep>>;
|
||||
|
||||
void quantity_of_matrix_add()
|
||||
{
|
||||
std::cout << "\nquantity_of_matrix_add:\n";
|
||||
// void quantity_of_matrix_add()
|
||||
// {
|
||||
// std::cout << "\nquantity_of_matrix_add:\n";
|
||||
|
||||
length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}});
|
||||
length_m<> u(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}});
|
||||
length_m<si::kilo<si::metre>> t(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}});
|
||||
// length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}});
|
||||
// length_m<> u(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}});
|
||||
// length_m<si::kilo<si::metre>> t(matrix<>{{3, 2, 1}, {3, 2, 1}, {3, 2, 1}});
|
||||
|
||||
std::cout << "v =\n" << v << "\n";
|
||||
std::cout << "u =\n" << u << "\n";
|
||||
std::cout << "t =\n" << t << "\n";
|
||||
// std::cout << "v =\n" << v << "\n";
|
||||
// std::cout << "u =\n" << u << "\n";
|
||||
// std::cout << "t =\n" << t << "\n";
|
||||
|
||||
std::cout << "v + u =\n" << v + u << "\n";
|
||||
std::cout << "v + t =\n" << v + t << "\n";
|
||||
// std::cout << "v + u =\n" << v + u << "\n";
|
||||
// std::cout << "v + t =\n" << v + t << "\n";
|
||||
|
||||
// TODO Uncomment when fixed in the LA lib
|
||||
// std::cout << "v[mm] =\n" << matrix<si::length<si::millimetre>>(v) << "\n";
|
||||
}
|
||||
// // TODO Uncomment when fixed in the LA lib
|
||||
// // std::cout << "v[mm] =\n" << matrix<si::length<si::millimetre>>(v) << "\n";
|
||||
// }
|
||||
|
||||
void quantity_of_matrix_multiply_same()
|
||||
{
|
||||
std::cout << "\nquantity_of_matrix_multiply_same:\n";
|
||||
// void quantity_of_matrix_multiply_same()
|
||||
// {
|
||||
// std::cout << "\nquantity_of_matrix_multiply_same:\n";
|
||||
|
||||
length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}});
|
||||
length_v<> u(vector<>{3, 2, 1});
|
||||
// length_m<> v(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}});
|
||||
// length_v<> u(vector<>{3, 2, 1});
|
||||
|
||||
std::cout << "v =\n" << v << "\n";
|
||||
std::cout << "u =\n" << u << "\n";
|
||||
// std::cout << "v =\n" << v << "\n";
|
||||
// std::cout << "u =\n" << u << "\n";
|
||||
|
||||
std::cout << "v * u =\n" << v * u << "\n";
|
||||
std::cout << "2 * m * u =\n" << 2. * m * u << "\n";
|
||||
}
|
||||
// std::cout << "v * u =\n" << v * u << "\n";
|
||||
// std::cout << "2 * m * u =\n" << 2. * m * u << "\n";
|
||||
// }
|
||||
|
||||
void quantity_of_matrix_multiply_different()
|
||||
{
|
||||
std::cout << "\nquantity_of_matrix_multiply_different:\n";
|
||||
// void quantity_of_matrix_multiply_different()
|
||||
// {
|
||||
// std::cout << "\nquantity_of_matrix_multiply_different:\n";
|
||||
|
||||
force_v<> v(vector<>{1, 2, 3});
|
||||
length_m<> u(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}});
|
||||
// force_v<> v(vector<>{1, 2, 3});
|
||||
// length_m<> u(matrix<>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}});
|
||||
|
||||
std::cout << "v =\n" << v << "\n";
|
||||
std::cout << "u =\n" << u << "\n";
|
||||
// std::cout << "v =\n" << v << "\n";
|
||||
// std::cout << "u =\n" << u << "\n";
|
||||
|
||||
std::cout << "v * u =\n" << v * u << "\n";
|
||||
std::cout << "2 * N * u =\n" << 2. * N * u << "\n";
|
||||
std::cout << "2 * u =\n" << 2 * u << "\n";
|
||||
}
|
||||
// std::cout << "v * u =\n" << v * u << "\n";
|
||||
// std::cout << "2 * N * u =\n" << 2. * N * u << "\n";
|
||||
// std::cout << "2 * u =\n" << 2 * u << "\n";
|
||||
// }
|
||||
|
||||
void quantity_of_matrix_divide_by_scalar()
|
||||
{
|
||||
std::cout << "\nquantity_of_matrix_divide_by_scalar:\n";
|
||||
// void quantity_of_matrix_divide_by_scalar()
|
||||
// {
|
||||
// std::cout << "\nquantity_of_matrix_divide_by_scalar:\n";
|
||||
|
||||
length_m<> v(matrix<>{{2, 4, 6}, {4, 6, 8}, {8, 4, 2}});
|
||||
// length_m<> v(matrix<>{{2, 4, 6}, {4, 6, 8}, {8, 4, 2}});
|
||||
|
||||
std::cout << "v =\n" << v << "\n";
|
||||
// std::cout << "v =\n" << v << "\n";
|
||||
|
||||
// TODO Uncomment when bug in the LA is fixed
|
||||
// std::cout << "v / (2 * s) =\n" << v / (2 * s) << "\n";
|
||||
// std::cout << "v / 2 =\n" << v / 2 << "\n";
|
||||
}
|
||||
// // TODO Uncomment when bug in the LA is fixed
|
||||
// // std::cout << "v / (2 * s) =\n" << v / (2 * s) << "\n";
|
||||
// // std::cout << "v / 2 =\n" << v / 2 << "\n";
|
||||
// }
|
||||
|
||||
void quantity_of_matrix_tests()
|
||||
{
|
||||
quantity_of_matrix_add();
|
||||
quantity_of_matrix_multiply_same();
|
||||
quantity_of_matrix_multiply_different();
|
||||
quantity_of_matrix_divide_by_scalar();
|
||||
}
|
||||
// void quantity_of_matrix_tests()
|
||||
// {
|
||||
// quantity_of_matrix_add();
|
||||
// quantity_of_matrix_multiply_same();
|
||||
// quantity_of_matrix_multiply_different();
|
||||
// quantity_of_matrix_divide_by_scalar();
|
||||
// }
|
||||
|
||||
|
||||
// void vector_of_quantity_add()
|
||||
// {
|
||||
// std::cout << "\nvector_of_quantity_add:\n";
|
||||
|
||||
// vector<quantity<m>> v = {1 * m, 2 * m, 3 * m};
|
||||
// vector<quantity<m>> u = {3 * m, 2 * m, 1 * m};
|
||||
// vector<quantity<km>> t = {3 * km, 2 * km, 1 * km};
|
||||
|
||||
// std::cout << "v = " << v << "\n";
|
||||
// std::cout << "u = " << u << "\n";
|
||||
// std::cout << "t = " << t << "\n";
|
||||
|
||||
// std::cout << "v + u = " << v + u << "\n";
|
||||
// std::cout << "v + t = " << v + t << "\n";
|
||||
// std::cout << "t[m] = " << vector<quantity<m>>(t) << "\n";
|
||||
// }
|
||||
|
||||
// void vector_of_quantity_multiply_same()
|
||||
// {
|
||||
// std::cout << "\nvector_of_quantity_multiply_same:\n";
|
||||
|
||||
// vector<quantity<m>> v = {1 * m, 2 * m, 3 * m};
|
||||
// vector<quantity<m>> u = {3 * m, 2 * m, 1 * m};
|
||||
|
||||
// std::cout << "v = " << v << "\n";
|
||||
// std::cout << "u = " << u << "\n";
|
||||
|
||||
// std::cout << "v * u = " << v * u << "\n";
|
||||
// std::cout << "2 * m * v = " << 2. * m * v << "\n";
|
||||
// }
|
||||
|
||||
// void vector_of_quantity_multiply_different()
|
||||
// {
|
||||
// std::cout << "\nvector_of_quantity_multiply_different:\n";
|
||||
|
||||
// vector<quantity<N>> v = {1 * N, 2 * N, 3 * N};
|
||||
// vector<quantity<m>> u = {3 * m, 2 * m, 1 * m};
|
||||
|
||||
// std::cout << "v = " << v << "\n";
|
||||
// std::cout << "u = " << u << "\n";
|
||||
|
||||
// std::cout << "v * u = " << v * u << "\n";
|
||||
// std::cout << "2 * N * u = " << 2. * N * u << "\n";
|
||||
// std::cout << "2 * u = " << 2 * u << "\n";
|
||||
// }
|
||||
|
||||
// void vector_of_quantity_divide_by_scalar()
|
||||
// {
|
||||
// std::cout << "\nvector_of_quantity_divide_by_scalar:\n";
|
||||
|
||||
// vector<quantity<m>> v = {4 * m, 8 * m, 12 * m};
|
||||
|
||||
// std::cout << "v = " << v << "\n";
|
||||
|
||||
// // TODO Uncomment when bug in the LA is fixed
|
||||
// // std::cout << "v / (2 * s) = " << v / (2 * s) << "\n";
|
||||
// // std::cout << "v / 2 = " << v / 2 << "\n";
|
||||
// }
|
||||
|
||||
// void vector_of_quantity_tests()
|
||||
// {
|
||||
// vector_of_quantity_add();
|
||||
// vector_of_quantity_multiply_same();
|
||||
// vector_of_quantity_multiply_different();
|
||||
// vector_of_quantity_divide_by_scalar();
|
||||
// }
|
||||
|
||||
// void matrix_of_quantity_add()
|
||||
// {
|
||||
// std::cout << "\nmatrix_of_quantity_add:\n";
|
||||
|
||||
// matrix<quantity<m>> v = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}};
|
||||
// matrix<quantity<m>> u = {{3 * m, 2 * m, 1 * m}, {3 * m, 2 * m, 1 * m}, {3 * m, 2 * m, 1 * m}};
|
||||
// matrix<quantity<mm>> t = {{3 * mm, 2 * mm, 1 * mm}, {3 * mm, 2 * mm, 1 * mm}, {3 * mm, 2 * mm, 1 * mm}};
|
||||
|
||||
// std::cout << "v =\n" << v << "\n";
|
||||
// std::cout << "u =\n" << u << "\n";
|
||||
// std::cout << "t =\n" << t << "\n";
|
||||
|
||||
// std::cout << "v + u =\n" << v + u << "\n";
|
||||
// std::cout << "v + t =\n" << v + t << "\n";
|
||||
|
||||
// // TODO Uncomment when fixed in the LA lib
|
||||
// // std::cout << "v[mm] =\n" << matrix<si::length<si::millimetre>>(v) << "\n";
|
||||
// }
|
||||
|
||||
// void matrix_of_quantity_multiply_same()
|
||||
// {
|
||||
// std::cout << "\nmatrix_of_quantity_multiply_same:\n";
|
||||
|
||||
// matrix<quantity<m>> v = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}};
|
||||
// vector<quantity<m>> u = {3 * m, 2 * m, 1 * m};
|
||||
|
||||
// std::cout << "v =\n" << v << "\n";
|
||||
// std::cout << "u =\n" << u << "\n";
|
||||
|
||||
// std::cout << "v * u =\n" << v * u << "\n";
|
||||
// std::cout << "2 * m * u =\n" << 2. * m * u << "\n";
|
||||
// }
|
||||
|
||||
// void matrix_of_quantity_multiply_different()
|
||||
// {
|
||||
// std::cout << "\nmatrix_of_quantity_multiply_different:\n";
|
||||
|
||||
// vector<quantity<N>> v = {1 * N, 2 * N, 3 * N};
|
||||
// matrix<quantity<m>> u = {{1 * m, 2 * m, 3 * m}, {4 * m, 5 * m, 6 * m}, {7 * m, 8 * m, 9 * m}};
|
||||
|
||||
// std::cout << "v =\n" << v << "\n";
|
||||
// std::cout << "u =\n" << u << "\n";
|
||||
|
||||
// std::cout << "v * u =\n" << v * u << "\n";
|
||||
// std::cout << "2 * N * u =\n" << 2. * N * u << "\n";
|
||||
// std::cout << "2 * u =\n" << 2 * u << "\n";
|
||||
// }
|
||||
|
||||
// void matrix_of_quantity_divide_by_scalar()
|
||||
// {
|
||||
// std::cout << "\nmatrix_of_quantity_divide_by_scalar:\n";
|
||||
|
||||
// matrix<quantity<m>> v = {{2 * m, 4 * m, 6 * m}, {4 * m, 6 * m, 8 * m}, {8 * m, 4 * m, 2 * m}};
|
||||
|
||||
// std::cout << "v =\n" << v << "\n";
|
||||
|
||||
// // TODO Uncomment when bug in the LA is fixed
|
||||
// // std::cout << "v / (2 * s) =\n" << v / (2 * s) << "\n";
|
||||
// // std::cout << "v / 2 =\n" << v / 2 << "\n";
|
||||
// }
|
||||
|
||||
// void matrix_of_quantity_tests()
|
||||
// {
|
||||
// matrix_of_quantity_add();
|
||||
// matrix_of_quantity_multiply_same();
|
||||
// matrix_of_quantity_multiply_different();
|
||||
// matrix_of_quantity_divide_by_scalar();
|
||||
// }
|
||||
|
||||
} // namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
vector_of_quantity_tests();
|
||||
matrix_of_quantity_tests();
|
||||
quantity_of_vector_tests();
|
||||
quantity_of_matrix_tests();
|
||||
// quantity_of_matrix_tests();
|
||||
// vector_of_quantity_tests();
|
||||
// matrix_of_quantity_tests();
|
||||
}
|
||||
|
@ -20,10 +20,10 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <units/systems/si/units.h>
|
||||
#include <mp_units/quantity_io.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
#include <cmath>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
@ -118,18 +118,18 @@ private:
|
||||
} // namespace
|
||||
|
||||
template<class T>
|
||||
inline constexpr bool units::is_scalar<measurement<T>> = true;
|
||||
inline constexpr bool mp_units::is_scalar<measurement<T>> = true;
|
||||
template<class T>
|
||||
inline constexpr bool units::is_vector<measurement<T>> = true;
|
||||
inline constexpr bool mp_units::is_vector<measurement<T>> = true;
|
||||
|
||||
static_assert(units::RepresentationOf<measurement<double>, units::quantity_character::scalar>);
|
||||
static_assert(mp_units::RepresentationOf<measurement<double>, mp_units::quantity_character::scalar>);
|
||||
|
||||
namespace {
|
||||
|
||||
void example()
|
||||
{
|
||||
using namespace units;
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
const auto a = isq::acceleration(measurement{9.8, 0.1}, m / s2);
|
||||
const auto t = isq::time(measurement{1.2, 0.1}, s);
|
||||
|
@ -20,19 +20,19 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/format.h>
|
||||
#include <units/systems/si/constants.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/format.h>
|
||||
#include <mp_units/systems/si/constants.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <iostream>
|
||||
|
||||
template<class T>
|
||||
requires units::is_scalar<T>
|
||||
inline constexpr bool units::is_vector<T> = true;
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units::si;
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units::si;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
std::cout << "The seven defining constants of the SI and the seven corresponding units they define:\n";
|
||||
std::cout << STD_FMT::format("- hyperfine transition frequency of Cs: {} = {:%.0Q %q}\n",
|
||||
|
@ -20,23 +20,23 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/math.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <units/systems/isq_angle/isq_angle.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/math.h>
|
||||
#include <mp_units/quantity_io.h>
|
||||
#include <mp_units/systems/isq_angle/isq_angle.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <iostream>
|
||||
|
||||
template<class T>
|
||||
requires units::is_scalar<T>
|
||||
inline constexpr bool units::is_vector<T> = true;
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace units;
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace units::angular::unit_symbols;
|
||||
using units::angular::unit_symbols::deg;
|
||||
using units::angular::unit_symbols::rad;
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
using namespace mp_units::angular::unit_symbols;
|
||||
using mp_units::angular::unit_symbols::deg;
|
||||
using mp_units::angular::unit_symbols::rad;
|
||||
|
||||
const auto lever = isq_angle::position_vector[cm](20);
|
||||
const auto force = isq_angle::force[N](500);
|
||||
|
@ -20,22 +20,22 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <units/math.h>
|
||||
#include <units/quantity_io.h>
|
||||
#include <units/systems/isq/mechanics.h>
|
||||
#include <units/systems/natural/natural.h>
|
||||
#include <units/systems/si/constants.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/math.h>
|
||||
#include <mp_units/quantity_io.h>
|
||||
#include <mp_units/systems/isq/mechanics.h>
|
||||
#include <mp_units/systems/natural/natural.h>
|
||||
#include <mp_units/systems/si/constants.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
template<class T>
|
||||
requires units::is_scalar<T>
|
||||
inline constexpr bool units::is_vector<T> = true;
|
||||
requires mp_units::is_scalar<T>
|
||||
inline constexpr bool mp_units::is_vector<T> = true;
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace mp_units;
|
||||
|
||||
quantity_of<isq::mechanical_energy> auto total_energy(weak_quantity_of<isq::momentum> auto p,
|
||||
weak_quantity_of<isq::mass> auto m,
|
||||
@ -46,7 +46,7 @@ quantity_of<isq::mechanical_energy> auto total_energy(weak_quantity_of<isq::mome
|
||||
|
||||
void si_example()
|
||||
{
|
||||
using namespace units::si::unit_symbols;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
constexpr auto GeV = si::giga<si::electronvolt>;
|
||||
|
||||
constexpr quantity_of<isq::speed> auto c = si::si2019::speed_of_light_in_vacuum(1.);
|
||||
@ -85,8 +85,8 @@ void si_example()
|
||||
|
||||
void natural_example()
|
||||
{
|
||||
using namespace units::natural;
|
||||
using namespace units::natural::unit_symbols;
|
||||
using namespace mp_units::natural;
|
||||
using namespace mp_units::natural::unit_symbols;
|
||||
|
||||
constexpr quantity_of<isq::speed> auto c = 1. * speed_of_light_in_vacuum;
|
||||
const quantity_of<isq::momentum> auto p = 4. * momentum[GeV];
|
||||
|
@ -25,7 +25,7 @@ cmake_minimum_required(VERSION 3.19)
|
||||
option(${projectPrefix}USE_LIBFMT "Enables usage of libfmt instead of the one from 'std'" ON)
|
||||
message(STATUS "${projectPrefix}USE_LIBFMT: ${${projectPrefix}USE_LIBFMT}")
|
||||
|
||||
add_units_module(core-fmt DEPENDENCIES mp-units::core HEADERS include/units/format.h)
|
||||
add_units_module(core-fmt DEPENDENCIES mp-units::core HEADERS include/mp_units/format.h)
|
||||
target_compile_definitions(mp-units-core-fmt INTERFACE ${projectPrefix}USE_LIBFMT=$<BOOL:${${projectPrefix}USE_LIBFMT}>)
|
||||
|
||||
if(${projectPrefix}USE_LIBFMT)
|
||||
|
@ -28,14 +28,14 @@
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <units/bits/fmt_hacks.h>
|
||||
#include <mp_units/bits/fmt_hacks.h>
|
||||
#include <concepts>
|
||||
#include <limits>
|
||||
#include <string_view>
|
||||
|
||||
// most of the below code is based on/copied from libfmt
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
struct auto_id {};
|
||||
|
||||
@ -382,11 +382,11 @@ template<std::input_iterator It, std::sentinel_for<It> S, typename SpecHandler>
|
||||
|
||||
if (begin == end) return begin;
|
||||
|
||||
begin = ::units::detail::parse_align(begin, end, handler);
|
||||
begin = ::mp_units::detail::parse_align(begin, end, handler);
|
||||
if (begin == end) return begin;
|
||||
|
||||
// Parse sign.
|
||||
begin = ::units::detail::parse_sign(begin, end, handler);
|
||||
begin = ::mp_units::detail::parse_sign(begin, end, handler);
|
||||
if (begin == end) return begin;
|
||||
|
||||
if (*begin == '#') {
|
||||
@ -400,12 +400,12 @@ template<std::input_iterator It, std::sentinel_for<It> S, typename SpecHandler>
|
||||
if (++begin == end) return begin;
|
||||
}
|
||||
|
||||
begin = ::units::detail::parse_width(begin, end, handler);
|
||||
begin = ::mp_units::detail::parse_width(begin, end, handler);
|
||||
if (begin == end) return begin;
|
||||
|
||||
// Parse precision.
|
||||
if (*begin == '.') {
|
||||
begin = ::units::detail::parse_precision(begin, end, handler);
|
||||
begin = ::mp_units::detail::parse_precision(begin, end, handler);
|
||||
if (begin == end) return begin;
|
||||
}
|
||||
|
||||
@ -465,4 +465,4 @@ private:
|
||||
ParseContext& context_;
|
||||
};
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
@ -27,7 +27,7 @@
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
|
||||
#ifndef UNITS_USE_LIBFMT
|
||||
#define UNITS_USE_LIBFMT 1
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/algorithm.h>
|
||||
#include <units/bits/fmt.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/quantity.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/algorithm.h>
|
||||
#include <mp_units/bits/fmt.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/quantity.h>
|
||||
#include <mp_units/unit.h>
|
||||
#include <cstdint>
|
||||
|
||||
// Grammar
|
||||
@ -46,7 +46,7 @@
|
||||
// units-unit-symbol-solidus ::= one of "oan"
|
||||
// units-unit-symbol-separator ::= one of "sd"
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
// Holds specs about the whole object
|
||||
template<typename CharT>
|
||||
@ -259,17 +259,17 @@ template<std::input_iterator It, std::sentinel_for<It> S>
|
||||
return it;
|
||||
}
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
||||
|
||||
template<auto Reference, typename Rep, typename CharT>
|
||||
struct STD_FMT::formatter<units::quantity<Reference, Rep>, CharT> {
|
||||
struct STD_FMT::formatter<mp_units::quantity<Reference, Rep>, CharT> {
|
||||
private:
|
||||
using quantity = units::quantity<Reference, Rep>;
|
||||
using quantity = mp_units::quantity<Reference, Rep>;
|
||||
using iterator = TYPENAME STD_FMT::basic_format_parse_context<CharT>::iterator;
|
||||
|
||||
bool quantity_value = false;
|
||||
bool quantity_unit = false;
|
||||
units::detail::quantity_format_specs<CharT> specs;
|
||||
mp_units::detail::quantity_format_specs<CharT> specs;
|
||||
std::basic_string_view<CharT> format_str;
|
||||
|
||||
struct spec_handler {
|
||||
@ -277,9 +277,9 @@ private:
|
||||
STD_FMT::basic_format_parse_context<CharT>& context;
|
||||
|
||||
constexpr void on_fill(std::basic_string_view<CharT> fill) { f.specs.global.fill = fill; }
|
||||
constexpr void on_align(units::detail::fmt_align align) { f.specs.global.align = align; }
|
||||
constexpr void on_align(mp_units::detail::fmt_align align) { f.specs.global.align = align; }
|
||||
constexpr void on_width(int width) { f.specs.global.width = width; }
|
||||
constexpr void on_sign(units::detail::fmt_sign sign) { f.specs.rep.sign = sign; }
|
||||
constexpr void on_sign(mp_units::detail::fmt_sign sign) { f.specs.rep.sign = sign; }
|
||||
constexpr void on_hash() { f.specs.rep.alt = true; }
|
||||
constexpr void on_precision(int precision) { f.specs.rep.precision = precision; }
|
||||
constexpr void on_localized() { f.specs.rep.localized = true; }
|
||||
@ -297,13 +297,13 @@ private:
|
||||
template<typename T>
|
||||
constexpr void on_dynamic_width(T t)
|
||||
{
|
||||
f.specs.global.dynamic_width_index = units::detail::on_dynamic_arg(t, context);
|
||||
f.specs.global.dynamic_width_index = mp_units::detail::on_dynamic_arg(t, context);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr void on_dynamic_precision(T t)
|
||||
{
|
||||
f.specs.rep.dynamic_precision_index = units::detail::on_dynamic_arg(t, context);
|
||||
f.specs.rep.dynamic_precision_index = mp_units::detail::on_dynamic_arg(t, context);
|
||||
}
|
||||
|
||||
template<std::input_iterator It, std::sentinel_for<It> S>
|
||||
@ -314,7 +314,7 @@ private:
|
||||
template<std::input_iterator It, std::sentinel_for<It> S>
|
||||
constexpr void on_quantity_value(It begin, S end)
|
||||
{
|
||||
if (begin != end) units::detail::parse_units_rep(begin, end, *this, units::treat_as_floating_point<Rep>);
|
||||
if (begin != end) mp_units::detail::parse_units_rep(begin, end, *this, mp_units::treat_as_floating_point<Rep>);
|
||||
f.quantity_value = true;
|
||||
}
|
||||
|
||||
@ -329,29 +329,29 @@ private:
|
||||
throw STD_FMT::format_error("invalid unit modifier specified");
|
||||
}
|
||||
|
||||
if (auto it = units::detail::at_most_one_of(begin, end, "UA"); it != end) {
|
||||
if (auto it = mp_units::detail::at_most_one_of(begin, end, "UA"); it != end) {
|
||||
if (*it == 'U')
|
||||
f.specs.unit.encoding = units::text_encoding::unicode;
|
||||
f.specs.unit.encoding = mp_units::text_encoding::unicode;
|
||||
else
|
||||
f.specs.unit.encoding = units::text_encoding::ascii;
|
||||
f.specs.unit.encoding = mp_units::text_encoding::ascii;
|
||||
}
|
||||
|
||||
if (auto it = units::detail::at_most_one_of(begin, end, "oan"); it != end) {
|
||||
if (auto it = mp_units::detail::at_most_one_of(begin, end, "oan"); it != end) {
|
||||
if (*it == 'o')
|
||||
f.specs.unit.solidus = units::unit_symbol_solidus::one_denominator;
|
||||
f.specs.unit.solidus = mp_units::unit_symbol_solidus::one_denominator;
|
||||
else if (*it == 'a')
|
||||
f.specs.unit.solidus = units::unit_symbol_solidus::always;
|
||||
f.specs.unit.solidus = mp_units::unit_symbol_solidus::always;
|
||||
else
|
||||
f.specs.unit.solidus = units::unit_symbol_solidus::never;
|
||||
f.specs.unit.solidus = mp_units::unit_symbol_solidus::never;
|
||||
}
|
||||
|
||||
if (auto it = units::detail::at_most_one_of(begin, end, "sd"); it != end) {
|
||||
if (auto it = mp_units::detail::at_most_one_of(begin, end, "sd"); it != end) {
|
||||
if (*it == 's')
|
||||
f.specs.unit.separator = units::unit_symbol_separator::space;
|
||||
f.specs.unit.separator = mp_units::unit_symbol_separator::space;
|
||||
else {
|
||||
if (f.specs.unit.encoding == units::text_encoding::ascii)
|
||||
if (f.specs.unit.encoding == mp_units::text_encoding::ascii)
|
||||
throw STD_FMT::format_error("dot unit separator allowed only for Unicode encoding");
|
||||
f.specs.unit.separator = units::unit_symbol_separator::dot;
|
||||
f.specs.unit.separator = mp_units::unit_symbol_separator::dot;
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,19 +370,19 @@ private:
|
||||
spec_handler handler{*this, ctx};
|
||||
|
||||
// parse alignment
|
||||
begin = units::detail::parse_align(begin, end, handler);
|
||||
begin = mp_units::detail::parse_align(begin, end, handler);
|
||||
if (begin == end) return {begin, begin};
|
||||
|
||||
// parse width
|
||||
begin = units::detail::parse_width(begin, end, handler);
|
||||
begin = mp_units::detail::parse_width(begin, end, handler);
|
||||
if (begin == end) return {begin, begin};
|
||||
|
||||
// parse units-specific specification
|
||||
end = units::detail::parse_units_format(begin, end, handler);
|
||||
end = mp_units::detail::parse_units_format(begin, end, handler);
|
||||
|
||||
if (specs.global.align == units::detail::fmt_align::none && (!quantity_unit || quantity_value))
|
||||
if (specs.global.align == mp_units::detail::fmt_align::none && (!quantity_unit || quantity_value))
|
||||
// quantity values should behave like numbers (by default aligned to right)
|
||||
specs.global.align = units::detail::fmt_align::right;
|
||||
specs.global.align = mp_units::detail::fmt_align::right;
|
||||
|
||||
return {begin, end};
|
||||
}
|
||||
@ -395,15 +395,15 @@ private:
|
||||
|
||||
if (begin == end || *begin == '}') {
|
||||
// default format should print value followed by the unit separated with 1 space
|
||||
out = units::detail::format_units_quantity_value<CharT>(out, q.number(), specs.rep, ctx.locale());
|
||||
if constexpr (!std::derived_from<decltype(Reference.unit), units::derived_unit<>>) {
|
||||
out = mp_units::detail::format_units_quantity_value<CharT>(out, q.number(), specs.rep, ctx.locale());
|
||||
if constexpr (!std::derived_from<decltype(Reference.unit), mp_units::derived_unit<>>) {
|
||||
*out++ = CharT(' ');
|
||||
out = unit_symbol_to<CharT>(out, Reference.unit);
|
||||
}
|
||||
} else {
|
||||
// user provided format
|
||||
units::detail::quantity_formatter f(out, q, specs, ctx.locale());
|
||||
units::detail::parse_units_format(begin, end, f);
|
||||
mp_units::detail::quantity_formatter f(out, q, specs, ctx.locale());
|
||||
mp_units::detail::parse_units_format(begin, end, f);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -423,10 +423,10 @@ public:
|
||||
// process dynamic width and precision
|
||||
if (specs.global.dynamic_width_index >= 0)
|
||||
specs.global.width =
|
||||
units::detail::get_dynamic_spec<units::detail::width_checker>(specs.global.dynamic_width_index, ctx);
|
||||
mp_units::detail::get_dynamic_spec<mp_units::detail::width_checker>(specs.global.dynamic_width_index, ctx);
|
||||
if (specs.rep.dynamic_precision_index >= 0)
|
||||
specs.rep.precision =
|
||||
units::detail::get_dynamic_spec<units::detail::precision_checker>(specs.rep.dynamic_precision_index, ctx);
|
||||
mp_units::detail::get_dynamic_spec<mp_units::detail::precision_checker>(specs.rep.dynamic_precision_index, ctx);
|
||||
|
||||
if (specs.global.width == 0) {
|
||||
// Avoid extra copying if width is not specified
|
||||
@ -443,7 +443,7 @@ public:
|
||||
// In `global_format_buffer` we will create a global format string
|
||||
// e.g. "{:*^10%.1Q_%q}, 1.23_q_m" => "{:*^10}"
|
||||
std::basic_string<CharT> global_format_buffer;
|
||||
units::detail::format_global_buffer<CharT>(std::back_inserter(global_format_buffer), specs.global);
|
||||
mp_units::detail::format_global_buffer<CharT>(std::back_inserter(global_format_buffer), specs.global);
|
||||
|
||||
// Format the `quantity buffer` using specs from `global_format_buffer`
|
||||
// In the example, equivalent to STD_FMT::format("{:*^10}", "1.2_m")
|
@ -22,4 +22,4 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(core-io DEPENDENCIES mp-units::core HEADERS include/units/quantity_io.h)
|
||||
add_units_module(core-io DEPENDENCIES mp-units::core HEADERS include/mp_units/quantity_io.h)
|
||||
|
@ -23,11 +23,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/quantity.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/quantity.h>
|
||||
#include <mp_units/unit.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -61,4 +61,4 @@ std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>&
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -33,14 +33,14 @@ check_libcxx_in_use(${projectPrefix}LIBCXX)
|
||||
add_library(
|
||||
mp-units-core
|
||||
INTERFACE
|
||||
include/units/customization_points.h
|
||||
include/units/dimension.h
|
||||
include/units/quantity.h
|
||||
include/units/quantity_point.h
|
||||
include/units/quantity_spec.h
|
||||
include/units/reference.h
|
||||
include/units/system_reference.h
|
||||
include/units/unit.h
|
||||
include/mp_units/customization_points.h
|
||||
include/mp_units/dimension.h
|
||||
include/mp_units/quantity.h
|
||||
include/mp_units/quantity_point.h
|
||||
include/mp_units/quantity_spec.h
|
||||
include/mp_units/reference.h
|
||||
include/mp_units/system_reference.h
|
||||
include/mp_units/unit.h
|
||||
)
|
||||
target_compile_features(mp-units-core INTERFACE cxx_std_20)
|
||||
target_link_libraries(mp-units-core INTERFACE gsl::gsl-lite)
|
||||
|
@ -22,13 +22,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
#include <mp_units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
#include <compare>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <ranges>
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
// TODO refactor two below functions with std::ranges when moved to modules
|
||||
|
||||
@ -109,7 +109,7 @@ constexpr auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2, Cmp
|
||||
template<class I1, class I2>
|
||||
constexpr auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2)
|
||||
{
|
||||
return ::units::detail::lexicographical_compare_three_way(f1, l1, f2, l2, std::compare_three_way());
|
||||
return ::mp_units::detail::lexicographical_compare_three_way(f1, l1, f2, l2, std::compare_three_way());
|
||||
}
|
||||
|
||||
template<class ForwardIt>
|
||||
@ -169,8 +169,8 @@ template<std::ranges::input_range R, std::weakly_incrementable O>
|
||||
requires std::indirectly_copyable<std::ranges::iterator_t<R>, O>
|
||||
constexpr copy_result<std::ranges::borrowed_iterator_t<R>, O> copy(R&& r, O result)
|
||||
{
|
||||
return ::units::detail::copy(std::ranges::begin(r), std::ranges::end(r), std::move(result));
|
||||
return ::mp_units::detail::copy(std::ranges::begin(r), std::ranges::end(r), std::move(result));
|
||||
}
|
||||
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/type_list.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/math_concepts.h>
|
||||
#include <units/bits/ratio.h>
|
||||
#include <mp_units/bits/external/type_list.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/math_concepts.h>
|
||||
#include <mp_units/bits/ratio.h>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief Type list type used by the expression template framework
|
||||
@ -554,4 +554,4 @@ template<template<typename> typename Proj, template<typename...> typename To, ty
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,9 +22,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
#include <mp_units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
// TODO use <algorithm> when moved to C++20 modules (parsing takes too long for each translation unit)
|
||||
#include <units/bits/algorithm.h>
|
||||
#include <mp_units/bits/algorithm.h>
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <compare>
|
||||
@ -34,7 +34,7 @@
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief A compile-time fixed string
|
||||
@ -111,4 +111,4 @@ basic_fixed_string(CharT) -> basic_fixed_string<CharT, 1>;
|
||||
template<std::size_t N>
|
||||
using fixed_string = basic_fixed_string<char, N>;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,14 +22,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
#include <mp_units/bits/external/hacks.h> // IWYU pragma: keep
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
UNITS_DIAGNOSTIC_PUSH
|
||||
UNITS_DIAGNOSTIC_IGNORE_EXPR_ALWAYS_TF
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -294,6 +294,6 @@ struct type_list_sort_impl<List<Types...>, Pred> {
|
||||
template<TypeList List, template<typename, typename> typename Pred>
|
||||
using type_list_sort = TYPENAME detail::type_list_sort_impl<List, Pred>::type;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
|
||||
UNITS_DIAGNOSTIC_POP
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
// conditional
|
||||
namespace detail {
|
||||
@ -80,4 +80,4 @@ concept is_derived_from_specialization_of = requires(T* t) { detail::to_base_spe
|
||||
template<typename T, typename... Ts>
|
||||
concept one_of = (false || ... || std::same_as<T, Ts>);
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,23 +22,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <units/bits/external/type_name.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/math_concepts.h>
|
||||
#include <units/bits/prime.h>
|
||||
#include <units/bits/ratio.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
#include <units/bits/text_tools.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <mp_units/bits/expression_template.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <mp_units/bits/external/type_name.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/math_concepts.h>
|
||||
#include <mp_units/bits/prime.h>
|
||||
#include <mp_units/bits/ratio.h>
|
||||
#include <mp_units/bits/symbol_text.h>
|
||||
#include <mp_units/bits/text_tools.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
#include <numbers>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -844,4 +844,4 @@ template<Magnitude auto M>
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
template<auto N>
|
||||
concept gt_zero = (N > 0);
|
||||
@ -32,4 +32,4 @@ concept gt_zero = (N > 0);
|
||||
template<auto N>
|
||||
concept non_zero = (N != 0);
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/algorithm.h>
|
||||
#include <mp_units/bits/algorithm.h>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@ -30,7 +30,7 @@
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
[[nodiscard]] consteval bool is_prime_by_trial_division(std::uintmax_t n)
|
||||
{
|
||||
@ -153,4 +153,4 @@ struct wheel_factorizer {
|
||||
[[nodiscard]] static consteval bool is_prime(std::size_t n) { return (n > 1) && find_first_factor(n) == n; }
|
||||
};
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
@ -22,19 +22,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/magnitude.h>
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/magnitude.h>
|
||||
#include <mp_units/bits/quantity_concepts.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/reference.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
UNITS_DIAGNOSTIC_PUSH
|
||||
// warning C4244: 'argument': conversion from 'intmax_t' to 'T', possible loss of data with T=int
|
||||
UNITS_DIAGNOSTIC_IGNORE_LOSS_OF_DATA
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
template<Reference auto R, RepresentationOf<R.quantity_spec.character> Rep>
|
||||
class quantity;
|
||||
@ -188,11 +188,11 @@ template<Representation ToRep, auto R, typename Rep>
|
||||
// *
|
||||
// * This cast gets the target quantity point type to cast to or anything that works for quantity_cast. For example:
|
||||
// *
|
||||
// * auto q1 = units::quantity_point_cast<decltype(quantity_point{0_q_s})>(quantity_point{1_q_ms});
|
||||
// * auto q1 = units::quantity_point_cast<units::isq::si::time<units::isq::si::second>>(quantity_point{1_q_ms});
|
||||
// * auto q1 = units::quantity_point_cast<units::isq::si::dim_acceleration>(quantity_point{200_q_Gal});
|
||||
// * auto q1 = units::quantity_point_cast<units::isq::si::second>(quantity_point{1_q_ms});
|
||||
// * auto q1 = units::quantity_point_cast<int>(quantity_point{1_q_ms});
|
||||
// * auto q1 = mp_units::quantity_point_cast<decltype(quantity_point{0_q_s})>(quantity_point{1_q_ms});
|
||||
// * auto q1 = mp_units::quantity_point_cast<mp_units::isq::si::time<mp_units::isq::si::second>>(quantity_point{1_q_ms});
|
||||
// * auto q1 = mp_units::quantity_point_cast<mp_units::isq::si::dim_acceleration>(quantity_point{200_q_Gal});
|
||||
// * auto q1 = mp_units::quantity_point_cast<mp_units::isq::si::second>(quantity_point{1_q_ms});
|
||||
// * auto q1 = mp_units::quantity_point_cast<int>(quantity_point{1_q_ms});
|
||||
// *
|
||||
// * @tparam CastSpec a target quantity point type to cast to or anything that works for quantity_cast
|
||||
// */
|
||||
@ -219,7 +219,7 @@ template<Representation ToRep, auto R, typename Rep>
|
||||
// *
|
||||
// * This cast gets both the target dimension and unit to cast to. For example:
|
||||
// *
|
||||
// * auto q1 = units::quantity_point_cast<units::isq::si::dim_speed, units::isq::si::kilometre_per_hour>(v1);
|
||||
// * auto q1 = mp_units::quantity_point_cast<mp_units::isq::si::dim_speed, mp_units::isq::si::kilometre_per_hour>(v1);
|
||||
// *
|
||||
// * @note This cast is especially useful when working with quantity points of unknown dimensions
|
||||
// * (@c unknown_dimension).
|
||||
@ -234,6 +234,6 @@ template<Representation ToRep, auto R, typename Rep>
|
||||
// return quantity_point_cast<quantity_point<rebind_point_origin_dimension<O, ToD>, ToU, Rep>>(q);
|
||||
// }
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
|
||||
UNITS_DIAGNOSTIC_POP
|
@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief Quantity character
|
||||
@ -243,4 +243,4 @@ concept quantity_point_like = requires(T q) {
|
||||
decltype(quantity_point_like_traits<T>::relative(q))>;
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -23,8 +23,8 @@
|
||||
#pragma once
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <units/bits/math_concepts.h>
|
||||
#include <units/bits/ratio_maths.h>
|
||||
#include <mp_units/bits/math_concepts.h>
|
||||
#include <mp_units/bits/ratio_maths.h>
|
||||
#include <cstdint>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include <compare>
|
||||
#include <numeric>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
struct ratio;
|
||||
constexpr ratio inverse(const ratio& r);
|
||||
@ -89,4 +89,4 @@ struct ratio {
|
||||
return ratio(res[0], res[1]);
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -31,7 +31,7 @@
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] constexpr T abs(T v) noexcept
|
||||
@ -92,4 +92,4 @@ constexpr void normalize(std::intmax_t& num, std::intmax_t& den)
|
||||
return lhs * rhs;
|
||||
}
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
@ -23,8 +23,8 @@
|
||||
#pragma once
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <units/bits/external/fixed_string.h>
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <mp_units/bits/external/fixed_string.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <compare>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -185,4 +185,4 @@ template<typename UnicodeCharT, std::size_t N, std::size_t M>
|
||||
basic_symbol_text(const basic_fixed_string<UnicodeCharT, N>&, const basic_fixed_string<char, M>&)
|
||||
-> basic_symbol_text<UnicodeCharT, N, M>;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/fixed_string.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
#include <mp_units/bits/external/fixed_string.h>
|
||||
#include <mp_units/bits/symbol_text.h>
|
||||
|
||||
namespace units::detail {
|
||||
namespace mp_units::detail {
|
||||
|
||||
template<std::intmax_t Value>
|
||||
requires(0 <= Value) && (Value < 10)
|
||||
@ -84,4 +84,4 @@ template<std::intmax_t Value>
|
||||
return regular<Value / 10>() + regular<Value % 10>();
|
||||
}
|
||||
|
||||
} // namespace units::detail
|
||||
} // namespace mp_units::detail
|
@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief Specifies if a value of a type should be treated as a floating-point value
|
||||
@ -64,8 +64,8 @@ inline constexpr bool is_scalar = std::is_floating_point_v<Rep> || (std::is_inte
|
||||
*
|
||||
* @code{.cpp}
|
||||
* template<class T>
|
||||
* requires units::is_scalar<T>
|
||||
* inline constexpr bool units::is_vector<T> = true;
|
||||
* requires mp_units::is_scalar<T>
|
||||
* inline constexpr bool mp_units::is_vector<T> = true;
|
||||
* @endcode
|
||||
*/
|
||||
template<typename Rep>
|
||||
@ -85,7 +85,7 @@ inline constexpr bool is_tensor = false;
|
||||
/**
|
||||
* @brief A type trait that defines zero, one, min, and max for a representation type
|
||||
*
|
||||
* The zero, one, min, and max member functions in units::quantity forward their work to
|
||||
* The zero, one, min, and max member functions in mp_units::quantity forward their work to
|
||||
* these methods. This type can be specialized if the representation Rep requires a specific
|
||||
* implementation to return these quantity objects.
|
||||
*
|
||||
@ -153,4 +153,4 @@ struct quantity_like_traits;
|
||||
template<typename T>
|
||||
struct quantity_point_like_traits;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
#include <mp_units/bits/expression_template.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/symbol_text.h>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief A dimension of a base quantity
|
||||
@ -256,4 +256,4 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Dimension D>
|
||||
|
||||
// TODO consider adding the support for text output of the dimensional equation
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -23,19 +23,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/quantity_cast.h>
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/customization_points.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/quantity_cast.h>
|
||||
#include <mp_units/bits/quantity_concepts.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
#include <mp_units/reference.h>
|
||||
#include <mp_units/unit.h>
|
||||
#include <compare>
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -153,10 +153,10 @@ public:
|
||||
#endif
|
||||
|
||||
template<Unit U>
|
||||
requires quantity_convertible_to_<quantity, quantity<::units::reference<quantity_spec, U{}>{}, Rep>>
|
||||
[[nodiscard]] constexpr quantity<::units::reference<quantity_spec, U{}>{}, Rep> operator[](U) const
|
||||
requires quantity_convertible_to_<quantity, quantity<::mp_units::reference<quantity_spec, U{}>{}, Rep>>
|
||||
[[nodiscard]] constexpr quantity<::mp_units::reference<quantity_spec, U{}>{}, Rep> operator[](U) const
|
||||
{
|
||||
return quantity<::units::reference<quantity_spec, U{}>{}, Rep>{*this};
|
||||
return quantity<::mp_units::reference<quantity_spec, U{}>{}, Rep>{*this};
|
||||
}
|
||||
|
||||
// member unary operators
|
||||
@ -337,44 +337,44 @@ public:
|
||||
[[nodiscard]] friend constexpr Quantity auto operator+(const quantity& lhs, const Value& rhs)
|
||||
requires requires { // TODO: Simplify when Clang catches up.
|
||||
requires !Quantity<Value>;
|
||||
requires unit == ::units::one;
|
||||
requires unit == ::mp_units::one;
|
||||
requires invoke_result_of_<R.quantity_spec.character, std::plus<>, rep, Value>;
|
||||
}
|
||||
{
|
||||
return ::units::quantity(lhs.number() + rhs);
|
||||
return ::mp_units::quantity(lhs.number() + rhs);
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator+(const Value& lhs, const quantity& rhs)
|
||||
requires requires { // TODO: Simplify when Clang catches up.
|
||||
requires !Quantity<Value>;
|
||||
requires unit == ::units::one;
|
||||
requires unit == ::mp_units::one;
|
||||
requires invoke_result_of_<R.quantity_spec.character, std::plus<>, Value, rep>;
|
||||
}
|
||||
{
|
||||
return ::units::quantity(lhs + rhs.number());
|
||||
return ::mp_units::quantity(lhs + rhs.number());
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator-(const quantity& lhs, const Value& rhs)
|
||||
requires requires { // TODO: Simplify when Clang catches up.
|
||||
requires !Quantity<Value>;
|
||||
requires unit == ::units::one;
|
||||
requires unit == ::mp_units::one;
|
||||
requires invoke_result_of_<R.quantity_spec.character, std::minus<>, rep, Value>;
|
||||
}
|
||||
{
|
||||
return ::units::quantity(lhs.number() - rhs);
|
||||
return ::mp_units::quantity(lhs.number() - rhs);
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator-(const Value& lhs, const quantity& rhs)
|
||||
requires requires { // TODO: Simplify when Clang catches up.
|
||||
requires !Quantity<Value>;
|
||||
requires unit == ::units::one;
|
||||
requires unit == ::mp_units::one;
|
||||
requires invoke_result_of_<R.quantity_spec.character, std::minus<>, Value, rep>;
|
||||
}
|
||||
{
|
||||
return ::units::quantity(lhs - rhs.number());
|
||||
return ::mp_units::quantity(lhs - rhs.number());
|
||||
}
|
||||
|
||||
template<Representation Value>
|
||||
@ -406,7 +406,7 @@ public:
|
||||
requires(!Quantity<Value>) && invoke_result_of_<R.quantity_spec.character, std::divides<>, const Value&, rep>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator/(const Value& v, const quantity& q)
|
||||
{
|
||||
return (dimensionless[::units::one] / reference)(v / q.number());
|
||||
return (dimensionless[::mp_units::one] / reference)(v / q.number());
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@ -444,7 +444,7 @@ public:
|
||||
template<auto R, typename Rep>
|
||||
explicit(false) quantity(quantity<R, Rep>) -> quantity<R, Rep>;
|
||||
|
||||
template<RepresentationOf<units::quantity_character::scalar> Rep>
|
||||
template<RepresentationOf<mp_units::quantity_character::scalar> Rep>
|
||||
explicit(false) quantity(Rep) -> quantity<dimensionless[one], Rep>;
|
||||
|
||||
#if !UNITS_COMP_CLANG || UNITS_COMP_CLANG > 16
|
||||
@ -524,21 +524,21 @@ template<Quantity Q1, Quantity Q2>
|
||||
return quantity_cast<ref>(lhs).number() == quantity_cast<ref>(rhs).number();
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
||||
|
||||
namespace std {
|
||||
|
||||
template<units::Quantity Q1, units::Quantity Q2>
|
||||
template<mp_units::Quantity Q1, mp_units::Quantity Q2>
|
||||
requires requires {
|
||||
{
|
||||
units::common_reference(Q1::reference, Q2::reference)
|
||||
} -> units::Reference;
|
||||
mp_units::common_reference(Q1::reference, Q2::reference)
|
||||
} -> mp_units::Reference;
|
||||
typename common_type_t<typename Q1::rep, typename Q2::rep>;
|
||||
}
|
||||
struct common_type<Q1, Q2> {
|
||||
public:
|
||||
using type = units::quantity<units::common_reference(Q1::reference, Q2::reference),
|
||||
common_type_t<typename Q1::rep, typename Q2::rep>>;
|
||||
using type = mp_units::quantity<mp_units::common_reference(Q1::reference, Q2::reference),
|
||||
common_type_t<typename Q1::rep, typename Q2::rep>>;
|
||||
};
|
||||
|
||||
} // namespace std
|
@ -23,11 +23,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/customization_points.h>
|
||||
#include <units/quantity.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/quantity.h>
|
||||
#include <compare>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -234,4 +234,4 @@ explicit quantity_point(QP)
|
||||
-> quantity_point<quantity_point_like_traits<QP>::reference, quantity_point_like_traits<QP>::point_origin,
|
||||
typename quantity_point_like_traits<QP>::rep>;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,16 +22,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/algorithm.h>
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/type_name.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/dimension.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/algorithm.h>
|
||||
#include <mp_units/bits/expression_template.h>
|
||||
#include <mp_units/bits/external/type_name.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/quantity_concepts.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/unit.h>
|
||||
#include <tuple>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -381,14 +381,14 @@ struct quantity_spec<Self, Q, Args...> : std::remove_const_t<decltype(Q)> {
|
||||
|
||||
#ifdef __cpp_explicit_this_parameter
|
||||
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
inline constexpr struct name : ::units::quantity_spec<##__VA_ARGS__> { \
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
inline constexpr struct name : ::mp_units::quantity_spec<##__VA_ARGS__> { \
|
||||
} name
|
||||
|
||||
#else
|
||||
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
inline constexpr struct name : ::units::quantity_spec<name, ##__VA_ARGS__> { \
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
inline constexpr struct name : ::mp_units::quantity_spec<name, ##__VA_ARGS__> { \
|
||||
} name
|
||||
|
||||
#endif
|
||||
@ -503,4 +503,4 @@ template<std::intmax_t Num, std::intmax_t Den = 1, QuantitySpec Q>
|
||||
detail::type_list_of_quantity_spec_less>(q);
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/quantity_concepts.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/quantity_concepts.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief Quantity reference type
|
||||
@ -109,4 +109,4 @@ template<Reference R1, Reference R2>
|
||||
common_unit(r1.unit, r2.unit, rest.unit...)>{};
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/reference.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
#include <mp_units/reference.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief System-specific reference
|
||||
@ -69,4 +69,4 @@ struct system_reference {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,20 +22,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/algorithm.h>
|
||||
#include <units/bits/expression_template.h>
|
||||
#include <units/bits/external/fixed_string.h>
|
||||
#include <units/bits/external/type_name.h>
|
||||
#include <units/bits/external/type_traits.h>
|
||||
#include <units/bits/magnitude.h>
|
||||
#include <units/bits/ratio.h>
|
||||
#include <units/bits/symbol_text.h>
|
||||
#include <units/bits/text_tools.h>
|
||||
#include <units/dimension.h>
|
||||
#include <mp_units/bits/algorithm.h>
|
||||
#include <mp_units/bits/expression_template.h>
|
||||
#include <mp_units/bits/external/fixed_string.h>
|
||||
#include <mp_units/bits/external/type_name.h>
|
||||
#include <mp_units/bits/external/type_traits.h>
|
||||
#include <mp_units/bits/magnitude.h>
|
||||
#include <mp_units/bits/ratio.h>
|
||||
#include <mp_units/bits/symbol_text.h>
|
||||
#include <mp_units/bits/text_tools.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
#ifdef __cpp_explicit_this_parameter
|
||||
template<auto...>
|
||||
@ -483,7 +483,7 @@ template<Unit T, basic_symbol_text Symbol, Unit auto U>
|
||||
template<typename F, int Num, int... Den, typename... Us>
|
||||
[[nodiscard]] consteval auto get_canonical_unit_impl(const power<F, Num, Den...>&, const type_list<Us...>&)
|
||||
{
|
||||
auto mag = (units::mag<1> * ... * pow<Num, Den...>(get_canonical_unit_impl(Us{}, Us{}).mag));
|
||||
auto mag = (mp_units::mag<1> * ... * pow<Num, Den...>(get_canonical_unit_impl(Us{}, Us{}).mag));
|
||||
auto u = (one * ... * pow<Num, Den...>(get_canonical_unit_impl(Us{}, Us{}).reference_unit));
|
||||
return canonical_unit{mag, u};
|
||||
}
|
||||
@ -506,7 +506,7 @@ template<typename T, typename F, int Num, int... Den>
|
||||
template<typename... Us>
|
||||
[[nodiscard]] consteval auto get_canonical_unit_impl(const type_list<Us...>&)
|
||||
{
|
||||
auto mag = (units::mag<1> * ... * get_canonical_unit_impl(Us{}, Us{}).mag);
|
||||
auto mag = (mp_units::mag<1> * ... * get_canonical_unit_impl(Us{}, Us{}).mag);
|
||||
auto u = (one * ... * get_canonical_unit_impl(Us{}, Us{}).reference_unit);
|
||||
return canonical_unit{mag, u};
|
||||
}
|
||||
@ -564,7 +564,7 @@ using type_list_of_unit_less = expr_less<T1, T2, unit_less>;
|
||||
template<Magnitude M, Unit U>
|
||||
[[nodiscard]] consteval Unit auto operator*(M mag, const U u)
|
||||
{
|
||||
if constexpr (mag == units::mag<1>)
|
||||
if constexpr (mag == mp_units::mag<1>)
|
||||
return u;
|
||||
else
|
||||
return scaled_unit<mag, U>{};
|
||||
@ -923,4 +923,4 @@ template<typename CharT = char, Unit U>
|
||||
return buffer;
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,4 +22,4 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(angular DEPENDENCIES mp-units::isq HEADERS include/units/systems/angular/angular.h)
|
||||
add_units_module(angular DEPENDENCIES mp-units::isq HEADERS include/mp_units/systems/angular/angular.h)
|
||||
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/dimension.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::angular {
|
||||
namespace mp_units::angular {
|
||||
|
||||
// clang-format off
|
||||
inline constexpr struct dim_angle : base_dimension<"A"> {} dim_angle;
|
||||
@ -52,4 +52,4 @@ inline constexpr auto deg2 = square<degree>;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
} // namespace units::angular
|
||||
} // namespace mp_units::angular
|
@ -22,4 +22,4 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(cgs DEPENDENCIES mp-units::si HEADERS include/units/systems/cgs/cgs.h)
|
||||
add_units_module(cgs DEPENDENCIES mp-units::si HEADERS include/mp_units/systems/cgs/cgs.h)
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/si/units.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::cgs {
|
||||
namespace mp_units::cgs {
|
||||
|
||||
// clang-format off
|
||||
inline constexpr struct centimetre : decltype(si::centi<si::metre>) {} centimetre;
|
||||
@ -53,4 +53,4 @@ inline constexpr auto St = stokes;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
} // namespace units::cgs
|
||||
} // namespace mp_units::cgs
|
@ -22,4 +22,4 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(hep DEPENDENCIES mp-units::si HEADERS include/units/systems/hep/hep.h)
|
||||
add_units_module(hep DEPENDENCIES mp-units::si HEADERS include/mp_units/systems/hep/hep.h)
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/si/si.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/systems/si/si.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::hep {
|
||||
namespace mp_units::hep {
|
||||
|
||||
// energy
|
||||
using si::electronvolt;
|
||||
@ -88,4 +88,4 @@ inline constexpr auto c2 = square<si::si2019::speed_of_light_in_vacuum_unit>;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
} // namespace units::hep
|
||||
} // namespace mp_units::hep
|
@ -22,6 +22,4 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(
|
||||
iau DEPENDENCIES mp-units::si HEADERS include/units/systems/iau/iau.h
|
||||
)
|
||||
add_units_module(iau DEPENDENCIES mp-units::si HEADERS include/mp_units/systems/iau/iau.h)
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/si/si.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/systems/si/si.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::iau {
|
||||
namespace mp_units::iau {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Astronomical_system_of_units
|
||||
|
||||
@ -79,4 +79,4 @@ inline constexpr auto c_0 = speed_of_light_unit;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
} // namespace units::iau
|
||||
} // namespace mp_units::iau
|
@ -23,7 +23,9 @@
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(
|
||||
iec80000 DEPENDENCIES mp-units::isq mp-units::si
|
||||
HEADERS include/units/systems/iec80000/binary_prefixes.h include/units/systems/iec80000/quantities.h
|
||||
include/units/systems/iec80000/iec80000.h include/units/systems/iec80000/unit_symbols.h include/units/systems/iec80000/units.h
|
||||
iec80000
|
||||
DEPENDENCIES mp-units::isq mp-units::si
|
||||
HEADERS include/mp_units/systems/iec80000/binary_prefixes.h include/mp_units/systems/iec80000/quantities.h
|
||||
include/mp_units/systems/iec80000/iec80000.h include/mp_units/systems/iec80000/unit_symbols.h
|
||||
include/mp_units/systems/iec80000/units.h
|
||||
)
|
||||
|
@ -22,9 +22,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::iec80000 {
|
||||
namespace mp_units::iec80000 {
|
||||
|
||||
// clang-format off
|
||||
template<PrefixableUnit auto U> struct kibi_ : prefixed_unit<"Ki", mag_power<2, 10>, U> {};
|
||||
@ -46,4 +46,4 @@ template<PrefixableUnit auto U> inline constexpr zebi_<U> zebi;
|
||||
template<PrefixableUnit auto U> inline constexpr yobi_<U> yobi;
|
||||
// clang-format on
|
||||
|
||||
} // namespace units::iec80000
|
||||
} // namespace mp_units::iec80000
|
@ -23,8 +23,8 @@
|
||||
#pragma once
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <units/systems/iec80000/binary_prefixes.h>
|
||||
#include <units/systems/iec80000/quantities.h>
|
||||
#include <units/systems/iec80000/unit_symbols.h>
|
||||
#include <units/systems/iec80000/units.h>
|
||||
#include <mp_units/systems/iec80000/binary_prefixes.h>
|
||||
#include <mp_units/systems/iec80000/quantities.h>
|
||||
#include <mp_units/systems/iec80000/unit_symbols.h>
|
||||
#include <mp_units/systems/iec80000/units.h>
|
||||
// IWYU pragma: end_exports
|
@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/dimension.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/systems/isq/mechanics.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
#include <mp_units/systems/isq/mechanics.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
|
||||
namespace units::iec80000 {
|
||||
namespace mp_units::iec80000 {
|
||||
|
||||
// clang-format off
|
||||
inline constexpr struct dim_traffic_intensity : base_dimension<"A"> {} dim_traffic_intensity;
|
||||
@ -69,4 +69,4 @@ QUANTITY_SPEC(decision_content, dimensionless);
|
||||
// TODO how to model information_content and the following quantities???
|
||||
// QUANTITY_SPEC(information_content, ...);
|
||||
|
||||
} // namespace units::iec80000
|
||||
} // namespace mp_units::iec80000
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/iec80000/binary_prefixes.h>
|
||||
#include <units/systems/iec80000/units.h>
|
||||
#include <units/systems/si/prefixes.h>
|
||||
#include <mp_units/systems/iec80000/binary_prefixes.h>
|
||||
#include <mp_units/systems/iec80000/units.h>
|
||||
#include <mp_units/systems/si/prefixes.h>
|
||||
|
||||
namespace units::iec80000::unit_symbols {
|
||||
namespace mp_units::iec80000::unit_symbols {
|
||||
|
||||
// bit
|
||||
inline constexpr auto kbit = si::kilo<bit>;
|
||||
@ -98,4 +98,4 @@ inline constexpr auto YBd = si::yotta<baud>;
|
||||
// TODO do we need prefixed versions of Erlang?
|
||||
inline constexpr auto E = erlang;
|
||||
|
||||
} // namespace units::iec80000::unit_symbols
|
||||
} // namespace mp_units::iec80000::unit_symbols
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/iec80000/quantities.h>
|
||||
#include <units/systems/si/units.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/systems/iec80000/quantities.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::iec80000 {
|
||||
namespace mp_units::iec80000 {
|
||||
|
||||
// clang-format off
|
||||
inline constexpr struct erlang : named_unit<"E", traffic_intensity> {} erlang;
|
||||
@ -36,4 +36,4 @@ inline constexpr struct byte : named_unit<"B", mag<8> * bit> {} byte;
|
||||
inline constexpr struct baud : named_unit<"Bd", 1 / si::second> {} baud;
|
||||
// clang-format on
|
||||
|
||||
} // namespace units::iec80000
|
||||
} // namespace mp_units::iec80000
|
@ -22,4 +22,6 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(imperial DEPENDENCIES mp-units::si mp-units::international HEADERS include/units/systems/imperial/imperial.h)
|
||||
add_units_module(
|
||||
imperial DEPENDENCIES mp-units::si mp-units::international HEADERS include/mp_units/systems/imperial/imperial.h
|
||||
)
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/international/international.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/systems/international/international.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::imperial {
|
||||
namespace mp_units::imperial {
|
||||
|
||||
using namespace international;
|
||||
|
||||
@ -95,4 +95,4 @@ inline constexpr auto t = ton;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
} // namespace units::imperial
|
||||
} // namespace mp_units::imperial
|
@ -22,4 +22,4 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(international DEPENDENCIES mp-units::si HEADERS include/units/systems/international/international.h)
|
||||
add_units_module(international DEPENDENCIES mp-units::si HEADERS include/mp_units/systems/international/international.h)
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/si/si.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/systems/si/si.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::international {
|
||||
namespace mp_units::international {
|
||||
|
||||
// clang-format off
|
||||
// mass
|
||||
@ -97,4 +97,4 @@ inline constexpr auto hp = mechanical_horsepower;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
} // namespace units::international
|
||||
} // namespace mp_units::international
|
@ -23,7 +23,9 @@
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(
|
||||
isq DEPENDENCIES mp-units::core
|
||||
HEADERS include/units/systems/isq/base_quantities.h include/units/systems/isq/electromagnetism.h include/units/systems/isq/isq.h
|
||||
include/units/systems/isq/mechanics.h include/units/systems/isq/space_and_time.h include/units/systems/isq/thermodynamics.h
|
||||
isq
|
||||
DEPENDENCIES mp-units::core
|
||||
HEADERS include/mp_units/systems/isq/base_quantities.h include/mp_units/systems/isq/electromagnetism.h
|
||||
include/mp_units/systems/isq/isq.h include/mp_units/systems/isq/mechanics.h
|
||||
include/mp_units/systems/isq/space_and_time.h include/mp_units/systems/isq/thermodynamics.h
|
||||
)
|
||||
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/dimension.h>
|
||||
#include <units/quantity.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <mp_units/dimension.h>
|
||||
#include <mp_units/quantity.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
|
||||
namespace units::isq {
|
||||
namespace mp_units::isq {
|
||||
|
||||
// clang-format off
|
||||
// dimensions of base quantities
|
||||
@ -48,4 +48,4 @@ QUANTITY_SPEC(thermodynamic_temperature, dim_thermodynamic_temperature);
|
||||
QUANTITY_SPEC(amount_of_substance, dim_amount_of_substance);
|
||||
QUANTITY_SPEC(luminous_intensity, dim_luminous_intensity);
|
||||
|
||||
} // namespace units::isq
|
||||
} // namespace mp_units::isq
|
@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/isq/base_quantities.h>
|
||||
#include <units/systems/isq/mechanics.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <mp_units/systems/isq/base_quantities.h>
|
||||
#include <mp_units/systems/isq/mechanics.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
|
||||
namespace units::isq {
|
||||
namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(electric_charge, electric_current* time);
|
||||
QUANTITY_SPEC(electric_charge_density, electric_charge / volume);
|
||||
@ -135,4 +135,4 @@ QUANTITY_SPEC(reactive_power, complex_power);
|
||||
QUANTITY_SPEC(non_active_power, pow<1, 2>(pow<2>(apparent_power)));
|
||||
QUANTITY_SPEC(active_energy, instantaneous_power* time);
|
||||
|
||||
} // namespace units::isq
|
||||
} // namespace mp_units::isq
|
@ -23,9 +23,9 @@
|
||||
#pragma once
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <units/systems/isq/base_quantities.h>
|
||||
#include <units/systems/isq/electromagnetism.h>
|
||||
#include <units/systems/isq/mechanics.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/isq/thermodynamics.h>
|
||||
#include <mp_units/systems/isq/base_quantities.h>
|
||||
#include <mp_units/systems/isq/electromagnetism.h>
|
||||
#include <mp_units/systems/isq/mechanics.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/isq/thermodynamics.h>
|
||||
// IWYU pragma: end_exports
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/isq/base_quantities.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <mp_units/systems/isq/base_quantities.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
|
||||
namespace units::isq {
|
||||
namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(mass_density, mass / volume);
|
||||
inline constexpr auto density = mass_density;
|
||||
@ -106,4 +106,4 @@ QUANTITY_SPEC(mass_change_rate, mass / time);
|
||||
QUANTITY_SPEC(volume_flow_rate, velocity* area, quantity_character::scalar);
|
||||
QUANTITY_SPEC(action, mechanical_energy* time);
|
||||
|
||||
} // namespace units::isq
|
||||
} // namespace mp_units::isq
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/isq/base_quantities.h>
|
||||
#include <units/quantity_spec.h>
|
||||
#include <mp_units/systems/isq/base_quantities.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
|
||||
namespace units::isq {
|
||||
namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(width, length);
|
||||
inline constexpr auto breadth = width;
|
||||
@ -82,4 +82,4 @@ QUANTITY_SPEC(phase_coefficient, phase_angle / path_length);
|
||||
QUANTITY_SPEC(propagation_coefficient, 1 / length); // γ = α + iβ where α denotes attenuation
|
||||
// and β the phase coefficient of a plane wave
|
||||
|
||||
} // namespace units::isq
|
||||
} // namespace mp_units::isq
|
@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/systems/isq/base_quantities.h>
|
||||
#include <units/systems/isq/mechanics.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
#include <mp_units/systems/isq/base_quantities.h>
|
||||
#include <mp_units/systems/isq/mechanics.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
|
||||
namespace units::isq {
|
||||
namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(Celsius_temperature, thermodynamic_temperature); // TODO should we account for T0 here?
|
||||
QUANTITY_SPEC(linear_expansion_coefficient, 1 / length * (length / thermodynamic_temperature));
|
||||
@ -95,4 +95,4 @@ QUANTITY_SPEC(relative_mass_ratio_of_vapour,
|
||||
mass_ratio_of_water_vapour_to_dry_gas / mass_ratio_of_water_vapour_to_dry_gas);
|
||||
QUANTITY_SPEC(dew_point_temperature, thermodynamic_temperature);
|
||||
|
||||
} // namespace units::isq
|
||||
} // namespace mp_units::isq
|
@ -22,4 +22,6 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(isq_angle DEPENDENCIES mp-units::angular mp-units::isq HEADERS include/units/systems/isq_angle/isq_angle.h)
|
||||
add_units_module(
|
||||
isq_angle DEPENDENCIES mp-units::angular mp-units::isq HEADERS include/mp_units/systems/isq_angle/isq_angle.h
|
||||
)
|
||||
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/quantity_spec.h>
|
||||
#include <units/systems/angular/angular.h>
|
||||
#include <units/systems/isq/isq.h>
|
||||
#include <mp_units/quantity_spec.h>
|
||||
#include <mp_units/systems/angular/angular.h>
|
||||
#include <mp_units/systems/isq/isq.h>
|
||||
|
||||
namespace units::isq_angle {
|
||||
namespace mp_units::isq_angle {
|
||||
|
||||
using namespace isq;
|
||||
|
||||
@ -55,4 +55,4 @@ QUANTITY_SPEC(loss_angle, angular_measure);
|
||||
// constants
|
||||
inline constexpr auto cotes_angle = cotes_angle_constant[angular::radian];
|
||||
|
||||
} // namespace units::isq_angle
|
||||
} // namespace mp_units::isq_angle
|
@ -22,4 +22,4 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(natural DEPENDENCIES mp-units::isq HEADERS include/units/systems/natural/natural.h)
|
||||
add_units_module(natural DEPENDENCIES mp-units::isq HEADERS include/mp_units/systems/natural/natural.h)
|
||||
|
@ -22,13 +22,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/system_reference.h>
|
||||
#include <units/systems/isq/mechanics.h>
|
||||
#include <units/systems/isq/space_and_time.h>
|
||||
#include <units/systems/si/prefixes.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/system_reference.h>
|
||||
#include <mp_units/systems/isq/mechanics.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/prefixes.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::natural {
|
||||
namespace mp_units::natural {
|
||||
|
||||
// clang-format off
|
||||
// units
|
||||
@ -57,4 +57,4 @@ inline constexpr auto GeV2 = square<gigaelectronvolt>;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
} // namespace units::natural
|
||||
} // namespace mp_units::natural
|
@ -23,7 +23,9 @@
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(
|
||||
si DEPENDENCIES mp-units::isq
|
||||
HEADERS include/units/systems/si/constants.h include/units/systems/si/prefixes.h include/units/systems/si/si.h
|
||||
include/units/systems/si/unit_symbols.h include/units/systems/si/units.h
|
||||
si
|
||||
DEPENDENCIES mp-units::isq
|
||||
HEADERS include/mp_units/systems/si/constants.h include/mp_units/systems/si/prefixes.h
|
||||
include/mp_units/systems/si/si.h include/mp_units/systems/si/unit_symbols.h
|
||||
include/mp_units/systems/si/units.h
|
||||
)
|
||||
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/isq/isq.h>
|
||||
#include <units/quantity.h>
|
||||
#include <units/systems/si/units.h>
|
||||
#include <mp_units/quantity.h>
|
||||
#include <mp_units/systems/isq/isq.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
|
||||
namespace units::si {
|
||||
namespace mp_units::si {
|
||||
|
||||
namespace si2019 {
|
||||
|
||||
@ -69,4 +69,4 @@ inline constexpr struct magnetic_constant_unit :
|
||||
inline constexpr auto standard_gravity = isq::acceleration[standard_gravity_unit];
|
||||
inline constexpr auto magnetic_constant = isq::magnetic_constant[magnetic_constant_unit];
|
||||
|
||||
} // namespace units::si
|
||||
} // namespace mp_units::si
|
@ -22,9 +22,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::si {
|
||||
namespace mp_units::si {
|
||||
|
||||
// clang-format off
|
||||
template<PrefixableUnit auto U> struct yocto_ : prefixed_unit<"y", mag_power<10, -24>, U> {};
|
||||
@ -70,4 +70,4 @@ template<PrefixableUnit auto U> inline constexpr zetta_<U> zetta;
|
||||
template<PrefixableUnit auto U> inline constexpr yotta_<U> yotta;
|
||||
// clang-format on
|
||||
|
||||
} // namespace units::si
|
||||
} // namespace mp_units::si
|
@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/si/constants.h>
|
||||
#include <units/systems/si/prefixes.h>
|
||||
#include <units/systems/si/unit_symbols.h>
|
||||
#include <units/systems/si/units.h>
|
||||
#include <mp_units/systems/si/constants.h>
|
||||
#include <mp_units/systems/si/prefixes.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
#include <mp_units/systems/si/units.h>
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/si/prefixes.h>
|
||||
#include <units/systems/si/units.h>
|
||||
#include <mp_units/systems/si/prefixes.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
|
||||
namespace units::si::unit_symbols {
|
||||
namespace mp_units::si::unit_symbols {
|
||||
|
||||
inline constexpr auto ym = yocto<metre>;
|
||||
inline constexpr auto zm = zepto<metre>;
|
||||
@ -645,4 +645,4 @@ inline constexpr auto m4 = pow<4>(metre);
|
||||
inline constexpr auto s2 = square<second>;
|
||||
inline constexpr auto s3 = cubic<second>;
|
||||
|
||||
} // namespace units::si::unit_symbols
|
||||
} // namespace mp_units::si::unit_symbols
|
@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/isq/base_quantities.h>
|
||||
#include <units/systems/si/prefixes.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/systems/isq/base_quantities.h>
|
||||
#include <mp_units/systems/si/prefixes.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::si {
|
||||
namespace mp_units::si {
|
||||
|
||||
// clang-format off
|
||||
// base units
|
||||
@ -89,9 +89,9 @@ inline constexpr struct electronvolt : named_unit<"eV", mag<ratio{1'602'176'634,
|
||||
|
||||
// clang-format on
|
||||
|
||||
} // namespace units::si
|
||||
} // namespace mp_units::si
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
template<>
|
||||
inline constexpr bool unit_can_be_prefixed<si::degree_Celsius> = false;
|
||||
@ -102,4 +102,4 @@ inline constexpr bool unit_can_be_prefixed<si::hour> = false;
|
||||
template<>
|
||||
inline constexpr bool unit_can_be_prefixed<si::day> = false;
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,6 +22,4 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(
|
||||
typographic DEPENDENCIES mp-units::usc HEADERS include/units/systems/typographic/typographic.h
|
||||
)
|
||||
add_units_module(typographic DEPENDENCIES mp-units::usc HEADERS include/mp_units/systems/typographic/typographic.h)
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/usc/usc.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/systems/usc/usc.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::typographic {
|
||||
namespace mp_units::typographic {
|
||||
|
||||
// clang-format off
|
||||
// https://en.wikipedia.org/wiki/Point_(typography)
|
||||
@ -36,4 +36,4 @@ inline constexpr struct point_dtp : named_unit<"point(dtp)", mag<ratio{1, 72}> *
|
||||
inline constexpr struct pica_dtp : named_unit<"pica(dtp)", mag<12> * point_dtp> {} pica_dtp;
|
||||
// clang-format on
|
||||
|
||||
} // namespace units::typographic
|
||||
} // namespace mp_units::typographic
|
@ -22,4 +22,4 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(usc DEPENDENCIES mp-units::si mp-units::international HEADERS include/units/systems/usc/usc.h)
|
||||
add_units_module(usc DEPENDENCIES mp-units::si mp-units::international HEADERS include/mp_units/systems/usc/usc.h)
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/systems/international/international.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/systems/international/international.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
namespace units::usc {
|
||||
namespace mp_units::usc {
|
||||
|
||||
using namespace international;
|
||||
|
||||
@ -160,4 +160,4 @@ inline constexpr auto deg_F = degree_Fahrenheit;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
} // namespace units::usc
|
||||
} // namespace mp_units::usc
|
@ -24,5 +24,5 @@ cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(
|
||||
utility DEPENDENCIES mp-units::core mp-units::isq mp-units::si mp-units::angular
|
||||
HEADERS include/units/chrono.h include/units/math.h include/units/random.h
|
||||
HEADERS include/mp_units/chrono.h include/mp_units/math.h include/mp_units/random.h
|
||||
)
|
||||
|
@ -22,13 +22,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/customization_points.h>
|
||||
#include <units/isq/space_and_time.h>
|
||||
#include <units/si/prefixes.h>
|
||||
#include <units/si/units.h>
|
||||
#include <mp_units/customization_points.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/prefixes.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
#include <chrono>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -100,4 +100,4 @@ template<quantity_point_of<isq::time> QP>
|
||||
return ret_type(to_std_duration(qp.absolute()));
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/angular/angular.h>
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <units/isq/space_and_time.h>
|
||||
#include <units/quantity.h>
|
||||
#include <units/si/units.h>
|
||||
#include <units/unit.h>
|
||||
#include <mp_units/bits/external/hacks.h>
|
||||
#include <mp_units/quantity.h>
|
||||
#include <mp_units/systems/angular/angular.h>
|
||||
#include <mp_units/systems/isq/space_and_time.h>
|
||||
#include <mp_units/systems/si/units.h>
|
||||
#include <mp_units/unit.h>
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <cmath>
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace units {
|
||||
namespace mp_units {
|
||||
|
||||
/**
|
||||
* @brief Computes the value of a quantity raised to the `Num/Den` power
|
||||
@ -157,7 +157,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
requires((!treat_as_floating_point<Rep>) || requires { floor(q.number()); } ||
|
||||
requires { std::floor(q.number()); }) &&
|
||||
(To == R.unit || requires {
|
||||
::units::quantity_cast<To>(q);
|
||||
::mp_units::quantity_cast<To>(q);
|
||||
quantity<reference<R.quantity_spec, To>{}, Rep>::one();
|
||||
})
|
||||
{
|
||||
@ -194,7 +194,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
[[nodiscard]] constexpr quantity<reference<R.quantity_spec, To>{}, Rep> ceil(const quantity<R, Rep>& q) noexcept
|
||||
requires((!treat_as_floating_point<Rep>) || requires { ceil(q.number()); } || requires { std::ceil(q.number()); }) &&
|
||||
(To == R.unit || requires {
|
||||
::units::quantity_cast<To>(q);
|
||||
::mp_units::quantity_cast<To>(q);
|
||||
quantity<reference<R.quantity_spec, To>{}, Rep>::one();
|
||||
})
|
||||
{
|
||||
@ -234,7 +234,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
requires((!treat_as_floating_point<Rep>) || requires { round(q.number()); } ||
|
||||
requires { std::round(q.number()); }) &&
|
||||
(To == R.unit || requires {
|
||||
::units::floor<To>(q);
|
||||
::mp_units::floor<To>(q);
|
||||
quantity<reference<R.quantity_spec, To>{}, Rep>::one();
|
||||
})
|
||||
{
|
||||
@ -246,7 +246,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
return quantity_cast<To>(q);
|
||||
}
|
||||
} else {
|
||||
const auto res_low = units::floor<To>(q);
|
||||
const auto res_low = mp_units::floor<To>(q);
|
||||
const auto res_high = res_low + res_low.one();
|
||||
const auto diff0 = q - res_low;
|
||||
const auto diff1 = res_high - q;
|
||||
@ -414,4 +414,4 @@ template<quantity_of<dimension_one> Q>
|
||||
|
||||
} // namespace angular
|
||||
|
||||
} // namespace units
|
||||
} // namespace mp_units
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user