24 std::for_each(v.begin(), v.end(),
25 [&s, &delim](
const std::string& elem) { s << elem << delim; });
33 std::map<int, std::string> result;
35 result[0] =
"OK, valid minimum";
36 result[-2] =
"iteration has not converged";
37 result[1] =
"input domain error, e.g sqrt(-1)";
38 result[2] =
"output range error, e.g. exp(1e100)";
39 result[3] =
"invalid pointer";
40 result[4] =
"invalid argument supplied by user";
41 result[5] =
"generic failure";
42 result[6] =
"factorization failed";
43 result[7] =
"sanity check failed - shouldn't happen";
44 result[8] =
"malloc failed";
45 result[9] =
"problem with user-supplied function";
46 result[10] =
"iterative process is out of control";
47 result[11] =
"exceeded max number of iterations";
48 result[12] =
"tried to divide by zero";
49 result[13] =
"user specified an invalid tolerance";
50 result[14] =
"failed to reach the specified tolerance";
51 result[15] =
"underflow";
52 result[16] =
"overflow ";
53 result[17] =
"loss of accuracy";
54 result[18] =
"failed because of roundoff error";
55 result[19] =
"matrix, vector lengths are not conformant";
56 result[20] =
"matrix not square";
57 result[21] =
"apparent singularity detected";
58 result[22] =
"integral or series is divergent";
59 result[23] =
"requested feature is not supported by the hardware";
60 result[24] =
"requested feature not (yet) implemented";
61 result[25] =
"cache limit exceeded";
62 result[26] =
"table limit exceeded";
63 result[27] =
"iteration is not making progress towards solution";
64 result[28] =
"jacobian evaluations are not improving the solution";
65 result[29] =
"cannot reach the specified tolerance in F";
66 result[30] =
"cannot reach the specified tolerance in X";
67 result[31] =
"cannot reach the specified tolerance in gradient";
76 auto it = errorDescription.find(errorCode);
77 if (it != errorDescription.end())
80 return "Unknown error";
85 constexpr
double eps = std::numeric_limits<double>::epsilon();
87 throw std::runtime_error(
"MinimizerUtils::numbersDiffer() -> Error.Not intended for tol<1");
88 return std::abs(a - b) >
eps * std::max(tol *
eps, std::abs(b));
95 if (sectionName.empty())
96 return std::string(report_width,
'-') +
"\n";
98 std::string prefix(3,
'-');
99 std::string body = std::string(
" ") + sectionName +
" ";
100 std::string postfix(report_width - body.size() - prefix.size(),
'-');
101 std::ostringstream result;
102 result << prefix << body << postfix << std::endl;
Declares namespace MinimizerUtils.
std::string toString(const std::vector< std::string > &v, const std::string &delim="")
std::string sectionString(const std::string §ionName="", size_t report_width=80)
Returns horizontal line of 80 characters length with section name in it.
bool numbersDiffer(double a, double b, double tol)
std::map< int, std::string > gslErrorDescriptionMap()
Returns translation of GSL error code to string.
std::string gslErrorDescription(int errorCode)