File indexing completed on 2024-05-12 03:47:44

0001 /*
0002     File                 : errors.h
0003     Project              : LabPlot
0004     Description          : Translatable strings for GSL error codes
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2017 Alexander Semke <alexander.semke@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef GSL_ERRORS_H
0011 #define GSL_ERRORS_H
0012 
0013 #include <KLocalizedString>
0014 #include <gsl/gsl_errno.h>
0015 
0016 namespace {
0017 QString gslErrorToString(int status) {
0018     switch (status) {
0019     case GSL_SUCCESS:
0020         return i18n("Success");
0021     case GSL_FAILURE:
0022         return i18n("Failure");
0023     case GSL_CONTINUE:
0024         return i18n("Iteration has not converged");
0025     case GSL_EDOM:
0026         return i18n("Input domain error, e.g sqrt(-1)");
0027     case GSL_ERANGE:
0028         return i18n("Output range error, e.g. exp(1e100)");
0029     case GSL_EFAULT:
0030         return i18n("Invalid pointer");
0031     case GSL_EINVAL:
0032         return i18n("Invalid argument supplied");
0033     case GSL_EFAILED:
0034         return i18n("Generic failure");
0035     case GSL_EFACTOR:
0036         return i18n("Factorization failed");
0037     case GSL_ENOMEM:
0038         return i18n("Failed to allocate memory");
0039     case GSL_EBADFUNC:
0040         return i18n("Problem with supplied function");
0041     case GSL_ERUNAWAY:
0042         return i18n("Iterative process is out of control");
0043     case GSL_EMAXITER:
0044         return i18n("Exceeded max number of iterations");
0045     case GSL_EZERODIV:
0046         return i18n("Tried to divide by zero");
0047     case GSL_EBADTOL:
0048         return i18n("Invalid tolerance specified");
0049     case GSL_ETOL:
0050         return i18n("Failed to reach the specified tolerance");
0051     case GSL_EUNDRFLW:
0052         return i18n("Underflow");
0053     case GSL_EOVRFLW:
0054         return i18n("Overflow");
0055     case GSL_ELOSS:
0056         return i18n("Loss of accuracy");
0057     case GSL_EROUND:
0058         return i18n("Failed because of roundoff error");
0059     case GSL_EBADLEN:
0060         return i18n("Matrix, vector lengths are not conformant");
0061     case GSL_ENOTSQR:
0062         return i18n("Matrix not square");
0063     case GSL_ESING:
0064         return i18n("Apparent singularity detected");
0065     case GSL_EDIVERGE:
0066         return i18n("Integral or series is divergent");
0067     case GSL_EUNSUP:
0068         return i18n("Requested feature is not supported by the hardware");
0069     case GSL_EUNIMPL:
0070         return i18n("Requested feature not (yet) implemented");
0071     case GSL_ECACHE:
0072         return i18n("Cache limit exceeded");
0073     case GSL_ETABLE:
0074         return i18n("Table limit exceeded");
0075     case GSL_ENOPROG:
0076         return i18n("Iteration is not making progress towards solution");
0077     case GSL_ENOPROGJ:
0078         return i18n("Jacobian evaluations are not improving the solution");
0079     case GSL_ETOLF:
0080         return i18n("Cannot reach the specified tolerance in F");
0081     case GSL_ETOLX:
0082         return i18n("Cannot reach the specified tolerance in X");
0083     case GSL_ETOLG:
0084         return i18n("Cannot reach the specified tolerance in gradient");
0085     case GSL_EOF:
0086         return i18n("End of file");
0087     default:
0088         return QLatin1String(gsl_strerror(status));
0089     }
0090 }
0091 }
0092 #endif