Commit Graph
40 Commits
Author SHA1 Message Date
Chip Hogg ea83af8aa9 Rename as_magnitude<...>() to mag<...>()
This is easier to write and to read.
2022-07-29 01:46:06 +00:00
Chip Hogg 6a9dcb30de Migrate explicit-exp inputs 2022-07-20 00:52:36 +00:00
Chip Hogg 5fb468697b Merge branch 'master' into chiphogg/switch-to-mag 2022-05-12 16:12:01 +00:00
Mateusz Pusz 5300caf17b refactor: 💥 ! derived_deduced_unit renamed to derived_scaled_unit
Naming is hard ;-)
2022-05-11 12:34:52 +02:00
Mateusz Pusz 32b36fb670 refactor: 💥 ! PrefixFamily support removed
It doesn't have much sense to restrict prefixes usage for most units and in many places we were wrong to do so already.
2022-05-11 11:59:33 +02:00
Mateusz Pusz 0522bae972 refactor: 💥 ! unit renamed to derived_unit 2022-05-11 11:40:19 +02:00
Mateusz Pusz f5d21a0711 refactor: 💥 ! derived_unit renamed to derived_deduced_unit 2022-05-11 11:23:18 +02:00
Chip Hogg 78bcb3b019 Remove troublesome ::ratio members
For some reason, MSVC seems to want to instantiate these, even though
nobody ever asks for them (as evidenced by the fact that the builds
passed on other architectures).
2022-04-12 00:35:17 +00:00
Chip Hogg 5e365f1905 Delete obsolete test case 2022-04-11 15:16:16 +00:00
Chip Hogg d19b2803ce 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!
2022-04-11 15:16:16 +00:00
Mateusz Pusz b221dace3f style: clang-format applied to the remaining files 2022-04-02 21:36:42 +02:00
Mateusz Pusz 8e88f06380 refactor: *deduced_unit renamed to *derived_unit 2021-05-10 15:56:48 +02:00
Mateusz Pusz 37cfc53d1d refactor: IWYU applied to the source files
`alternative_namespaces` examples left out as I consider them a subject for removal in the nearest future.
2021-03-30 13:21:05 +02:00
Mateusz Pusz bbbb77286c refactor: physical replaced with isq
Refers to #249
2021-03-16 12:03:25 +01:00
Mateusz Pusz 5c94a40906 build: COMP_XXX renamed to UNITS_COMP_XXX 2021-03-15 21:13:21 +01:00
Johel Ernesto Guerrero Peña 6bf09aa646 feat: quantity_kind and quantity_point_kind 2021-02-15 19:31:08 +01:00
Mateusz Pusz 76437a7752 fix: unit_tests.cpp compilation fixed for MSVC 2021-01-04 13:55:27 +01:00
Mateusz Pusz eea770a2e1 test: #if COMP_GCC >= 10 removed
Resolves #197
2021-01-04 09:45:10 +01:00
Mateusz Pusz 58daacfd58 fix: unit tests fixed for DOWNCAST_MODE = OFF 2020-09-10 11:33:58 +02:00
Mateusz Pusz e367afed71 Merge branch 'downcasting_2.0' 2020-09-09 20:31:03 +02:00
Mateusz Pusz 563b358d5e feat!: 💥 dimensionless quantities refactored
Dimensionless quantities are now represented by quantity types rather
than by plain representation types. Only dimensionless quantities with
`unitless` unit are implicitly convertible from representation types.

`units::exp()` now is a function doing std::exp() on a representation
type (previous `units::exp` class template was renamed to
`units::exponent`).

