Physical units put in the physical namespace (I am sorry)

This commit is contained in:
Mateusz Pusz committed 2020-05-08 22:39:24 +02:00
1 parent 771a9a1551
commit 7e935a4108
117 files changed
+352 -349

No files matched your search

@@ -9,7 +9,7 @@ namespace experimental{
namespace acceleration {
template<typename Rep = double>
using m_per_s2 = units::si::acceleration<units::si::metre_per_second_sq, Rep>;
using m_per_s2 = units::physical::si::acceleration<units::physical::si::metre_per_second_sq, Rep>;
template<typename Rep = double>
constexpr m_per_s2<Rep> g{static_cast<Rep>(9.80665)};
+2 -2
View File
@@ -6,9 +6,9 @@
namespace area {
template<typename Rep = double>
using m2 = units::si::area<units::si::square_metre, Rep>;
using m2 = units::physical::si::area<units::physical::si::square_metre, Rep>;
template<typename Rep = double>
using fm2 = units::si::area<units::si::square_femtometre, Rep>;
using fm2 = units::physical::si::area<units::physical::si::square_femtometre, Rep>;
} // namespace area
@@ -52,7 +52,7 @@ struct Box {
#include <iostream>
using namespace units::si::literals;
using namespace units::physical::si::literals;
int main()
{
@@ -28,7 +28,7 @@
#include <iostream>
using namespace units::experimental;
using namespace units::si::literals;
using namespace units::physical::si::literals;
int main()
{
@@ -24,8 +24,8 @@
#include "./area.h"
#include "./units_str.h"
using namespace units::si::literals;
using namespace units::international;
using namespace units::physical::si::literals;
using namespace units::physical::international;
using namespace units::experimental;
void simple_quantities()
@@ -40,7 +40,7 @@ inline constexpr std::common_type_t<typename Target::rep, typename Source::rep>
} // namespace
using namespace units::si::literals;
using namespace units::physical::si::literals;
using namespace units::experimental;
int main()
+1 -1
View File
@@ -10,7 +10,7 @@ namespace experimental{
namespace density {
template<typename Rep = double>
using kg_per_m3 = units::si::density<units::si::kilogram_per_metre_cub, Rep>;
using kg_per_m3 = units::physical::si::density<units::physical::si::kilogram_per_metre_cub, Rep>;
}
+1 -1
View File
@@ -9,7 +9,7 @@ namespace experimental{
namespace force {
template<typename Rep = double>
using N = units::si::force<units::si::newton, Rep>;
using N = units::physical::si::force<units::physical::si::newton, Rep>;
}
+22 -22
View File
@@ -15,70 +15,70 @@ namespace experimental{
namespace length {
template<typename Rep = double>
using m = units::si::length<units::si::metre, Rep>;
using m = units::physical::si::length<units::physical::si::metre, Rep>;
template<typename Rep = double>
using mm = units::si::length<units::si::millimetre, Rep>;
using mm = units::physical::si::length<units::physical::si::millimetre, Rep>;
template<typename Rep = double>
using fm = units::si::length<units::si::femtometre, Rep>;
using fm = units::physical::si::length<units::physical::si::femtometre, Rep>;
template<typename Rep = double>
using km = units::si::length<units::si::kilometre, Rep>;
using km = units::physical::si::length<units::physical::si::kilometre, Rep>;
template<typename Rep = double>
using AU = units::si::length<units::si::astronomical_unit, Rep>;
using AU = units::physical::si::length<units::physical::si::astronomical_unit, Rep>;
template<typename Rep = double>
using in = units::si::length<units::international::inch, Rep>;
using in = units::physical::si::length<units::physical::international::inch, Rep>;
template<typename Rep = double>
using angstrom = units::si::length<units::iau::angstrom, Rep>;
using angstrom = units::physical::si::length<units::physical::iau::angstrom, Rep>;
template<typename Rep = double>
using ch = units::si::length<units::imperial::chain, Rep>;
using ch = units::physical::si::length<units::physical::imperial::chain, Rep>;
template<typename Rep = double>
using fathom = units::si::length<units::international::fathom, Rep>;
using fathom = units::physical::si::length<units::physical::international::fathom, Rep>;
template<typename Rep = double>
using fathom_us = units::si::length<units::us::fathom, Rep>;
using fathom_us = units::physical::si::length<units::physical::us::fathom, Rep>;
template<typename Rep = double>
using ft = units::si::length<units::international::foot, Rep>;
using ft = units::physical::si::length<units::physical::international::foot, Rep>;
template<typename Rep = double>
using ft_us = units::si::length<units::us::foot, Rep>;
using ft_us = units::physical::si::length<units::physical::us::foot, Rep>;
template<typename Rep = double>
using ly = units::si::length<units::iau::light_year, Rep>;
using ly = units::physical::si::length<units::physical::iau::light_year, Rep>;
template<typename Rep = double>
using mi = units::si::length<units::international::mile, Rep>;
using mi = units::physical::si::length<units::physical::international::mile, Rep>;
template<typename Rep = double>
using mi_naut = units::si::length<units::international::nautical_mile, Rep>;
using mi_naut = units::physical::si::length<units::physical::international::nautical_mile, Rep>;
template<typename Rep = double>
using pc = units::si::length<units::iau::parsec, Rep>;
using pc = units::physical::si::length<units::physical::iau::parsec, Rep>;
template<typename Rep = double>
using pica_comp = units::si::length<units::typographic::pica_comp, Rep>;
using pica_comp = units::physical::si::length<units::physical::typographic::pica_comp, Rep>;
template<typename Rep = double>
using pica_prn = units::si::length<units::typographic::pica_prn, Rep>;
using pica_prn = units::physical::si::length<units::physical::typographic::pica_prn, Rep>;
template<typename Rep = double>
using point_comp = units::si::length<units::typographic::point_comp, Rep>;
using point_comp = units::physical::si::length<units::physical::typographic::point_comp, Rep>;
template<typename Rep = double>
using point_prn = units::si::length<units::typographic::point_prn, Rep>;
using point_prn = units::physical::si::length<units::physical::typographic::point_prn, Rep>;
template<typename Rep = double>
using rd = units::si::length<units::imperial::rod, Rep>;
using rd = units::physical::si::length<units::physical::imperial::rod, Rep>;
template<typename Rep = double>
using yd = units::si::length<units::international::yard, Rep>;
using yd = units::physical::si::length<units::physical::international::yard, Rep>;
} // namespace length
+1 -1
View File
@@ -10,7 +10,7 @@ namespace experimental{
namespace mass {
template<typename Rep = double>
using kg = units::si::mass<units::si::kilogram, Rep>;
using kg = units::physical::si::mass<units::physical::si::kilogram, Rep>;
}
+4 -4
View File
@@ -7,15 +7,15 @@
namespace q_time {
template<typename Rep = double>
using s = units::si::time<units::si::second, Rep>;
using s = units::physical::si::time<units::physical::si::second, Rep>;
template<typename Rep = double>
using ms = units::si::time<units::si::millisecond, Rep>;
using ms = units::physical::si::time<units::physical::si::millisecond, Rep>;
template<typename Rep = double>
using min = units::si::time<units::si::minute, Rep>;
using min = units::physical::si::time<units::physical::si::minute, Rep>;
template<typename Rep = double>
using h = units::si::time<units::si::hour, Rep>;
using h = units::physical::si::time<units::physical::si::hour, Rep>;
} // namespace time
+1 -1
View File
@@ -7,7 +7,7 @@
*/
using namespace units::experimental;
using namespace units::si::literals;
using namespace units::physical::si::literals;
int main()
{
+5 -5
View File
@@ -10,19 +10,19 @@ namespace experimental{
namespace voltage {
template<typename Rep = double>
using V = units::si::voltage<units::si::volt, Rep>;
using V = units::physical::si::voltage<units::physical::si::volt, Rep>;
template<typename Rep = double>
using mV = units::si::voltage<units::si::millivolt, Rep>;
using mV = units::physical::si::voltage<units::physical::si::millivolt, Rep>;
template<typename Rep = double>
using uV = units::si::voltage<units::si::microvolt, Rep>;
using uV = units::physical::si::voltage<units::physical::si::microvolt, Rep>;
template<typename Rep = double>
using nV = units::si::voltage<units::si::nanovolt, Rep>;
using nV = units::physical::si::voltage<units::physical::si::nanovolt, Rep>;
template<typename Rep = double>
using pV = units::si::voltage<units::si::picovolt, Rep>;
using pV = units::physical::si::voltage<units::physical::si::picovolt, Rep>;
} // namespace voltage
+1 -1
View File
@@ -10,7 +10,7 @@ namespace experimental{
namespace volume {
template<typename Rep = double>
using m3 = units::si::volume<units::si::cubic_metre, Rep>;
using m3 = units::physical::si::volume<units::physical::si::cubic_metre, Rep>;
}
+19 -19
View File
@@ -27,47 +27,47 @@
namespace {
constexpr units::si::velocity<units::si::metre_per_second, int>
fixed_int_si_avg_speed(units::si::length<units::si::metre, int> d,
units::si::time<units::si::second, int> t)
using namespace units::physical;
constexpr si::velocity<si::metre_per_second, int>
fixed_int_si_avg_speed(si::length<si::metre, int> d,
si::time<si::second, int> t)
{
return d / t;
}
constexpr units::si::velocity<units::si::metre_per_second>
fixed_double_si_avg_speed(units::si::length<units::si::metre> d,
units::si::time<units::si::second> t)
constexpr si::velocity<si::metre_per_second>
fixed_double_si_avg_speed(si::length<si::metre> d,
si::time<si::second> t)
{
return d / t;
}
template<typename U1, typename R1, typename U2, typename R2>
constexpr units::Velocity AUTO si_avg_speed(units::si::length<U1, R1> d,
units::si::time<U2, R2> t)
constexpr Velocity AUTO si_avg_speed(si::length<U1, R1> d,
si::time<U2, R2> t)
{
return d / t;
}
constexpr units::Velocity AUTO avg_speed(units::Length AUTO d, units::Time AUTO t)
constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t)
{
return d / t;
}
template<units::Length D, units::Time T, units::Velocity V>
template<Length D, Time T, Velocity V>
void print_result(D distance, T duration, V velocity)
{
const auto result_in_kmph = units::quantity_cast<units::si::velocity<units::si::kilometre_per_hour>>(velocity);
const auto result_in_kmph = units::quantity_cast<si::velocity<si::kilometre_per_hour>>(velocity);
std::cout << "Average speed of a car that makes " << distance << " in "
<< duration << " is " << result_in_kmph << ".\n";
}
void example()
{
using namespace units;
// SI (int)
{
using namespace units::si::literals;
using namespace units::physical::si::literals;
constexpr Length AUTO distance = 220q_km; // constructed from a UDL
constexpr si::time<si::hour, int> duration(2); // constructed from a value
@@ -81,7 +81,7 @@ void example()
// SI (double)
{
using namespace units::si::literals;
using namespace units::physical::si::literals;
constexpr Length AUTO distance = 220.q_km; // constructed from a UDL
constexpr si::time<si::hour> duration(2); // constructed from a value
@@ -97,7 +97,7 @@ void example()
// Customary Units (int)
{
using namespace units::international::literals;
using namespace units::physical::international::literals;
constexpr Length AUTO distance = 140q_mi; // constructed from a UDL
constexpr si::time<si::hour, int> duration(2); // constructed from a value
@@ -113,7 +113,7 @@ void example()
// Customary Units (double)
{
using namespace units::international::literals;
using namespace units::physical::international::literals;
constexpr Length AUTO distance = 140q_mi; // constructed from a UDL
constexpr si::time<si::hour> duration(2); // constructed from a value
@@ -131,7 +131,7 @@ void example()
// CGS (int)
{
using namespace units::cgs::literals;
using namespace units::physical::cgs::literals;
constexpr Length AUTO distance = 22'000'000q_cm; // constructed from a UDL
constexpr cgs::time<si::hour, int> duration(2); // constructed from a value
@@ -150,7 +150,7 @@ void example()
// CGS (double)
{
using namespace units::cgs::literals;
using namespace units::physical::cgs::literals;
constexpr Length AUTO distance = 22'000'000q_cm; // constructed from a UDL
constexpr cgs::time<si::hour> duration(2); // constructed from a value
+2 -2
View File
@@ -11,8 +11,8 @@
namespace {
using namespace units;
using namespace units::si::literals;
using namespace units::physical;
using namespace units::physical::si::literals;
using m = si::metre;
using kg = si::kilogram;
+2 -2
View File
@@ -29,8 +29,8 @@
int main()
{
using namespace units;
using namespace units::si;
using namespace units::physical;
using namespace units::physical::si;
std::cout << "mp-units capacitor time curve example...\n";
std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
+7 -6
View File
@@ -33,11 +33,11 @@ using namespace units;
void simple_quantities()
{
using namespace units::si;
using namespace units::international;
using namespace units::physical::si;
using namespace units::physical::international;
using distance = length<metre>;
using duration = si::time<second>;
using duration = physical::si::time<second>;
constexpr distance km = 1.0q_km;
constexpr distance miles = 1.0q_mi;
@@ -57,8 +57,9 @@ void simple_quantities()
void quantities_with_typed_units()
{
using namespace units::si;
using namespace units::international;
using namespace units::physical;
using namespace units::physical::si;
using namespace units::physical::international;
constexpr length<kilometre> km = 1.0q_km;
constexpr length<mile> miles = 1.0q_mi;
@@ -104,7 +105,7 @@ void quantities_with_typed_units()
void calcs_comparison()
{
using namespace units::si;
using namespace units::physical::si;
std::cout << "\nA distinct unit for each type is efficient and accurate\n"
"when adding two values of the same very big\n"
+1 -1
View File
@@ -41,7 +41,7 @@ inline constexpr std::common_type_t<typename Target::rep, typename Source::rep>
int main()
{
using namespace units::si;
using namespace units::physical::si;
std::cout << "conversion factor in mp-units...\n\n";
+2 -2
View File
@@ -25,7 +25,7 @@
#include <units/format.h>
#include <iostream>
using namespace units;
using namespace units::physical;
constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t)
{
@@ -34,7 +34,7 @@ constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t)
int main()
{
using namespace si::literals;
using namespace units::physical::si::literals;
Velocity AUTO v1 = avg_speed(220q_km, 2q_h);
Velocity AUTO v2 = avg_speed(si::length<international::mile>(140), si::time<si::hour>(2));
Velocity AUTO v3 = quantity_cast<si::metre_per_second>(v2);
@@ -20,7 +20,7 @@ struct state_variable {
Q predicted_next_state;
};
using namespace units::si;
using namespace units::physical::si;
constexpr auto radar_transmit_interval = 5.0q_s;
constexpr double kalman_range_gain = 0.2;
+4 -4
View File
@@ -55,8 +55,8 @@ std::ostream& operator<<(std::ostream& os, const std::experimental::math::matrix
using namespace std::experimental::math;
using namespace units;
using namespace si::literals;
using namespace units::physical;
using namespace units::physical::si::literals;
template<typename Rep = double>
using vector = fs_vector<Rep, 3>;
@@ -201,10 +201,10 @@ void matrix_of_quantity_tests()
matrix_of_quantity_divide_by_scalar();
}
template<Unit U = si::metre, Scalar Rep = double>
template<units::Unit U = si::metre, units::Scalar Rep = double>
using length_v = si::length<U, vector<Rep>>;
template<Unit U = si::newton, Scalar Rep = double>
template<units::Unit U = si::newton, units::Scalar Rep = double>
using force_v = si::force<U, vector<Rep>>;
void quantity_of_vector_add()
+1 -1
View File
@@ -157,7 +157,7 @@ namespace {
void example()
{
using namespace units;
using namespace units::physical;
const auto a = si::acceleration<si::metre_per_second_sq, measurement<double>>(measurement(9.8, 0.1));
const auto t = si::time<si::second, measurement<double>>(measurement(1.2, 0.1));
+3 -3
View File
@@ -30,7 +30,7 @@
namespace {
using namespace units;
using namespace units::physical;
Energy AUTO total_energy(Momentum AUTO p, Mass AUTO m, Velocity AUTO c)
{
@@ -39,7 +39,7 @@ Energy AUTO total_energy(Momentum AUTO p, Mass AUTO m, Velocity AUTO c)
void si_example()
{
using namespace si;
using namespace units::physical::si;
using GeV = gigaelectronvolt;
constexpr Velocity AUTO c = si2019::speed_of_light<>;
@@ -70,7 +70,7 @@ void si_example()
void natural_example()
{
using namespace natural;
using namespace units::physical::natural;
using GeV = gigaelectronvolt;
constexpr Velocity AUTO c = speed_of_light<>;
+9 -8
View File
@@ -25,23 +25,24 @@
namespace {
template<units::Length D, units::Time T>
constexpr units::Velocity AUTO avg_speed(D d, T t)
template<units::physical::Length D, units::physical::Time T>
constexpr units::physical::Velocity AUTO avg_speed(D d, T t)
{
return d / t;
}
void example()
{
using namespace units::si::literals;
using namespace units::physical;
using namespace units::physical::si::literals;
units::Length AUTO d1 = 123q_m;
units::Time AUTO t1 = 10q_s;
units::Velocity AUTO v1 = avg_speed(d1, t1);
Length AUTO d1 = 123q_m;
Time AUTO t1 = 10q_s;
Velocity AUTO v1 = avg_speed(d1, t1);
auto temp1 = v1 * 50q_m; // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit'
units::Velocity AUTO v2 = temp1 / 100q_m; // back to known dimensions again
units::Length AUTO d2 = v2 * 60q_s;
Velocity AUTO v2 = temp1 / 100q_m; // back to known dimensions again
Length AUTO d2 = v2 * 60q_s;
std::cout << "d1 = " << d1 << '\n';
std::cout << "t1 = " << t1 << '\n';