Commit Graph
280 Commits
Author SHA1 Message Date
Mateusz Pusz 38fb9911a9 refactor: 💥 ! " ⋅ " replaced with "⋅" in derived unit symbols 2022-05-24 12:56:14 +02:00
Mateusz Pusz 768f400cc3 test: quantity CTAD tests enabled only for the newest compilers 2022-05-23 09:56:45 +02:00
Mateusz Pusz 4498adce7c test: test for new quantity CTAD guide added 2022-05-22 19:49:10 +02:00
Mateusz Pusz 13f03bfe70 feat: luminous_flux support added 2022-05-13 14:31:13 +02: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
Mateusz Pusz 4c60447a28 Merge branch 'master' into downcast_mode_off 2022-05-09 19:12:02 +02:00
Mateusz Pusz ffa0f321f9 fix: shadowing compilation errors on MSVC fixed 2022-05-06 10:00:39 +02:00
Mateusz Pusz 4361cb874e fix: hectare definition fixed to be a prefixed version of are + other units
Relates to #359
2022-04-27 19:32:21 +02:00
Mateusz Pusz 56cee31a67 fix: si::hep::dim_momentum duplicated definition fixed 2022-04-24 19:52:07 +02:00
Chip Hogg d7681e188e Support seamless interop between ratio and rational Magnitude
We provide two new functions, `numerator(m)` and `denominator(m)`, for a
Magnitude `m`.  They fulfill the following conditions:

1. `numerator(m)` and `denominator(m)` are always integer Magnitudes.
2. If `m` is rational, then `m == numerator(m) / denominator(m)`.

