Migrate units from ratio to Magnitude

This commit is huge, but hopefully the cognitive load is not too bad.
The bulk of this commit is just some fairly mechanical updates from
`ratio` to `Magnitude`.  Other things to call out:

- `UnitRatio` goes away.  We don't need this concept, because Magnitude
  can't even _represent_ anything that doesn't satisfy it.

- I commented out some formatting test cases where the precise
  expression changes, but the number is completely equivalent.  We will
  need to decide how we want to handle Magnitude formatting as a
  separate, follow-on task.  But at least Magnitude gives us all the
  tools we'll need to do so!
This commit is contained in:
Chip Hogg committed 2022-04-11 15:16:16 +00:00
1 parent 5afe7766e9
commit d19b2803ce
42 files changed
+197 -199

No files matched your search

@@ -58,7 +58,7 @@ struct exakatal : prefixed_unit<exakatal, exa, katal> {};
struct zettakatal : prefixed_unit<zettakatal, zetta, katal> {};
struct yottakatal : prefixed_unit<yottakatal, yotta, katal> {};
struct enzyme_unit : named_scaled_unit<enzyme_unit, "U", prefix, ratio(1, 60, -6), katal> {};
struct enzyme_unit : named_scaled_unit<enzyme_unit, "U", prefix, as_magnitude<ratio(1, 60, -6)>(), katal> {};
struct dim_catalytic_activity :
isq::dim_catalytic_activity<dim_catalytic_activity, katal, dim_time, dim_amount_of_substance> {};
+2 -1
View File
@@ -55,7 +55,8 @@ struct yottajoule : prefixed_unit<yottajoule, yotta, joule> {};
// N.B. electron charge (and eV) is an exact constant:
// https://www.bipm.org/documents/20126/41483022/SI-Brochure-9.pdf#page=147
struct electronvolt : named_scaled_unit<electronvolt, "eV", prefix, ratio(1'602'176'634, 1'000'000'000, -19), joule> {};
struct electronvolt :
named_scaled_unit<electronvolt, "eV", prefix, as_magnitude<ratio(1'602'176'634, 1'000'000'000, -19)>(), joule> {};
struct gigaelectronvolt : prefixed_unit<gigaelectronvolt, giga, electronvolt> {};
struct dim_energy : isq::dim_energy<dim_energy, joule, dim_force, dim_length> {};
+2 -1
View File
@@ -56,7 +56,8 @@ struct exametre : prefixed_unit<exametre, exa, metre> {};
struct zettametre : prefixed_unit<zettametre, zetta, metre> {};
struct yottametre : prefixed_unit<yottametre, yotta, metre> {};
struct astronomical_unit : named_scaled_unit<astronomical_unit, "au", no_prefix, ratio(149'597'870'700), metre> {};
struct astronomical_unit :
named_scaled_unit<astronomical_unit, "au", no_prefix, as_magnitude<149'597'870'700>(), metre> {};
struct dim_length : isq::dim_length<metre> {};
@@ -56,7 +56,7 @@ struct exatesla : prefixed_unit<exatesla, exa, tesla> {};
struct zettatesla : prefixed_unit<zettatesla, zetta, tesla> {};
struct yottatesla : prefixed_unit<yottatesla, yotta, tesla> {};
struct gauss : named_scaled_unit<gauss, "G", prefix, ratio(1, 10'000), tesla> {};
struct gauss : named_scaled_unit<gauss, "G", prefix, as_magnitude<ratio(1, 10'000)>(), tesla> {};
struct dim_magnetic_induction :
isq::dim_magnetic_induction<dim_magnetic_induction, tesla, dim_voltage, dim_time, dim_length> {};
+2 -1
View File
@@ -79,7 +79,8 @@ struct zettatonne : prefixed_unit<zettatonne, zetta, tonne> {};
struct yottatonne : prefixed_unit<yottatonne, yotta, tonne> {};
struct dalton :
named_scaled_unit<dalton, "Da", no_prefix, ratio(16'605'390'666'050, 10'000'000'000'000, -27), kilogram> {};
named_scaled_unit<dalton, "Da", no_prefix, as_magnitude<ratio(16'605'390'666'050, 10'000'000'000'000, -27)>(),
kilogram> {};
struct dim_mass : isq::dim_mass<kilogram> {};
+3 -3
View File
@@ -43,9 +43,9 @@ struct picosecond : prefixed_unit<picosecond, pico, second> {};
struct nanosecond : prefixed_unit<nanosecond, nano, second> {};
struct microsecond : prefixed_unit<microsecond, micro, second> {};
struct millisecond : prefixed_unit<millisecond, milli, second> {};
struct minute : named_scaled_unit<minute, "min", no_prefix, ratio(60), second> {};
struct hour : named_scaled_unit<hour, "h", no_prefix, ratio(60), minute> {};
struct day : named_scaled_unit<day, "d", no_prefix, ratio(24), hour> {};
struct minute : named_scaled_unit<minute, "min", no_prefix, as_magnitude<60>(), second> {};
struct hour : named_scaled_unit<hour, "h", no_prefix, as_magnitude<60>(), minute> {};
struct day : named_scaled_unit<day, "d", no_prefix, as_magnitude<24>(), hour> {};
struct dim_time : isq::dim_time<second> {};