976 Commits

Author SHA1 Message Date
9c140f4b3a feat: explicit constructor now can perform an explicit quantity_spec conversion 2025-06-20 17:10:34 +02:00
35798a0f39 refactor: ostream.h header file made deprecated 2025-06-20 10:40:10 +02:00
50c05bddb3 refactor: format.h header file made deprecated 2025-06-20 09:06:49 +02:00
f18aa18869 refactor: compund assignment and pre-/post-increment operators are now lvalue-qualified member functions 2025-06-19 18:49:21 +02:00
6361daa76f feat: EQUIV{...} replaced with [...] in the text output of common units 2025-06-18 08:53:46 +02:00
13715168b0 test: interconvertible checks removed from units tests 2025-04-29 11:38:03 +02:00
ee02ed4fd1 fix: mag_constant workarounds branches for clang fixed 2025-04-03 08:06:13 +01:00
5a0e350be7 feat: lerp and midpoint for points added 2025-02-13 14:26:51 +01:00
4b1f7cd217 feat: 💥 Representation concept removed 2025-02-12 18:57:06 +01:00
e9c5f7236e feat: ConvertibleWithNumber introduced to improve convertibility of unit one with raw numbers
Resolves #675
2025-02-11 21:28:15 +01:00
836880c3a1 test: quantity character concepts tests for quantities added 2025-02-11 20:58:53 +01:00
47a82f466c refactor: scalar and complex renamed to real_scalar and complex_scalar respectively + concepts refactoring + electromagnetism fixes 2025-02-11 17:26:19 +01:00
9fb08e3c95 feat: electromagnetism.h updated to IEC80000-6-2022 2025-02-11 16:53:40 +01:00
c6e95a9fc7 refactor: limits.h removed and the contents moved to quantity.h and quantity_point.h
Resolves #673
2025-02-06 17:16:12 +01:00
5d4e1aa740 feat: might_store_converted_common_value added to detect conversions overflowing rep
Resolves #670, resolves #671, resolves #658, resolves #303
2025-02-06 15:28:55 +01:00
e5d2b95a1b fix: std::isnan compilation fixed for freestanding and C++20 2025-02-05 18:16:15 +01:00
88439828a5 feat: std::numeric_limits support added
Resolves #408
2025-02-05 18:04:43 +01:00
8d2dddb8b6 refactor: less, ceil, and round refactored and improved + more unit tests for round
Resolves #672
2025-02-05 12:10:36 +01:00
0b14d69539 feat: quantity::one() removed
Related to #408
2025-02-05 12:08:32 +01:00
7c54067a55 fix: type ordering in a unit test fixed for gcc 2025-01-21 12:53:57 +01:00
becb456da5 fix: missing get_common_unit() overload added
Resolves #666
2025-01-21 12:37:54 +01:00
44cbf82012 Fix clang-format error caused by missing to run pre-commit. 2025-01-11 17:41:56 +01:00
f6940e224c Add new tests for base dimension of quanties of the same kind and for derived dimensions. Remove temporary helper objects. 2025-01-11 17:31:03 +01:00
c758cb37e6 Add static tests for concept DimensionOf 2025-01-04 16:32:30 +01:00
06cbfae3b3 feat: quantity_spec conversions improved 2024-12-28 14:02:03 +01:00
db64534f34 test: tests to check if quantity satisfies Scalar 2024-12-01 14:15:56 +01:00
f0885f8027 feat: scaled units are now enclosed in parenthesis (...) instead of brackets [...] 2024-11-29 12:17:53 +01:00
52e95f9b2e test: a few more natural units tests added 2024-11-29 11:11:13 +01:00
a223c08a39 refactor: multiplication and division by scalars was a bad idea for Complex and Vector 2024-11-28 23:02:11 +01:00
465f88d500 refactor: 💥 is_XXX customization points for representation types removed 2024-11-26 14:48:08 +01:00
b77aa52355 refactor: absolute renamed to point
Resolves #645
2024-11-24 14:19:16 +01:00
9a0f7a25dd test: tests for dimensionless quantities static data members 2024-11-23 19:35:59 +01:00
0c09008671 fix: clang is too stupid to provide a deprecation warning for text_encoding 2024-11-21 11:25:57 +01:00
16e816d4cb refactor: 💥 Magnitude renamed to UnitMagnitude and magnitude to unit_magnitude 2024-11-21 08:58:18 +01:00
8ae21ffcc9 refactor: 💥 text_encoding renamed to character_set 2024-11-19 14:44:59 +01:00
623930ccee refactor: convertible_impl refactored to convertible + results caching 2024-11-16 22:11:59 +01:00
4f8e959b5c fix(test): shadowing warnings on gcc fixed 2024-11-16 08:28:39 +01:00
4aaebb9426 Merge branch 'master' of github.com:mpusz/units 2024-11-16 08:07:33 +01:00
de68b3a9f1 Replace old factoring with Baillie-PSW 2024-11-15 13:30:05 -05:00
3b586a685f Implement Baillie-PSW 2024-11-15 13:30:05 -05:00
9e8dfec265 Add the Strong Lucas Probable Prime test
This is more involved than the Miller-Rabin test, but we can tame the
complexity by breaking it down into helper functions, performing tasks
such as:

- Increment the index of the (U_k, V_k) sequence elements by one.
- Double the index of the (U_k, V_k) sequence elements.
- Find an appropriate D parameter.

etc.

With these helpers, the algorithm becomes straightforward (see, for
instance,
https://en.wikipedia.org/wiki/Lucas_pseudoprime#Strong_Lucas_pseudoprimes).
We start by ruling out perfect squares (because if we don't, then the
search for `D` will never terminate).  Then we find our `D`, and
decompose `n + 1` into `s` and `d` parameters (exactly as we did for
Miller-Rabin, except there we used `n - 1`).  At this point, the strong
test is easy: check whether `U_d` is 0, then check `V_d`, as well as `V`
for all successive doublings of the index less than `s`.

A similar testing strategy as for the Miller Rabin gives us sufficient
confidence.

1. Test that we get small primes right.
2. Test that we get known pseudoprimes "correctly wrong".
3. Test some really big primes.

(Remember, a probable prime test must mark every actual prime as
"probably prime".)

Helps #509.
2024-11-15 10:53:26 -05:00
c901b73ee5 Merge pull request #639 from chiphogg/chiphogg/jacobi#509
Add utilities to make Strong Lucas tests easier
2024-11-15 15:57:09 +01:00
26639dab34 Add some more 2024-11-15 09:39:39 -05:00
08e94171cb test: vector quantities unit tests addded 2024-11-15 12:59:18 +01:00
d56ffc08b8 Add utilities to make Strong Lucas tests easier
The Strong Lucas test coming in the next PR will already be complicated
enough.  It'll be convenient, and less distracting, if we already have
functions for certain operations we'll need.

One thing we'll need to do is detect inputs that are perfect squares.
Fortunately, this is pretty easy to do robustly and quickly, with
Newton's method.  We _don't_ want to use `std::sqrt`, because that takes
us into the floating point domain for no good reason, which could give
us wrong answers for larger integers.

The other thing we need is Jacobi symbols.  These are a lot more
obscure, but thankfully, still resonably straightforward to compute.
The Wikipedia page (https://en.wikipedia.org/wiki/Jacobi_symbol) has a
good explanation, and in particular, good instructions for computing
values.

With these utilities in place, the Strong Lucas code should be easier to
review.
2024-11-14 20:14:20 -05:00
1581fa59ad test: extend concepts tests with cartesian_vector as a representation 2024-11-14 20:42:21 +01:00
2cf64f20c5 fix: cartesian_vector convertibility tests fixed 2024-11-14 20:40:08 +01:00
a7cf015a3e feat: add compound assignment operators to cartesian_vector 2024-11-14 20:38:50 +01:00
4b5d37e83e feat: constructors of cartesian_vector refactored 2024-11-14 20:30:12 +01:00
cfd9ddb675 Add Miller-Rabin probable prime test
This can mark a number as either "probably prime", or "definitely
composite".  The first parameter is the base, and the second is the
number to test.

Future PRs will build up the Strong Lucas test which complements this,
and then form the Baillie-PSW test by composing the two.

Helps #506.
2024-11-13 19:56:05 -05:00