If `m` is _not_ rational, then the numerator and denominator are not
especially meaningful (there is no uniquely defined "leftover irrational
part").  However, we choose a convention that matches how humans would
write a mixed number.  For example, sqrt(27/16) would have a numerator
of 3, denominator of 4, and a "leftover part" of sqrt(3), matching the
"human" way of writing this as [(3 * sqrt(3)) / 4].  This has no use
yet, but it may later be useful in printing the Magnitude of an
anonymous Unit for end users.

To further reduce friction for the upcoming migration, we provide an
implicit conversion from a Magnitude to a `ratio`.  We restrict this
operation to rational Magnitudes, and guard this with a `static_assert`.
2022-04-05 23:03:44 +00:00
Mateusz Pusz b221dace3f style: clang-format applied to the remaining files 2022-04-02 21:36:42 +02:00
Markus Hofbauer cf7a7ed17a check: run pre-commit on all files 2022-04-02 18:58:23 +02:00
Johel Ernesto Guerrero Peña 146f1d1c83 fix: improve downcast mode off 2022-03-28 10:58:02 -04:00
Mateusz Pusz 63f3dd2be6 Merge pull request #344 from JohelEGP/quotient_remainder_theorem
test(static): simplify quotient_remainder_theorem test cases
2022-03-22 10:04:49 +01:00
Johel Ernesto Guerrero Peña feb1a0b860 test(static): simplify quotient_remainder_theorem test cases 2022-03-21 14:29:50 -04:00
Mateusz Pusz 3729a9fe93 Merge pull request #337 from chiphogg/chiphogg/prime-wheel
Use wheel factorization for prime numbers
2022-03-21 10:37:05 +01:00
Chip Hogg c339383873 Convert names to standard_case 2022-03-19 16:07:39 +00:00
Chip Hogg 48b6280486 Merge branch 'master' into chiphogg/prime-wheel 2022-03-19 16:01:32 +00:00
Chip Hogg a99e5f9032 Switch tests to use top-level, anonymous namespace 2022-03-19 15:54:29 +00:00
Chip Hogg 28c4fe3c08 Run clang-format-15 on changed files 2022-03-19 14:29:11 +00:00
Chip Hogg 1e8460d401 Revert "Try upping the basis size further"
This reverts commit 87073856a7.
It didn't fix the problem, and it caused some new ones.  We need a
different approach.
2022-03-19 13:21:47 +00:00
Markus Hofbauer 4c127797da check: run pre-commit on all files 2022-03-18 16:12:21 +01:00
Mateusz PuszandJohel Ernesto Guerrero Peña 6d82ddebbc Update test/unit_test/static/quantity_kind_test.cpp
Co-authored-by: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
2022-03-18 08:21:15 +01:00
Mateusz Pusz 144f6951c0 style: all files refromatted with clang-format 2022-03-17 23:59:48 +01:00
Chip Hogg 87073856a7 Try upping the basis size further
We are well into a regime of diminishing returns, but we'd better start
by seeing if the easy thing works.  Besides, setting this to 7 trips the
step limit in _generating_ the algorithm!
2022-03-12 18:56:26 +00:00
Chip Hogg 73a56115a1 Fix wheel factorization algorithm 2022-03-11 03:42:19 +00:00
Chip Hogg 24b284fcbb Add tests to support claims in comment 2022-03-10 23:41:36 +00:00
Chip Hogg 04b80f0827 Use wheel factorization for prime numbers
Certain existing units in the library require very large prime
numbers---so large, in fact, that our naive trial division hits the
_iteration limit_ for `constexpr` loops.  We don't want to force users
to provide a compiler option override, so we'd better find another way.

The solution is to use the "wheel factorization" algorithm:
https://en.wikipedia.org/wiki/Wheel_factorization

This lets us skip most composite numbers in our trial division.  The
implementation presented here is configurable in terms of the size of
the "basis" of primes we use.  Bigger bases let us skip more primes, but
at the cost of storing more numbers.  Fortunately, it turns out that N=3
was good enough for our purposes.
2022-03-10 23:29:02 +00:00
Johel Ernesto Guerrero Peña 3f145a25db refactor: update hacks for LLVM 15 2022-02-07 21:07:22 -04:00
Frank Dischner 774dd91686 Add tests for FPS cubic yard 2022-01-23 21:52:23 -06:00
Chip Hogg a80378cae8 Support addition and negation in ratio 2021-12-29 21:21:57 -05:00
Johel Ernesto Guerrero Peña 4efed3c6d4 refactor: update Clang 14 to not require range-v3 (#321)
* Revert "refactor: update hacks for LLVM 14"

This reverts commit d142844de7.

* refactor: update Clang 14 to not require range-v3
2021-12-13 10:01:16 +01:00
Mateusz Pusz 571df5ed33 feat: conversion from quantity_point to std::chrono::time_point added
Refers #316
2021-11-23 14:37:08 +01:00
Mateusz Pusz af928dd0c7 feat: conversion helpers from mp-units to std::chrono types added
Resolves #316
2021-11-23 11:17:47 +01:00
Markus Hofbauer 4cd90674d5 Feat: Round (#313)
* feat: round

* add more constraints for round

* overload round for quantity

* fix clang tidy

* Validate types before return
2021-11-15 18:53:15 +01:00
Markus Hofbauer 50b9050d6b Feat: Overloads for floor and ceil accepting quantities (#314)
* feat: overloads for floor and ceil accepting quantities

* require same type for dim and rep

* be specific for msvc
2021-11-15 12:23:28 +01:00
Markus Hofbauer b881b56480 feat: first draft ceil 2021-11-13 16:50:55 +01:00
Markus Hofbauer e82bfa23a5 Feat: Floor (#309)
* feat: first draft floor

* apply review feedback and move to desired files

* implement floor considering float types

* reduce code duplication

* apply review feedback and improve docstring

* enable static floor tests for gcc only

* Use recommended feature-test macro

* add floor runtime unittests

* apply review feedback

* make lambda const
2021-11-13 12:17:43 +01:00
Mateusz Pusz f9fb6cc8b3 build: projectPrefix usage added 2021-11-05 23:35:30 +01:00
Mateusz Pusz ca3d111579 fix: CTAD test disabled for most of the compilers 2021-10-20 20:18:15 +02:00
Mateusz Pusz 240ec3a460 build: CTAD for quantity is not supported by clang 2021-10-20 19:58:31 +02:00
Mateusz Pusz b7b8a0bf93 fix: CTAD for aliases fixed 2021-10-20 18:52:13 +02:00
Mateusz Pusz 620835db97 test: Numeric rounding error commented out 2021-09-10 08:08:02 +02:00
Mateusz Pusz 120d863c40 test: derived_quantity-related compilation error fixed 2021-09-09 09:26:23 +02:00
rstein cc5318e5cc refactored HEP units into separate files and corrected namespace where necessary 2021-08-04 13:46:48 +02:00
Ralph J. Steinhagen 322cde70b9 added HEP specific units and definitions
in accordance with https://www.bipm.org/documents/20126/41483022/SI-Brochure-9.pdf#page=147

see also disccusion thread #292
2021-08-03 10:56:47 +02:00
Mateusz Pusz ed5749a52b refactor: quantity op+() and op-() reimplemented in terms of reference rather then quantity types
`common_quantity`, `common_quantity_for`, `common_quantity_point`, `common_quantity_kind`, and `common_quantity_point_kind` removed

Resolves #290
2021-07-27 14:40:05 +02:00