Commit Graph
121 Commits
Author SHA1 Message Date
Mateusz Pusz 9f94a73bba Custom is_same implementation added 2020-06-29 20:30:59 +02:00
Mateusz Pusz 7eccef78a9 is_instantiation renamed to is_instantiation_of 2020-06-29 20:28:10 +02:00
Mateusz Pusz d171f5451e NTTP ratio support added (resolves #49) 2020-06-27 19:15:46 +02:00
Mateusz Pusz f55eacfa85 glide_computer example added 2020-06-21 10:37:45 +02:00
Johel Ernesto Guerrero Peña 75119eef3f feat: quantity_point 2020-06-17 15:31:22 +02:00
Mateusz Pusz 10f93b5386 Compilation on gcc-9 fixed 2020-05-28 20:45:15 +02:00
Mateusz Pusz 86b9177816 Specialize common_type to satisfy comparison concepts (resolves #113) 2020-05-28 20:19:05 +02:00
Mateusz Pusz 77a94b6d73 Ccompilation error fixed on gcc-9 2020-05-28 13:37:20 +02:00
Mateusz Pusz e58c8054bc Doxygen documentation added 2020-05-13 15:33:29 +02:00
Mateusz Pusz ce301748dd Velocity renamed to Speed (resolves #103) 2020-05-10 17:31:47 +02:00
Mateusz Pusz d19825e14c Numeric concepts removed from repo (no longer used) 2020-03-28 12:08:37 +01:00
Mateusz Pusz f75a69da9a Direct namespace usage removed from fixed_string 2020-03-27 15:21:42 +01:00
Ramzi Sabra 36bee5a8c3 fixed dot product symbol 2020-03-27 10:03:59 +01:00
Ramzi Sabra e0263c554d added ASCII character validation; added ASCII-only superscripts, scientific notation, dot product 2020-03-27 10:03:59 +01:00
Ramzi Sabra f6d9a1cbda removed c_str(), size(), operator<< abstractions from basic_symbol_text 2020-03-27 10:03:59 +01:00
Ramzi Sabra e9272ac108 added ASCII-only format output support 2020-03-27 10:03:59 +01:00
Mateusz Pusz 034f239f96 PrefixType renamed to PrefixFamily + units hierarchy PNG fixed 2020-03-19 14:44:56 +01:00
Mateusz Pusz c33f6f2d59 ostream width, align and fill added 2020-03-19 09:23:27 +01:00
Mateusz Pusz d2e49b25f7 Clang uses the Ranges-v3 concepts 2020-03-17 17:12:01 +01:00
Mateusz Pusz 0c02f94d29 Printing of uknown non-coherent units fixed 2020-02-24 20:45:47 +01:00
Mateusz Pusz e7756bf4eb Printing order of base units according to the recipe fixed 2020-02-24 15:18:37 +01:00
Mateusz Pusz 0eb2f404be clang-format applied to type_list 2020-02-24 15:17:03 +01:00
Mateusz Pusz c745bebffd type_list_join added 2020-02-24 15:15:46 +01:00
Oliver Schönrock ef862c9f69 include what we use and use system header syntax
don't show 10^0 when den != 0
2020-02-22 22:08:36 +01:00
Oliver Schönrock 424f0512c1 hack fix?! 2020-02-22 22:08:36 +01:00
Mateusz Pusz 0c89df3980 unknown_unit renamed to unknown_coherent_unit 2020-02-22 09:37:40 +01:00
Oliver Schönrock 834d1fa09d extending the range of operator* for incoherent units with large num/den
this improves the situation for #55 (doesn't solve it outright)
motivating examples which now work are:
1q_mi * 1q_mi * 1q_mi
1q_au * 1q_au
tests added and docs updated
2020-02-20 23:46:55 +01:00
Oliver Schönrock 39a2c2de0e employing more mathemtaically correct ratio_gcd calc (for common ratio)
really finds the maximum common ration as opposed to previous algo which
simplified on the exp part of the ratio by using std::min
most of new code credit to Conor Williams
discussion and additional doc here:
https://github.com/mpusz/units/issues/62#issuecomment-588152833
test case was 1yd + 1in = 37in => added as a test
commenting out unusued ratio_add and its tests
if to be reintroduced, should also use the new gcd routines
additonal change was required to check in `safe_divisible` concept
den=1 is not sufficient anymore. reusing new gcd routines
moved ratio nomalize and new gcd routines into new, separate bits/ratio_maths.h
this resolves #62
2020-02-20 19:59:12 +01:00
Oliver Schönrock 0566cc631d implementing units::ratio_add and tests
not yet used in src/include/units/bits/dim_consolidate.h
because it breaks and cascades (due to new exponent we think)
2020-02-16 14:53:06 +01:00
Mateusz Pusz d832b3a462 basic_fixed_string op== improved 2020-02-12 09:55:28 +01:00
Mateusz Pusz 3be8ee921e Starship improvements after the latest gcc fixes 2020-02-12 09:48:04 +01:00
Mateusz Pusz 037503cbc6 deduced_unit fixed + unit test for mass unit added 2020-02-10 20:35:32 +01:00
Mateusz Pusz 78350ed94b same_as remplaced with is_same_v in if constexpr 2020-02-08 20:11:20 +01:00
Mateusz Pusz 0354c56ac2 clang-format applied to a downcasting header 2020-01-31 17:03:35 +01:00
Mateusz Pusz 645570ff57 Library updated to the latest cmake common tools 2020-01-31 17:02:27 +01:00
Mateusz Pusz b27a422076 Preeliminary clang support added 2020-01-28 08:37:43 +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 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 eef6371ab4 Missing fixed_string comparison operators added 2019-12-26 14:03:55 +01:00
Mateusz Pusz bf5762dbbb Initial support for printing multiple negative exponents added 2019-12-26 12:07:08 +01:00
Mateusz Pusz 7cad312b55 fixed_string refactored 2019-12-23 13:21:48 +01:00
Mateusz Pusz bc8c31caa5 is_derived_from_instantiation fixed 2019-12-17 22:18:52 +01:00
Mateusz Pusz d5f7de8ecb unknown_dimension definition changed to contain at least one exponent 2019-12-17 08:36:31 +01:00
Mateusz Pusz 00d863508d base_dimension refactored
- now stores dimension's symbol rather than its name
- temperature and current renamed to exactly match their names in SI
2019-12-16 15:58:41 +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 fbf3ef8c4f Most of concepts moved to a new file + quantity.h split to smaller pieces 2019-12-12 13:17:31 +01:00