Commit Graph
143 Commits
Author SHA1 Message Date
Mateusz Pusz a8ada63031 units::exp disambiguated in unit tests 2020-02-12 09:49:49 +01:00
Mateusz Pusz 2360392a3d Tests for #58 added (uncomment when fixed) 2020-02-11 08:51:34 +01:00
Mateusz Pusz 037503cbc6 deduced_unit fixed + unit test for mass unit added 2020-02-10 20:35:32 +01:00
Mateusz Pusz 645570ff57 Library updated to the latest cmake common tools 2020-01-31 17:02:27 +01:00
Mateusz Pusz 876c2ac426 thou used as a primary unit in a fmt unit test 2020-01-14 12:59:37 +01:00
Andy Little 024f5a9c83 change const order
move in,ft,fathom,ft2,ft3,mph from us to international namespace
TODO distinguish units with different names for same values
2020-01-12 21:34:36 +01:00
Andy Little 283e9d81a3 Split the various non-si length units into their own namespaces.
new namespaces are
international ( combination of us and imperial + Canada etc)
iau  (https://www.iau.org/
imperial ( old imperial units)
typographical ( for sizes of printing fonts etc)

These namespace are based on some research , mainly on wikipedia.
Look in src/include/units/physical/si/length.h to see links to see the references to documentation justifying the change.

Unfortunately there are 3 foot units for example, an old imperial version, an old us version and an international version, which is more recent and attempts to unify the two previous ones. All versions have slight changes in value, so I opted to use the international version
The main change in the layout is that inch,foot and yard have been moved from us to international.

With this modification, I also modified the physical/us/area.hpp, volume.hpp and volume.hpp headers to refer to the international units.
This may not be correct, but if the modified us::foot (rather than international foot is used as a basis for these units, then
there is a ratio integer overflow during compilation, probably due to taking 3rd power of a ratio. After this commit. I will try to show that on another branch.
2020-01-12 21:34:36 +01:00
Mateusz Pusz a01c811f5f Square and cubic UDLs renamed 2020-01-09 10:03:41 +01:00
Mateusz Pusz 159e2c1c02 ratio_text improved to omit den == 1 for exp != 0 2019-12-29 17:19:55 +01:00
Mateusz Pusz e7f37e4e33 CGS fmt tests added 2019-12-29 17:06:03 +01:00
Mateusz Pusz 17e6b0d75d Small refactoring of new ratio (resolves #14) 2019-12-28 18:59:53 +01:00
Oliver Schönrock 0ad78fe753 small changes based on code review 2019-12-28 17:59:47 +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 594f92241a tonne added 2019-12-26 10:27:20 +01:00
Mateusz Pusz 2a7f2efa15 hectometre and hectare added 2019-12-26 10:20:30 +01:00
Mateusz Pusz 70fbf300b4 astronomical unit added 2019-12-26 10:11:12 +01:00
Mateusz Pusz 15e148381d decimetre and litre added 2019-12-26 10:07:02 +01:00
Mateusz Pusz 22fabb5a1b day unit added 2019-12-26 09:59:05 +01:00
Mateusz Pusz 81b1ba3162 fixed_string_test added 2019-12-26 09:49:39 +01:00
Mateusz Pusz 69974f82cd Floating-point UDLs removed from fmt_test 2019-12-23 13:23:23 +01:00
Mateusz Pusz 758c05ea15 quantity_cast fmt tests added 2019-12-23 13:22:37 +01:00
Mateusz Pusz 2abe429ba7 dimensions_concepts_test added 2019-12-17 22:26:01 +01:00
Mateusz Pusz 80a13b1a94 US system isolated from SI 2019-12-17 12:29:19 +01:00
Mateusz Pusz 6596c15238 scaled_unit template parameters order fixed (sorry Oliver) 2019-12-14 21:16:15 +01:00
Mateusz Pusz 8d1eb4c415 derived_dimension code split to a few smaller files 2019-12-14 12:23:47 +01:00
Mateusz Pusz b1b63e1b3a 2 parital specializations of a derived_dimension split to different types 2019-12-14 11:44:56 +01:00
Mateusz Pusz 156ab7ae7f Unknown dimension assert added to quantity_test 2019-12-12 15:39:04 +01:00
Mateusz Pusz 6765054e5d More CGS tests added 2019-12-12 15:37:52 +01:00
Mateusz Pusz 12b67923bc CGS tests added 2019-12-11 16:20:08 +01:00
Mateusz Pusz a10660d065 More SI tests added 2019-12-11 13:55:58 +01:00
Mateusz Pusz bc1901f4f0 Text formatting enabled + directory tree refactoring 2019-12-11 08:07:13 +01:00
Mateusz Pusz 8ffc46ba75 CGS support added 2019-12-09 17:19:58 +01:00
Mateusz Pusz d465d47803 range-v3 dependency removed for gcc-10 2019-12-08 16:09:00 +01:00
Mateusz Pusz 2c29af9670 Custom unit and data tests enabled 2019-12-07 18:33:55 +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 33f14f39f3 math_test enabled 2019-12-06 12:56:44 +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 c48bfe2098 quantity refactored and quantity_test enabled 2019-12-04 17:46:19 +01:00
Mateusz Pusz 0986d1e812 dimension_test enabled 2019-12-01 20:00:08 +01:00
Mateusz Pusz fa9b7db9d5 type_list_test enabled 2019-12-01 19:56:23 +01:00
Mateusz Pusz 1b4e8a2127 Units and dimensions redesigned 2019-12-01 19:47:58 +01:00
Mateusz Pusz 65ea59edbb digital_information_test renamed to workaround the issue with vscode test explorer 2019-11-28 23:01:06 +01:00
Mateusz Pusz b9dd6ab440 my_value compilation fixed 2019-11-16 18:29:56 +01:00
Mateusz Pusz 57e464cc99 quantity constraints refactored 2019-11-15 20:20:25 +01:00
Mateusz Pusz ff656620e9 fmt support for sign added 2019-11-12 19:46:15 +01:00
Mateusz Pusz 6d9cb8197f fmt fill and allign support added 2019-11-12 16:55:11 +01:00
Mateusz Pusz 83edb46de8 coherent_derived_unit symbol synthetizing fixed 2019-11-10 19:51:25 +01:00
Mateusz Pusz 9a96235e6c Synthesizing unit symbols in deduced_derived_unit support added (resolves #13) 2019-11-10 16:55:16 +00:00
Mateusz Pusz 03e3691d47 More text output tests added 2019-11-09 21:01:37 +00:00
Mateusz Pusz 2328a26992 Downcasting support added to quantity_cast (resolves #26) 2019-11-09 14:42:06 +00:00