diff --git a/include/boost/integer/extended_euclidean.hpp b/include/boost/integer/extended_euclidean.hpp index fe67853..4b0e028 100644 --- a/include/boost/integer/extended_euclidean.hpp +++ b/include/boost/integer/extended_euclidean.hpp @@ -14,6 +14,7 @@ namespace boost { namespace integer { // From "The Joy of Factoring", Algorithm 2.7. // Should the tuple be a named tuple? Is that possible? // Solves mx + ny = gcd(m,n). Returns tuple with (gcd(m,n), x, y). +// Is this the natural ordering?, or must people simply have to read the docs? template std::tuple extended_euclidean(Z m, Z n) { diff --git a/include/boost/integer/mod_inverse.hpp b/include/boost/integer/mod_inverse.hpp index 9d357d3..8bd2bb8 100644 --- a/include/boost/integer/mod_inverse.hpp +++ b/include/boost/integer/mod_inverse.hpp @@ -13,11 +13,11 @@ namespace boost { namespace integer { // From "The Joy of Factoring", Algorithm 2.7. -// The name is a bit verbose. Here's some others names I've found for this function: +// Here's some others names I've found for this function: // PowerMod[a, -1, m] (Mathematica) // mpz_invert (gmplib) // modinv (some dude on stackoverflow) -// Would modular_inverse be sometimes mistaken as the modular *additive* inverse? +// Would mod_inverse be sometimes mistaken as the modular *additive* inverse? template boost::optional mod_inverse(Z a, Z modulus) { diff --git a/test/extended_euclidean_test.cpp b/test/extended_euclidean_test.cpp index f3af897..1778eb9 100644 --- a/test/extended_euclidean_test.cpp +++ b/test/extended_euclidean_test.cpp @@ -17,6 +17,7 @@ using boost::integer::gcd; template void test_extended_euclidean() { + std::cout << "Testing the extended Euclidean algorithm on type " << boost::typeindex::type_id().pretty_name() << "\n"; Z max_arg = 1000; for (Z m = 1; m < max_arg; ++m) { @@ -34,6 +35,7 @@ void test_extended_euclidean() BOOST_AUTO_TEST_CASE(extended_euclidean_test) { + test_extended_euclidean(); test_extended_euclidean(); test_extended_euclidean(); test_extended_euclidean(); diff --git a/test/mod_inverse_test.cpp b/test/mod_inverse_test.cpp index 240ebf3..8d117c8 100644 --- a/test/mod_inverse_test.cpp +++ b/test/mod_inverse_test.cpp @@ -4,19 +4,21 @@ * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#define BOOST_TEST_MODULE modular_multiplicative_inverse_test +#define BOOST_TEST_MODULE mod_inverse_test #include #include #include #include using boost::multiprecision::int128_t; +using boost::multiprecision::int256_t; using boost::integer::mod_inverse; using boost::integer::gcd; template void test_mod_inverse() { + std::cout << "Testing the modular multiplicative inverse on type " << boost::typeindex::type_id().pretty_name() << "\n"; Z max_arg = 1000; for (Z modulus = 2; modulus < max_arg; ++modulus) { @@ -39,10 +41,12 @@ void test_mod_inverse() } } -BOOST_AUTO_TEST_CASE(extended_euclidean_test) +BOOST_AUTO_TEST_CASE(mod_inverse_test) { + test_mod_inverse(); test_mod_inverse(); test_mod_inverse(); test_mod_inverse(); test_mod_inverse(); + test_mod_inverse(); }