Skip to content

Commit 112f377

Browse files
committed
Merge branch 'master' of https://github.com/hurchalla/factoring
2 parents 612efd3 + 8efe255 commit 112f377

File tree

21 files changed

+275
-162
lines changed

21 files changed

+275
-162
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The goal for EPR was to create a correct and easy to use library with extremely
1414

1515
## Requirements
1616

17-
The EPR library requires compiler support for C++17 (if you are not using CMake, you may need to specify the option *-std="c++17"* when compiling). Compilers that are confirmed to build the library without warnings or errors on x86 include clang6, clang10, gcc7, gcc10, intel compiler 19, and Microsoft Visual C++ 2017 and 2019. The library is intended for use on all architectures (e.g. x86/64, ARM, RISC-V, Power), but has been tested only on x86/x64.
17+
The EPR library requires compiler support for C++17 (if you are not using CMake, you may need to specify the option *-std="c++17"* when compiling). Compilers that are confirmed to build the library without warnings or errors on x86 include clang6, clang10, clang18, gcc7, gcc10, gcc13, intel compiler 19, and Microsoft Visual C++ 2017, 2019, 2022. The library is intended for use on all architectures (e.g. x86/64, ARM, RISC-V, Power), but has been tested only on x86/x64.
1818

1919
For good performance you absolutely *must* ensure that the standard macro NDEBUG (see <cassert>) is defined when compiling.
2020

@@ -67,14 +67,15 @@ It may help to see a simple [example](examples/example_without_cmake).
6767

6868
The API consists of five header files in total (all the headers that are not under the *detail* folder). These files are the three general purpose files *factorize.h*, *is_prime.h*, *greatest_common_divisor.h*, and in the resource_intensive_api folder, the two special purpose files *factorize_intensive_uint32.h* and *IsPrimeIntensive.h*. Please view these files for their documentation. A quick summary of the functions is provided below; in all cases T is a template parameter of integral type.
6969

70-
*hurchalla::factorize(T x, int& num_factors)*. Returns a std::array containing the factors of x.
70+
*hurchalla::factorize(T x, unsigned int& num_factors)*. Returns a std::array containing the factors of x.
7171
*hurchalla::factorize(T x, std::vector& factors)*. Clears a std::vector and fills it with the factors of x.
7272
*hurchalla::greatest_common_divisor(T a, T b)*. Returns the greatest common divisor of a and b.
7373
*hurchalla::is_prime(T x)*. Returns true if x is prime. Otherwise returns false.
7474

7575
(from the resource_intensive_api folder)
76-
*hurchalla::IsPrimeIntensive(T x)*. This is a functor that returns true if x is prime, and otherwise returns false. Depending on the type T, this functor can use a very large amount of memory and can take many seconds to construct. See IsPrimeIntensive.h for details.
77-
*hurchalla::factorize_intensive_uint32(uint32_t x, int& num_factors, const IsPrimeIntensive<uint32_t,true>& ipi)*. Returns a std::array containing the factors of x. Note that the IsPrimeIntensive argument will usually take many seconds for you to construct and will use a large amount of memory. See IsPrimeIntensive.h for details.
76+
*hurchalla::IsPrimeIntensive*. This is a functor called with (T x) that returns true if x is prime, and otherwise returns false. Depending on the type T, this functor can use a very large amount of memory and can take many seconds to construct. See IsPrimeIntensive.h for details.
77+
*hurchalla::factorize_intensive_uint32(uint32_t x, unsigned int& num_factors, const IsPrimeIntensive<uint32_t,true>& ipi)*. Returns a std::array containing the factors of x. Note that the IsPrimeIntensive argument will usually take many seconds for you to construct and will use a large amount of memory. See IsPrimeIntensive.h for details.
78+
*hurchalla::FactorByTable32*. This is a functor called with (uint32_t x) that returns a std::array containing the factors of x. The functor typically takes a few minutes to construct from scratch (i.e. when constructed without a pre-saved table file), since it creates a 1.5GB factor table in memory. To save the table to file, so as to use the file later to quickly construct this functor, the class provides writeTableToFile(). See FactorByTable32.h for details.
7879

7980
## Algorithms
8081

benchmark/benchmark.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void bench_range(T min, T max)
7171
auto t0 = steady_clock::now();
7272

7373
for (T x = max; x > min; x = x-2) {
74-
int num_factors;
74+
unsigned int num_factors;
7575
auto arr = hurchalla::factorize(x, num_factors);
7676
// We need to prevent the compiler from completely removing
7777
// the factorize calls due to the array never being used.
@@ -82,7 +82,7 @@ void bench_range(T min, T max)
8282
}
8383
#if 0
8484
std::cout << "the factors of " << x << " are:" << "\n";
85-
for (int j = 0; j < num_factors; ++j)
85+
for (unsigned int j = 0; j < num_factors; ++j)
8686
std::cout << arr[j] << "\n";
8787
#endif
8888
}

examples/example_with_cmake/example.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ int main()
2323
{
2424
unsigned int x = 322u;
2525

26-
int num_factors;
26+
unsigned int num_factors;
2727
auto array = hurchalla::factorize(x, num_factors);
2828
std::cout << "the factors of " << x << " are:" << "\n";
29-
for (int i = 0; i < num_factors; ++i)
29+
for (unsigned int i = 0; i < num_factors; ++i)
3030
std::cout << array[i] << "\n";
3131
return 0;
3232
}

examples/example_without_cmake/example.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ int main()
2323
{
2424
unsigned int x = 322u;
2525

26-
int num_factors;
26+
unsigned int num_factors;
2727
auto array = hurchalla::factorize(x, num_factors);
2828
std::cout << "the factors of " << x << " are:" << "\n";
29-
for (int i = 0; i < num_factors; ++i)
29+
for (unsigned int i = 0; i < num_factors; ++i)
3030
std::cout << array[i] << "\n";
3131
return 0;
3232
}

include/hurchalla/factoring/detail/FactorizeStage2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# include "hurchalla/factoring/detail/PollardRhoBrentTrial.h"
1818
# include "hurchalla/factoring/detail/PollardRhoBrentTrialParallel.h"
1919
# include "hurchalla/factoring/detail/experimental/PollardRhoTrial.h"
20+
# include "hurchalla/factoring/detail/experimental/PollardRhoBrentTrialParallelOpt.h"
21+
# include "hurchalla/factoring/detail/experimental/PollardRhoBrentTrialParallelAlt.h"
2022
#endif
2123
#include "hurchalla/factoring/detail/factorize_wheel210.h"
2224
#include "hurchalla/montgomery_arithmetic/montgomery_form_aliases.h"

0 commit comments

Comments
 (0)