BREAKING_CHANGE: gcc-9.3 support removed
BREAKING_CHANGE: `exp` and `Exp` renamed to `exponent` and `Exponent`
Resolves #27
Resolves #42
2020-09-08 11:02:16 +02:00
Mateusz Pusz 77e11173bf Unit tests compilation fixed on VS 2020-09-06 15:35:08 +02:00
Johel Ernesto Guerrero Peña 36046fb6a6 test: simplify case 2020-09-06 09:55:59 +02:00
Johel Ernesto Guerrero Peña aff83b31dc test: codify comment 2020-09-06 09:55:59 +02:00
Johel Ernesto Guerrero Peña 71eda2fc66 test: codify comment in the correct place 2020-09-06 09:55:59 +02:00
Mateusz Pusz 5c98924efb Downcasting reworked to allow OFF and AUTO modes 2020-08-19 13:37:57 +02:00
Mateusz Pusz 9f94a73bba Custom is_same implementation added 2020-06-29 20:30:59 +02:00
Mateusz Pusz d171f5451e NTTP ratio support added (resolves #49) 2020-06-27 19:15:46 +02:00
Mateusz Pusz 61fadb8ebc dim_velocity renamed to dim_speed 2020-05-14 16:00:38 +02:00
Mateusz Pusz 7e935a4108 Physical units put in the physical namespace (I am sorry) 2020-05-08 22:39:24 +02:00
Mateusz Pusz a8ada63031 units::exp disambiguated in unit tests 2020-02-12 09:49:49 +01:00
Oliver Schönrock 509b6c9653 implementing ratio<num,den,exp> which replaces ratio<num,den>
https://github.com/mpusz/units/issues/14

This "works", as in it passes all static and runtime tests.
However quite a few of the tests have been "modified" to make them pass. Whether
this is legitimate is debatable and should be the source of some thought /
discussion.

1. many of the static tests and some of the runtime tests have had the input
ratios of the tests modified in the following way. eg ratio<3,1000> =>
ratio<3,1,-3>. ie they have been "canonicalised".

There are obviously an infinite number of ratios which represent the same
rational number. The way `ratio` is implemented it always moves as "many powers
of 10" from the `num` and `den` into the `exp` and that makes the `canonical`
ratio.

Because these are all "types" and the lib uses is_same all over the place, only
exact matches will be `is_same`. ie ratio<300,4,0> !is_same ratio<3,4,2> (the
latter is the canonical ratio). This is perhaps fine for tests in the devlopment
phase, but there may be a need for "more forgiving" comparison / concept of
value equality. One such comparison which compares den,num,exp after
canonicalisation is the constexpr function `same` as defined at top of
`ratio_test.cpp`. We may need to expose this and perhaps add even more soft
comparisions.

2. In the runtime tests it is "subjective" how some resukts should be
printed. There is the question of "how exactly to format certain ratios". eg
omit denominators of "1" and exponents of "0". However before even addressing
these in detail a decision needs to be made about the general form of
"non-floating-point-converted" ratios which do not map exactly to a "Symbol
prefix".

Arguably these are "relatively ugly" whatever we do, so we could just
go for an easily canonicalised form. An example is:

-        CHECK(stream.str() == "10 [1/60]W");
+        CHECK(stream.str() == "10 [1/6 x 10⁻¹]W");

Which of thses is "better"? Is there a "third", better form?  It's not obvious.

My opnion is: Both of 1&2 are fine for now, unless we think they go down the
wrong avenue, and can be "perfected later"? ie we can expose a softer version of
ratio based equality, and decide on canonical way of printing ratios (as far as
that is actually a very useful output form, compared with decimal, scientific or
engineering notation).
2019-12-28 17:59:47 +01:00
Mateusz Pusz 6596c15238 scaled_unit template parameters order fixed (sorry Oliver) 2019-12-14 21:16:15 +01:00
Mateusz Pusz bc1901f4f0 Text formatting enabled + directory tree refactoring 2019-12-11 08:07:13 +01:00
Mateusz Pusz 22eda11bea More refactoring
- unknown_unit and unknown_dimension added
- the support for remaining SI units added
2019-12-07 16:30:40 +01:00
Mateusz Pusz f31b26b5e5 Design cleanup
- unknown_unit added
- examples refactored
- base_type renamed to downcast_base_type
- scaled_unit renamed to named_scaled_unit
- detail::reference_unit renamed to scaled_unit
- quantity_test cleanup
2019-12-06 12:18:39 +01:00
Mateusz Pusz 1b4e8a2127 Units and dimensions redesigned 2019-12-01 19:47:58 +01:00
Mateusz Pusz 4d3e4aa1fc Surface tension added 2019-11-04 06:46:53 +00:00
Mateusz Pusz 91bcfedf1e Deduced units symbols refactoring started 2019-11-04 06:45:56 +00:00
Mateusz Pusz 3475f5193e Catch2 support added (resolves #8) 2019-10-14 10:53:02 +02:00