Commit Graph
1101 Commits
Author SHA1 Message Date
Chip Hogg 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
Chip Hogg 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
Mateusz Pusz f5b9288825 fix: MP_UNITS_NONCONST_TYPE disabled for gcc-12 2024-11-13 22:48:19 +01:00
Mateusz Pusz 2590aa4b80 refactor: MP_UNITS_NONCONST_TYPE introduced to benefit from the C++23 feature 2024-11-13 21:13:22 +01:00
Chip Hogg b99faf051b Merge branch 'master' into chiphogg/mod#509 2024-11-13 08:41:52 -05:00
Mateusz Pusz 1ee824423e refactor: usage of v for the function argument name changed to prevent shadowing errors 2024-11-12 16:22:14 +01:00
Mateusz Pusz 6c3c1fe5f7 feat: cartesian_vector added 2024-11-12 14:34:18 +01:00
Mateusz Pusz e4044f0e4b feat: ComplexRepresentation extended with complex operations 2024-11-12 14:20:19 +01:00
Chip Hogg 6c982d4202 Use std:: prefix and mpu's EXPECTS_DEBUG macro 2024-11-12 08:16:53 -05:00
Mateusz Pusz 8ec2f94ae2 fix: make_reference should skip only the exact kinds deduced from a unit 2024-11-11 23:36:58 +01:00
Chip Hogg 1110e53e38 Never mind
Apparently, that's not the right approach.
2024-11-11 14:34:47 -05:00
Chip Hogg a6d34b40a6 Include <bits/types.h>
Apparently some freestanding builds need this?
2024-11-11 13:35:37 -05:00
Chip Hogg 8a7483f7ea Add helpers for modular arithmetic
The prime-testing techniques we will use (Miller-Rabin, Strong Lucas)
all make heavy usage of modular arithmetic.  Therefore, we lay those
foundations here, adding utilities to perform the basic arithmetic
operations robustly.

Since these are internal-only helper functions, we don't bother checking
the preconditions, although we state them clearly in the contract
comment for each utility.  After C++26, we could add contracts for
these.

Helps #509.
2024-11-11 12:55:41 -05:00
Mateusz Pusz 727a898141 feat: derived_XXX are not constrained with SymbolicConstant 2024-11-09 23:03:24 +01:00
Mateusz Pusz a628f1d107 feat: per and power made final 2024-11-09 23:02:49 +01:00
Mateusz Pusz b4810089ec fix: gcc-12 compilation fixed
Resolves #632
2024-11-09 23:02:12 +01:00
Mateusz Pusz 4db913a592 fix: make_magnitude fixed for gcc-12 2024-11-09 20:42:17 +01:00
Mateusz Pusz ca4dbfa9b6 fix: extraneous semicolon removed 2024-11-08 13:39:16 +01:00
Mateusz Pusz 0c46d4ecfe refactor: type_list moved to implementation details 2024-11-08 13:36:43 +01:00
Mateusz Pusz 8423e50777 feat: SymbolicArg applied to expression templates 2024-11-08 13:30:55 +01:00
Mateusz Pusz 1702853893 refactor: SymbolicConstant moved to _expression_template.h_ 2024-11-08 13:27:25 +01:00
Mateusz Pusz 06853b7aeb fix: const was leaking to some SymbolicConstants 2024-11-08 12:57:29 +01:00
Mateusz Pusz da50348115 feat: 💥 RepresentationOf concept now also accepts a QuantitySpec and accepts any representation character for quantity kinds 2024-11-07 18:39:32 +01:00
Mateusz Pusz 75b50b8d2c feat: complex.h added 2024-11-07 10:58:51 +01:00
Mateusz Pusz 8f062bfa87 refactor: mp_units.core defined in terms of core.h 2024-11-07 10:24:28 +01:00
Mateusz Pusz 34816574ca fix: missing core.h added to CMake 2024-11-07 10:23:44 +01:00
Mateusz Pusz 10a82268aa feat: negation requirement added to Representation concepts 2024-11-07 08:49:31 +01:00
Mateusz Pusz 6896d8e086 fix: velocity is now defined in terms of displacement instead of position_vector 2024-11-06 18:46:01 +01:00
Mateusz Pusz c7303cc5fb refactor: representation concepts refactored + some quantities switched to complex 2024-11-05 19:09:16 +01:00
Mateusz Pusz 65a3c80a5f refactor: max used in one of the explode overloads 2024-11-05 08:06:04 +01:00
Mateusz Pusz 43ea6adc64 refactor: TagType renamed to SymbolicConstant 2024-11-05 08:00:10 +01:00
Mateusz Pusz cc25f9b0de refactor: get_complexity refactored to returned maximum complexity of an element (instead of the sum of elements) 2024-11-04 19:13:48 +01:00
Mateusz Pusz 467d9a5558 refactor: get_complexity refactored to be 0-based and not account for a number of arguments in a list 2024-11-04 18:04:01 +01:00
Mateusz Pusz c45df2a4bd fix: convertible_kinds implementation fixed 2024-11-04 18:02:09 +01:00
Mateusz Pusz 5810420277 refactor: 💥 tag types should not expose their members 2024-11-04 09:40:25 +01:00
Mateusz Pusz 8217399a88 fix: QuantityConvertibleTo used in quantity_point compound assignment
Resolves #215
2024-11-03 10:45:10 +01:00
Mateusz Pusz 046a83224e refactor: Forwarding renamed to Mutable
Resolves #215
2024-11-02 22:45:36 +01:00
Mateusz Pusz 80a4d6bc80 refactor: QuantityLikeImpl refactored to conform to API Reference by @JohelEGP 2024-11-02 13:56:49 +01:00
Mateusz Pusz 9d05e31af7 refactor: point_origin_interface::op- cleanup 2024-11-02 13:45:42 +01:00
Mateusz Pusz 8ca8270d2f feat: from now on truncation is not allowed in compound assignment 2024-10-30 08:40:49 +01:00
Mateusz Pusz d8bc0598fe style: clang-format in pre-commit updated to 19.1.2 2024-10-29 15:04:28 +01:00
Mateusz Pusz 9b3bae0f05 fix: compilation fixed after previous commits 2024-10-29 14:49:02 +01:00
Mateusz Pusz 06d9197f44 refactor: explicit cleanup for deduction guides of quantity and quantity_point 2024-10-29 14:06:32 +01:00
Mateusz Pusz c51b6e1f75 refactor: Forwarding concept applied to quantity and quantity_point 2024-10-29 13:56:02 +01:00
Mateusz Pusz 699b0e7c23 refactor: quantity_spec.h cleanup: extraneous detail namespace usage removed 2024-10-29 13:20:15 +01:00
Mateusz Pusz 74325e7965 refactor: per_mille symbol definition syntax changed 2024-10-29 13:15:57 +01:00
Mateusz Pusz 975025f88a refactor: 💥 convertibility traits and concepts refactored to use bool flags instead of wrappers 2024-10-29 13:15:10 +01:00
Mateusz Pusz 7445585db8 fix: compound assignment operations on quantities now behave the same as on the underying representation types
Resolves #137
2024-10-29 09:18:32 +01:00
Mateusz Pusz 797ae2e559 docs: typo in a comment fixed 2024-10-29 08:35:11 +01:00
Mateusz Pusz 08f90ba474 feat: quantity_values are now defined on top of std::chrono::duration_values 2024-10-28 16:08:56 +01:00