#include <iostream>
#include <string>
#include <vector>
struct Action_options {
};
{
std::cout <<
"Usage: quartic [OPTION] <E> <alpha> <dim>\n\n"
"Calculate action for one-dimensional quartic potential\n"
"parameterized by E and alpha.\n\n"
"Example: quartic 1.0 0.6 3\n\n"
"Options:\n"
" -h, --help print this help message\n"
" -v, --verbose produce verbose output"
<< std::endl;
}
bool starts_with(
const std::string& option,
const std::string& prefix)
{
return !option.compare(0, prefix.size(), prefix);
}
Action_options& options)
{
const auto n_positional_args = args.size();
if (n_positional_args == 0) {
throw Setup_error(
"value of E must be provided");
} else if (n_positional_args == 1) {
throw Setup_error(
"value of alpha must be provided");
} else if (n_positional_args == 2) {
throw Setup_error(
"number of dimensions must be provided");
} else if (n_positional_args > 3) {
throw Setup_error(
"unrecognized command line argument '"
+ args[3] + "'");
}
try {
options.E = std::stod(args[0]);
} catch (const std::invalid_argument& e) {
throw Setup_error(
"invalid value for E, '" + args[0] + "'");
}
try {
options.alpha = std::stod(args[1]);
} catch (const std::invalid_argument& e) {
throw Setup_error(
"invalid value for alpha, '" + args[1] + "'");
}
try {
options.dim = std::stoi(args[2]);
} catch (const std::invalid_argument& e) {
throw Setup_error(
"invalid number of dimensions '" + args[2] + "'");
}
}
{
Action_options options;
std::vector<std::string> positional_args;
int i = 1;
while (i < argc) {
const std::string opt(argv[i++]);
positional_args.push_back(opt);
continue;
}
if (opt == "-h" || opt == "--help") {
exit(EXIT_SUCCESS);
}
if (opt == "-v" || opt == "--verbose") {
options.verbose = true;
continue;
}
throw Setup_error(
"unrecognized command line argument '" + opt + "'");
}
return options;
}
}
int main(
int argc,
const char* argv[])
{
if (argc == 1) {
std::cerr << "Usage: quartic [OPTION] <E> <alpha> <dim>\n"
<< "Try 'quartic --help' for more information."
<< std::endl;
return EXIT_FAILURE;
}
int exit_code = 0;
try {
if (options.verbose) {
}
profiler.
solve(potential, false_min, true_min, barrier,
options.dim, Shooting::Solver_options::Compute_action);
std::cout << "# E = " << options.E
<< ", alpha = " << options.alpha
<< ", dim = " << options.dim
<< std::endl;
}
catch (
const Error& e) {
std::cerr << "Error: " << e.what() << std::endl;
exit_code = EXIT_FAILURE;
} catch (...) {
std::cerr << "Error: unrecognized error occurred."
<< std::endl;
exit_code = EXIT_FAILURE;
}
return exit_code;
}