diff --git a/include/xo/unit/Quantity.hpp b/include/xo/unit/Quantity.hpp index dc846fda..15dc4833 100644 --- a/include/xo/unit/Quantity.hpp +++ b/include/xo/unit/Quantity.hpp @@ -227,7 +227,7 @@ namespace xo { inline constexpr Quantity unit_qty(const scaled_unit & u) { return Quantity - (u.outer_scale_factor_.template to() * ::sqrt(u.outer_scale_sq_), + (u.outer_scale_factor_.template convert_to() * ::sqrt(u.outer_scale_sq_), u.natural_unit_); } diff --git a/include/xo/unit/scaled_unit.hpp b/include/xo/unit/scaled_unit.hpp index b13adeac..bf696f5d 100644 --- a/include/xo/unit/scaled_unit.hpp +++ b/include/xo/unit/scaled_unit.hpp @@ -70,6 +70,7 @@ namespace xo { template using width2x_t = width2x::type; +#ifdef NOT_USING template constexpr detail::bpu2_rescale_result @@ -85,7 +86,9 @@ namespace xo { rr.outer_scale_exact_, rr.outer_scale_sq_); } +#endif +#ifdef NOT_USING template constexpr scaled_unit @@ -99,6 +102,7 @@ namespace xo { rr.outer_scale_exact_, rr.outer_scale_sq_); }; +#endif template , diff --git a/include/xo/unit/scaled_unit_iostream.hpp b/include/xo/unit/scaled_unit_iostream.hpp index 1096d46b..35a5cce7 100644 --- a/include/xo/unit/scaled_unit_iostream.hpp +++ b/include/xo/unit/scaled_unit_iostream.hpp @@ -10,9 +10,11 @@ namespace xo { namespace qty { - template + template inline std::ostream & - operator<<(std::ostream & os, const scaled_unit & x) { + operator<<(std::ostream & os, + const scaled_unit & x) + { os << " + +namespace xo { + using xo::qty::scalefactor_ratio_type; + using xo::qty::abbrev::basis_unit2_abbrev; + using xo::qty::basis_unit; + using xo::qty::basis_unit2_abbrev_type; + using xo::qty::native_unit2_v; + using xo::qty::dim; + namespace bu = xo::qty::bu; + + namespace ut { + + /* compile-time test: + * verify we can use a basis_unit as a non-type template parameter + * we will need this for quantity> + */ + template + constexpr basis_unit2_abbrev_type bu_mpl_abbrev = bu.abbrev(); + + TEST_CASE("basis_unit", "[basis_unit]") { + //constexpr bool c_debug_flag = false; + + // can get bits from /dev/random by uncommenting the 2nd line below + //uint64_t seed = xxx; + //rng::Seed seed; + + //auto rng = xo::rng::xoshiro256ss(seed); + + //scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.basis_unit")); + //log && log("(A)", xtag("foo", foo)); + + static_assert(bu_mpl_abbrev == bu::gram.abbrev()); + REQUIRE(bu_mpl_abbrev == bu::gram.abbrev()); + } /*TEST_CASE(basis_unit)*/ + + TEST_CASE("basis_unit1", "[basis_unit]") { + constexpr bool c_debug_flag = true; + + // can get bits from /dev/random by uncommenting the 2nd line below + //uint64_t seed = xxx; + //rng::Seed seed; + + //auto rng = xo::rng::xoshiro256ss(seed); + + scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.basis_unit1")); + //log && log("(A)", xtag("foo", foo)); + + static_assert(native_unit2_v[static_cast(dim::mass)].native_dim() == dim::mass); + static_assert(native_unit2_v[static_cast(dim::distance)].native_dim() == dim::distance); + static_assert(native_unit2_v[static_cast(dim::time)].native_dim() == dim::time); + static_assert(native_unit2_v[static_cast(dim::time)].native_dim() == dim::time); + static_assert(native_unit2_v[static_cast(dim::currency)].native_dim() == dim::currency); + static_assert(native_unit2_v[static_cast(dim::price)].native_dim() == dim::price); + + log && log(xtag("mass*10^3", basis_unit2_abbrev(dim::mass, scalefactor_ratio_type(1000, 1)))); + + static_assert(basis_unit2_abbrev(dim::mass, scalefactor_ratio_type(1000, 1)) + == basis_unit2_abbrev_type::from_chars("kg")); + + log && log("---------------------"); + + /* note: using CHECK to make test show up in coverage */ + +# define REQUIRE_x2(x) static_assert(x); REQUIRE(x) + + REQUIRE_x2(bu::picogram.abbrev() == basis_unit2_abbrev_type::from_chars("pg")); + REQUIRE_x2(bu::nanogram.abbrev() + == basis_unit2_abbrev_type::from_chars("ng")); + REQUIRE_x2(bu::microgram.abbrev() + == basis_unit2_abbrev_type::from_chars("ug")); + REQUIRE_x2(bu::milligram.abbrev() + == basis_unit2_abbrev_type::from_chars("mg")); + REQUIRE_x2(bu::gram.abbrev() + == basis_unit2_abbrev_type::from_chars("g")); + REQUIRE_x2(bu::kilogram.abbrev() + == basis_unit2_abbrev_type::from_chars("kg")); + REQUIRE_x2(bu::tonne.abbrev() + == basis_unit2_abbrev_type::from_chars("t")); + REQUIRE_x2(bu::kilotonne.abbrev() + == basis_unit2_abbrev_type::from_chars("kt")); + REQUIRE_x2(bu::megatonne.abbrev() + == basis_unit2_abbrev_type::from_chars("Mt")); + + log && log(xtag("distance", basis_unit2_abbrev(dim::distance, scalefactor_ratio_type(1, 1)))); + + REQUIRE_x2(bu::picometre.abbrev() + == basis_unit2_abbrev_type::from_chars("pm")); + REQUIRE_x2(bu::nanometre.abbrev() + == basis_unit2_abbrev_type::from_chars("nm")); + REQUIRE_x2(bu::micrometre.abbrev() + == basis_unit2_abbrev_type::from_chars("um")); + REQUIRE_x2(bu::millimetre.abbrev() + == basis_unit2_abbrev_type::from_chars("mm")); + REQUIRE_x2(bu::metre.abbrev() + == basis_unit2_abbrev_type::from_chars("m")); + REQUIRE_x2(bu::kilometre.abbrev() + == basis_unit2_abbrev_type::from_chars("km")); + REQUIRE_x2(bu::megametre.abbrev() + == basis_unit2_abbrev_type::from_chars("Mm")); + REQUIRE_x2(bu::gigametre.abbrev() + == basis_unit2_abbrev_type::from_chars("Gm")); + + REQUIRE_x2(bu::lightsecond.abbrev() == basis_unit2_abbrev_type::from_chars("lsec")); + REQUIRE_x2(bu::astronomicalunit.abbrev() == basis_unit2_abbrev_type::from_chars("AU")); + + log && log(xtag("time", basis_unit2_abbrev(dim::time, scalefactor_ratio_type(1, 1)))); + + REQUIRE_x2(bu::second.abbrev() == basis_unit2_abbrev_type::from_chars("s")); + REQUIRE_x2(bu::picosecond.abbrev() == basis_unit2_abbrev_type::from_chars("ps")); + REQUIRE_x2(bu::nanosecond.abbrev() == basis_unit2_abbrev_type::from_chars("ns")); + REQUIRE_x2(bu::microsecond.abbrev() == basis_unit2_abbrev_type::from_chars("us")); + REQUIRE_x2(bu::millisecond.abbrev() == basis_unit2_abbrev_type::from_chars("ms")); + REQUIRE_x2(bu::second.abbrev() == basis_unit2_abbrev_type::from_chars("s")); + REQUIRE_x2(bu::minute.abbrev() == basis_unit2_abbrev_type::from_chars("min")); + REQUIRE_x2(bu::hour.abbrev() == basis_unit2_abbrev_type::from_chars("hr")); + REQUIRE_x2(bu::day.abbrev() == basis_unit2_abbrev_type::from_chars("dy")); + REQUIRE_x2(bu::week.abbrev() == basis_unit2_abbrev_type::from_chars("wk")); + REQUIRE_x2(bu::month.abbrev() == basis_unit2_abbrev_type::from_chars("mo")); + + REQUIRE_x2(bu::year.abbrev() == basis_unit2_abbrev_type::from_chars("yr")); + REQUIRE_x2(bu::year250.abbrev() == basis_unit2_abbrev_type::from_chars("yr250")); + REQUIRE_x2(bu::year360.abbrev() == basis_unit2_abbrev_type::from_chars("yr360")); + REQUIRE_x2(bu::year365.abbrev() == basis_unit2_abbrev_type::from_chars("yr365")); + + log && log(xtag("currency", basis_unit2_abbrev(dim::currency, scalefactor_ratio_type(1, 1)))); + + REQUIRE_x2(bu::currency.abbrev() == flatstring("ccy")); + + log && log(xtag("price", basis_unit2_abbrev(dim::price, scalefactor_ratio_type(1, 1)))); + + REQUIRE_x2(bu::price.abbrev() == flatstring("px")); + +# undef REQUIRE_x2 + +#ifdef OBSOLETE + log && log("---------------------"); + + log && log(xtag("mass*10^-9", scaled_native_unit2_abbrev_v)); + log && log(xtag("mass*10^-6", scaled_native_unit2_abbrev_v)); + log && log(xtag("mass*10^-3", scaled_native_unit2_abbrev_v)); + log && log(xtag("mass", scaled_native_unit2_abbrev_v)); + log && log(xtag("mass*10^3", scaled_native_unit2_abbrev_v)); + log && log(xtag("mass*10^6", scaled_native_unit2_abbrev_v)); + log && log(xtag("mass*10^9", scaled_native_unit2_abbrev_v)); + + log && log(xtag("distance*10^-9", scaled_native_unit2_abbrev_v)); + log && log(xtag("distance*10^-6", scaled_native_unit2_abbrev_v)); + log && log(xtag("distance*10^-3", scaled_native_unit2_abbrev_v)); + log && log(xtag("distance", scaled_native_unit2_abbrev_v)); + log && log(xtag("distance*10^3", scaled_native_unit2_abbrev_v)); + + log && log(xtag("time*10^-9", scaled_native_unit2_abbrev_v)); + log && log(xtag("time*10^-6", scaled_native_unit2_abbrev_v)); + log && log(xtag("time*10^-3", scaled_native_unit2_abbrev_v)); + log && log(xtag("time", scaled_native_unit2_abbrev_v)); + log && log(xtag("time*60", scaled_native_unit2_abbrev_v)); + log && log(xtag("time*3600", scaled_native_unit2_abbrev_v)); + log && log(xtag("time*24*3600", scaled_native_unit2_abbrev_v)); + log && log(xtag("time*250*24*3600", scaled_native_unit2_abbrev_v)); + log && log(xtag("time*360*24*3600", scaled_native_unit2_abbrev_v)); + log && log(xtag("time*365*24*3600", scaled_native_unit2_abbrev_v)); + + log && log(xtag("currency", scaled_native_unit2_abbrev_v)); + + log && log(xtag("price", scaled_native_unit2_abbrev_v)); + + REQUIRE(xo::qty::units::scaled_native_unit2_abbrev::value == xo::flatstring("g")); + + /* proof that scaled_native_unit2_abbrev::value is constexpr */ + static_assert(scaled_native_unit2_abbrev_v + == basis_unit2_abbrev_type::from_flatstring(xo::flatstring("g"))); +#endif + + } /*TEST_CASE(basis_unit1)*/ + + } /*namespace ut*/ +} /*namespace xo*/ + +/* end bu.test.cpp */ diff --git a/utest/unit.test.cpp b/utest/unit.test.cpp index ba1287ad..7e08294d 100644 --- a/utest/unit.test.cpp +++ b/utest/unit.test.cpp @@ -2,6 +2,7 @@ #include "xo/unit/unit2.hpp" #include "xo/unit/Quantity_iostream.hpp" +#include "xo/unit/scaled_unit_iostream.hpp" #include "xo/unit/Quantity.hpp" #include "xo/unit/scaled_unit_iostream.hpp" #include "xo/unit/natural_unit.hpp" @@ -13,6 +14,7 @@ #include "xo/unit/native_unit.hpp" #include "xo/indentlog/scope.hpp" #include "xo/indentlog/print/tag.hpp" +#include "xo/flatstring/int128_iostream.hpp" #include namespace xo { @@ -25,12 +27,11 @@ namespace xo { using xo::qty::Quantity; using xo::qty::dim; using xo::qty::basis_unit2_abbrev_type; - using xo::qty::native_unit2_v; using xo::qty::scalefactor_ratio_type; using xo::qty::units::scaled_native_unit2_abbrev; //using xo::qty::units::scaled_native_unit2_abbrev_v; using xo::qty::basis_unit; - using xo::qty::abbrev::basis_unit2_abbrev;; + using xo::qty::abbrev::basis_unit2_abbrev; using xo::qty::bpu_abbrev_type; using xo::qty::abbrev::bpu_abbrev; using xo::qty::basis_unit2_store; @@ -38,155 +39,15 @@ namespace xo { using xo::qty::abbrev::flatstring_from_exponent; using xo::qty::bpu; using xo::qty::detail::bpu2_rescale; - using xo::qty::detail::bpu2_product; + //using xo::qty::detail::bpu2_product; using xo::qty::natural_unit; using xo::qty::detail::nu_maker; using xo::qty::detail::su_product; - using xo::qty::detail::su_bpu_product; + //using xo::qty::detail::su_bpu_product; using xo::qty::detail::nu_ratio_inplace; using xo::qty::detail::su_ratio; using xo::qty::unit_qty; - TEST_CASE("basis_unit", "[basis_unit]") { - constexpr bool c_debug_flag = true; - - // can get bits from /dev/random by uncommenting the 2nd line below - //uint64_t seed = xxx; - //rng::Seed seed; - - //auto rng = xo::rng::xoshiro256ss(seed); - - scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.basis_unit")); - //log && log("(A)", xtag("foo", foo)); - - static_assert(native_unit2_v[static_cast(dim::mass)].native_dim() == dim::mass); - static_assert(native_unit2_v[static_cast(dim::distance)].native_dim() == dim::distance); - static_assert(native_unit2_v[static_cast(dim::time)].native_dim() == dim::time); - static_assert(native_unit2_v[static_cast(dim::time)].native_dim() == dim::time); - static_assert(native_unit2_v[static_cast(dim::currency)].native_dim() == dim::currency); - static_assert(native_unit2_v[static_cast(dim::price)].native_dim() == dim::price); - - log && log(xtag("mass*10^3", basis_unit2_abbrev(dim::mass, scalefactor_ratio_type(1000, 1)))); - - static_assert(basis_unit2_abbrev(dim::mass, scalefactor_ratio_type(1000, 1)) - == basis_unit2_abbrev_type::from_chars("kg")); - - log && log("---------------------"); - - /* note: using CHECK to make test show up in coverage */ - -# define REQUIRE_x2(x) static_assert(x); REQUIRE(x) - - REQUIRE_x2(bu::picogram.abbrev() == basis_unit2_abbrev_type::from_chars("pg")); - REQUIRE_x2(bu::nanogram.abbrev() - == basis_unit2_abbrev_type::from_chars("ng")); - REQUIRE_x2(bu::microgram.abbrev() - == basis_unit2_abbrev_type::from_chars("ug")); - REQUIRE_x2(bu::milligram.abbrev() - == basis_unit2_abbrev_type::from_chars("mg")); - REQUIRE_x2(bu::gram.abbrev() - == basis_unit2_abbrev_type::from_chars("g")); - REQUIRE_x2(bu::kilogram.abbrev() - == basis_unit2_abbrev_type::from_chars("kg")); - REQUIRE_x2(bu::tonne.abbrev() - == basis_unit2_abbrev_type::from_chars("t")); - REQUIRE_x2(bu::kilotonne.abbrev() - == basis_unit2_abbrev_type::from_chars("kt")); - REQUIRE_x2(bu::megatonne.abbrev() - == basis_unit2_abbrev_type::from_chars("Mt")); - - log && log(xtag("distance", basis_unit2_abbrev(dim::distance, scalefactor_ratio_type(1, 1)))); - - REQUIRE_x2(bu::picometre.abbrev() - == basis_unit2_abbrev_type::from_chars("pm")); - REQUIRE_x2(bu::nanometre.abbrev() - == basis_unit2_abbrev_type::from_chars("nm")); - REQUIRE_x2(bu::micrometre.abbrev() - == basis_unit2_abbrev_type::from_chars("um")); - REQUIRE_x2(bu::millimetre.abbrev() - == basis_unit2_abbrev_type::from_chars("mm")); - REQUIRE_x2(bu::metre.abbrev() - == basis_unit2_abbrev_type::from_chars("m")); - REQUIRE_x2(bu::kilometre.abbrev() - == basis_unit2_abbrev_type::from_chars("km")); - REQUIRE_x2(bu::megametre.abbrev() - == basis_unit2_abbrev_type::from_chars("Mm")); - REQUIRE_x2(bu::gigametre.abbrev() - == basis_unit2_abbrev_type::from_chars("Gm")); - - REQUIRE_x2(bu::lightsecond.abbrev() == basis_unit2_abbrev_type::from_chars("lsec")); - REQUIRE_x2(bu::astronomicalunit.abbrev() == basis_unit2_abbrev_type::from_chars("AU")); - - log && log(xtag("time", basis_unit2_abbrev(dim::time, scalefactor_ratio_type(1, 1)))); - - REQUIRE_x2(bu::second.abbrev() == basis_unit2_abbrev_type::from_chars("s")); - REQUIRE_x2(bu::picosecond.abbrev() == basis_unit2_abbrev_type::from_chars("ps")); - REQUIRE_x2(bu::nanosecond.abbrev() == basis_unit2_abbrev_type::from_chars("ns")); - REQUIRE_x2(bu::microsecond.abbrev() == basis_unit2_abbrev_type::from_chars("us")); - REQUIRE_x2(bu::millisecond.abbrev() == basis_unit2_abbrev_type::from_chars("ms")); - REQUIRE_x2(bu::second.abbrev() == basis_unit2_abbrev_type::from_chars("s")); - REQUIRE_x2(bu::minute.abbrev() == basis_unit2_abbrev_type::from_chars("min")); - REQUIRE_x2(bu::hour.abbrev() == basis_unit2_abbrev_type::from_chars("hr")); - REQUIRE_x2(bu::day.abbrev() == basis_unit2_abbrev_type::from_chars("dy")); - REQUIRE_x2(bu::week.abbrev() == basis_unit2_abbrev_type::from_chars("wk")); - REQUIRE_x2(bu::month.abbrev() == basis_unit2_abbrev_type::from_chars("mo")); - - REQUIRE_x2(bu::year.abbrev() == basis_unit2_abbrev_type::from_chars("yr")); - REQUIRE_x2(bu::year250.abbrev() == basis_unit2_abbrev_type::from_chars("yr250")); - REQUIRE_x2(bu::year360.abbrev() == basis_unit2_abbrev_type::from_chars("yr360")); - REQUIRE_x2(bu::year365.abbrev() == basis_unit2_abbrev_type::from_chars("yr365")); - - log && log(xtag("currency", basis_unit2_abbrev(dim::currency, scalefactor_ratio_type(1, 1)))); - - REQUIRE_x2(bu::currency.abbrev() == flatstring("ccy")); - - log && log(xtag("price", basis_unit2_abbrev(dim::price, scalefactor_ratio_type(1, 1)))); - - REQUIRE_x2(bu::price.abbrev() == flatstring("px")); - -# undef REQUIRE_x2 - -#ifdef OBSOLETE - log && log("---------------------"); - - log && log(xtag("mass*10^-9", scaled_native_unit2_abbrev_v)); - log && log(xtag("mass*10^-6", scaled_native_unit2_abbrev_v)); - log && log(xtag("mass*10^-3", scaled_native_unit2_abbrev_v)); - log && log(xtag("mass", scaled_native_unit2_abbrev_v)); - log && log(xtag("mass*10^3", scaled_native_unit2_abbrev_v)); - log && log(xtag("mass*10^6", scaled_native_unit2_abbrev_v)); - log && log(xtag("mass*10^9", scaled_native_unit2_abbrev_v)); - - log && log(xtag("distance*10^-9", scaled_native_unit2_abbrev_v)); - log && log(xtag("distance*10^-6", scaled_native_unit2_abbrev_v)); - log && log(xtag("distance*10^-3", scaled_native_unit2_abbrev_v)); - log && log(xtag("distance", scaled_native_unit2_abbrev_v)); - log && log(xtag("distance*10^3", scaled_native_unit2_abbrev_v)); - - log && log(xtag("time*10^-9", scaled_native_unit2_abbrev_v)); - log && log(xtag("time*10^-6", scaled_native_unit2_abbrev_v)); - log && log(xtag("time*10^-3", scaled_native_unit2_abbrev_v)); - log && log(xtag("time", scaled_native_unit2_abbrev_v)); - log && log(xtag("time*60", scaled_native_unit2_abbrev_v)); - log && log(xtag("time*3600", scaled_native_unit2_abbrev_v)); - log && log(xtag("time*24*3600", scaled_native_unit2_abbrev_v)); - log && log(xtag("time*250*24*3600", scaled_native_unit2_abbrev_v)); - log && log(xtag("time*360*24*3600", scaled_native_unit2_abbrev_v)); - log && log(xtag("time*365*24*3600", scaled_native_unit2_abbrev_v)); - - log && log(xtag("currency", scaled_native_unit2_abbrev_v)); - - log && log(xtag("price", scaled_native_unit2_abbrev_v)); - - REQUIRE(xo::qty::units::scaled_native_unit2_abbrev::value == xo::flatstring("g")); - - /* proof that scaled_native_unit2_abbrev::value is constexpr */ - static_assert(scaled_native_unit2_abbrev_v - == basis_unit2_abbrev_type::from_flatstring(xo::flatstring("g"))); -#endif - - } /*TEST_CASE(basis_unit)*/ - TEST_CASE("basis_unit2_store", "[basis_unit2_store]") { constexpr bool c_debug_flag = false; @@ -362,20 +223,20 @@ namespace xo { constexpr auto p_floor = orig_bpu.power().floor(); static_assert(p_floor == 1); - constexpr auto p_frac = orig_bpu.power().frac().template to(); + constexpr auto p_frac = orig_bpu.power().frac().template convert_to(); static_assert(p_frac == 0.0); constexpr auto outer_sf_exact = mult.power(p_floor); static_assert(outer_sf_exact.num() == 1); static_assert(outer_sf_exact.den() == 1000); - constexpr auto mult_inexact = mult.template to(); + constexpr auto mult_inexact = mult.template convert_to(); static_assert(mult_inexact == 0.001); constexpr auto rr = bpu2_rescale(orig_bpu, scalefactor_ratio_type(1000000, 1)); static_assert(rr.bpu_rescaled_.power() == power_ratio_type(1,1)); - static_assert(rr.outer_scale_exact_ == outer_sf_exact); + static_assert(rr.outer_scale_factor_ == outer_sf_exact); static_assert(rr.outer_scale_sq_ == 1.0); } @@ -398,23 +259,23 @@ namespace xo { constexpr auto p_floor = orig_bpu.power().floor(); static_assert(p_floor == 0); - constexpr auto p_frac = orig_bpu.power().frac().template to(); + constexpr auto p_frac = orig_bpu.power().frac().template convert_to(); static_assert(p_frac == -0.5); constexpr auto outer_sf_exact = mult.power(p_floor); static_assert(outer_sf_exact.num() == 1); static_assert(outer_sf_exact.den() == 1); - constexpr auto mult_inexact = mult.template to(); + constexpr auto mult_inexact = mult.template convert_to(); static_assert(mult_inexact == 12.0); constexpr auto rr = bpu2_rescale(orig_bpu, scalefactor_ratio_type(30*24*3600, 1)); - log && log(xtag("rr.outer_scale_exact", rr.outer_scale_exact_), + log && log(xtag("rr.outer_scale_exact", rr.outer_scale_factor_), xtag("rr.outer_scale_sq", rr.outer_scale_sq_)); static_assert(rr.bpu_rescaled_.power() == power_ratio_type(-1,2)); - static_assert(rr.outer_scale_exact_ == outer_sf_exact); + static_assert(rr.outer_scale_factor_ == outer_sf_exact); static_assert(rr.outer_scale_sq_ == 12.0); } @@ -437,23 +298,23 @@ namespace xo { constexpr auto p_floor = orig_bpu.power().floor(); static_assert(p_floor == -1); - constexpr auto p_frac = orig_bpu.power().frac().template to(); + constexpr auto p_frac = orig_bpu.power().frac().template convert_to(); static_assert(p_frac == -0.5); constexpr auto outer_sf_exact = mult.power(p_floor); static_assert(outer_sf_exact.num() == 1); static_assert(outer_sf_exact.den() == 12); - constexpr auto mult_inexact = mult.template to(); + constexpr auto mult_inexact = mult.template convert_to(); static_assert(mult_inexact == 12.0); constexpr auto rr = bpu2_rescale(orig_bpu, scalefactor_ratio_type(30*24*3600, 1)); - log && log(xtag("rr.outer_scale_exact", rr.outer_scale_exact_), + log && log(xtag("rr.outer_scale_exact", rr.outer_scale_factor_), xtag("rr.outer_scale_sq", rr.outer_scale_sq_)); static_assert(rr.bpu_rescaled_.power() == power_ratio_type(-3,2)); - static_assert(rr.outer_scale_exact_ == outer_sf_exact); + static_assert(rr.outer_scale_factor_ == outer_sf_exact); static_assert(rr.outer_scale_sq_ == 12.0); } } /*TEST_CASE(bpu_rescale)*/ @@ -481,6 +342,7 @@ namespace xo { power_ratio_type(1,2)); static_assert(bpu_y.native_dim() == dim::time); +#ifdef NOT_USING constexpr auto bpu_prod = bpu2_product(bpu_x, bpu_y); log && log(xtag("bpu_prod.bpu_rescaled", bpu_prod.bpu_rescaled_)); @@ -492,6 +354,7 @@ namespace xo { static_assert(bpu_prod.bpu_rescaled_.power() == power_ratio_type(-1, 1)); static_assert(bpu_prod.outer_scale_exact_ == scalefactor_ratio_type(1,1)); static_assert(bpu_prod.outer_scale_sq_ == 1.0); +#endif } } /*TEST_CASE(bpu_product)*/ @@ -518,6 +381,7 @@ namespace xo { power_ratio_type(1,2)); static_assert(bpu_y.native_dim() == dim::time); +#ifdef NOT_USING constexpr auto bpu_prod = bpu2_product(bpu_x, bpu_y); log && log(xtag("bpu_prod.bpu_rescaled", bpu_prod.bpu_rescaled_)); @@ -529,6 +393,7 @@ namespace xo { static_assert(bpu_prod.bpu_rescaled_.power() == power_ratio_type(-1, 1)); static_assert(bpu_prod.outer_scale_exact_ == scalefactor_ratio_type(1,1)); static_assert(bpu_prod.outer_scale_sq_ == 1.0/12.0); +#endif } } /*TEST_CASE(bpu_product2)*/ @@ -594,6 +459,7 @@ namespace xo { static_assert(bpu.power() == power_ratio_type(-1, 2)); +#ifdef NOT_USING constexpr auto prod_rr = su_bpu_product(v, bpu); log && log(xtag("prod_rr.bpu_array", prod_rr.natural_unit_)); @@ -612,6 +478,7 @@ namespace xo { static_assert(prod_rr.natural_unit_[2].power() == power_ratio_type(-1, 2)); static_assert(prod_rr.outer_scale_factor_ == scalefactor_ratio_type(1, 1)); static_assert(prod_rr.outer_scale_sq_ == 1.0); +#endif } } /*TEST_CASE(bpu_array_product0)*/ @@ -641,6 +508,7 @@ namespace xo { static_assert(bpu.power() == power_ratio_type(-1, 2)); +#ifdef NOT_USING constexpr auto prod_rr = su_bpu_product(v, bpu); log && log(xtag("prod_rr.bpu_array", prod_rr.natural_unit_)); @@ -656,6 +524,7 @@ namespace xo { static_assert(prod_rr.natural_unit_[1].power() == power_ratio_type(-1, 1)); static_assert(prod_rr.outer_scale_factor_ == scalefactor_ratio_type(1, 1)); static_assert(prod_rr.outer_scale_sq_ == 12.0); +#endif } } /*TEST_CASE(bpu_array_product1)*/ @@ -685,6 +554,7 @@ namespace xo { static_assert(bpu.power() == power_ratio_type(-1, 1)); +#ifdef NOT_USING constexpr auto prod_rr = su_bpu_product(v, bpu); log && log(xtag("prod_rr.bpu_array", prod_rr.natural_unit_)); @@ -700,6 +570,7 @@ namespace xo { static_assert(prod_rr.natural_unit_[1].power() == power_ratio_type(-1, 1)); static_assert(prod_rr.outer_scale_factor_ == scalefactor_ratio_type(1, 1)); static_assert(prod_rr.outer_scale_sq_ == 1.0); +#endif } } /*TEST_CASE(bpu_array_product2)*/ @@ -732,7 +603,7 @@ namespace xo { constexpr auto prod_rr = su_product(v, w); log && log(xtag("prod_rr.bpu_array", prod_rr.natural_unit_)); - log && log(xtag("prod_rr.outer_scale_exact", prod_rr.outer_scale_factor_)); + log && log(xtag("prod_rr.outer_scale_exact", prod_rr.outer_scale_factor_.convert_to())); log && log(xtag("prod_rr.outer_scale_sq", prod_rr.outer_scale_sq_)); static_assert(prod_rr.natural_unit_.n_bpu() == 3);