-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add options: --RiemannR && --R-inverse
- Loading branch information
1 parent
0702ac5
commit c6906b5
Showing
5 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/// @brief Parse command-line options for the primesieve console | ||
/// (terminal) application. | ||
/// | ||
/// Copyright (C) 2022 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2024 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
|
@@ -44,6 +44,8 @@ enum OptionID | |
OPTION_DISTANCE, | ||
OPTION_PRINT, | ||
OPTION_QUIET, | ||
OPTION_R, | ||
OPTION_R_INVERSE, | ||
OPTION_SIZE, | ||
OPTION_TEST, | ||
OPTION_THREADS, | ||
|
@@ -380,6 +382,9 @@ CmdOptions parseOptions(int argc, char* argv[]) | |
{ "--print", std::make_pair(OPTION_PRINT, OPTIONAL_PARAM) }, | ||
{ "-q", std::make_pair(OPTION_QUIET, NO_PARAM) }, | ||
{ "--quiet", std::make_pair(OPTION_QUIET, NO_PARAM) }, | ||
{ "-R", std::make_pair(OPTION_R, NO_PARAM) }, | ||
{ "--RiemannR", std::make_pair(OPTION_R, NO_PARAM) }, | ||
{ "--R-inverse", std::make_pair(OPTION_R_INVERSE, NO_PARAM) }, | ||
{ "-s", std::make_pair(OPTION_SIZE, REQUIRED_PARAM) }, | ||
{ "--size", std::make_pair(OPTION_SIZE, REQUIRED_PARAM) }, | ||
{ "--test", std::make_pair(OPTION_TEST, NO_PARAM) }, | ||
|
@@ -408,6 +413,8 @@ CmdOptions parseOptions(int argc, char* argv[]) | |
case OPTION_QUIET: opts.quiet = true; break; | ||
case OPTION_NTH_PRIME: opts.nthPrime = true; break; | ||
case OPTION_NO_STATUS: opts.status = false; break; | ||
case OPTION_R: opts.RiemannR = true; break; | ||
case OPTION_R_INVERSE: opts.RiemannR_inverse = true; break; | ||
case OPTION_TIME: opts.time = true; break; | ||
case OPTION_NUMBER: opts.numbers.push_back(opt.getValue<uint64_t>()); break; | ||
case OPTION_HELP: help(/* exitCode */ 0); break; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/// | ||
/// @file cmdoptions.hpp | ||
/// | ||
/// Copyright (C) 2023 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2024 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
|
@@ -21,6 +21,8 @@ struct CmdOptions | |
int threads = 0; | ||
bool quiet = false; | ||
bool nthPrime = false; | ||
bool RiemannR = false; | ||
bool RiemannR_inverse = false; | ||
bool status = true; | ||
bool time = false; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,14 @@ | |
/// @file main.cpp | ||
/// @brief primesieve console application. | ||
/// | ||
/// Copyright (C) 2023 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2024 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
/// | ||
|
||
#include <primesieve/ParallelSieve.hpp> | ||
#include <primesieve/nthPrimeApprox.hpp> | ||
#include <primesieve/Vector.hpp> | ||
#include "cmdoptions.hpp" | ||
|
||
|
@@ -136,6 +137,10 @@ int main(int argc, char* argv[]) | |
|
||
if (opt.nthPrime) | ||
nthPrime(opt); | ||
else if (opt.RiemannR) | ||
std::cout << Ri(opt.numbers[0]) << std::endl; | ||
else if (opt.RiemannR_inverse) | ||
std::cout << Ri_inverse(opt.numbers[0]) << std::endl; | ||
else | ||
sieve(opt); | ||
} | ||
|