scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

MuParserScripting.cpp
Go to the documentation of this file.
1 
15 
33 #include "MuParserScript.h"
34 #include "MuParserScripting.h"
35 #include "Table.h"
36 #include "Matrix.h"
37 #include "QStringStdString.h"
38 
39 #include <qstringlist.h>
40 
41 using namespace mu;
42 
43 const char* MuParserScripting::langName = "muParser";
44 
45 // functions without function pointer (fun1,fun2,fun3 == NULL,NULL,NULL) are implemented
46 // in mu::Parser
48  {
49  { _T("abs"), 1, NULL,NULL,NULL, QT_TR_NOOP("abs(x):\n Absolute value of x.") },
50  { _T("acos"), 1, NULL,NULL,NULL, QT_TR_NOOP("acos(x):\n Inverse cos function.") },
51  { _T("acosh"), 1, NULL,NULL,NULL, QT_TR_NOOP("acosh(x):\n Hyperbolic inverse cos function.") },
52  { _T("asin"), 1, NULL,NULL,NULL, QT_TR_NOOP("asin(x):\n Inverse sin function.") },
53  { _T("asinh"), 1, NULL,NULL,NULL, QT_TR_NOOP("asinh(x):\n Hyperbolic inverse sin function.") },
54  { _T("atan"), 1, NULL,NULL,NULL, QT_TR_NOOP("atan(x):\n Inverse tan function.") },
55  { _T("atanh"), 1, NULL,NULL,NULL, QT_TR_NOOP("atanh(x):\n Hyperbolic inverse tan function.") },
56  { _T("avg"), -1, NULL,NULL,NULL, QT_TR_NOOP("avg(x,y,...):\n Mean value of all arguments.") },
57  { _T("bessel_j0"), 1, bessel_J0,NULL,NULL, QT_TR_NOOP("bessel_j0(x):\n Regular cylindrical Bessel function of zeroth order, J_0(x).") },
58  { _T("bessel_j1"), 1, bessel_J1,NULL,NULL, QT_TR_NOOP("bessel_j1(x):\n Regular cylindrical Bessel function of first order, J_1(x).") },
59  { _T("bessel_jn"), 2, NULL,bessel_Jn,NULL, QT_TR_NOOP("bessel_jn(double x, int n):\n Regular cylindrical Bessel function of order n, J_n(x).") },
60  { _T("bessel_jn_zero"), 2, NULL,bessel_Jn_zero,NULL, QT_TR_NOOP("bessel_jn_zero(double n, unsigned int s):\n s-th positive zero x_s of regular cylindrical Bessel function of order n, J_n(x_s)=0") },
61  { _T("bessel_y0"), 1, bessel_Y0, NULL,NULL, QT_TR_NOOP("bessel_y0(x):\n Irregular cylindrical Bessel function of zeroth order, Y_0(x), for x>0.") },
62  { _T("bessel_y1"), 1, bessel_Y1, NULL,NULL, QT_TR_NOOP("bessel_y1(x):\n Irregular cylindrical Bessel function of first order, Y_1(x), for x>0.") },
63  { _T("bessel_yn"), 2, NULL,bessel_Yn,NULL, QT_TR_NOOP("bessel_yn(double x, int n):\n Irregular cylindrical Bessel function of order n, Y_n(x), for x>0.") },
64  { _T("beta"), 2, NULL,beta,NULL, QT_TR_NOOP("beta(a,b):\n Computes the Beta Function, B(a,b) = Gamma(a)*Gamma(b)/Gamma(a+b) for a > 0, b > 0.") },
65  { _T("ceil"), 1, ceil,NULL,NULL, QT_TR_NOOP("ceil(x):\n Round to the next larger integer,\n smallest integer larger or equal to x.") },
66  { _T("cos"), 1, NULL,NULL,NULL, QT_TR_NOOP("cos(x):\n Calculate cosine.") },
67  { _T("cosh"), 1, NULL,NULL,NULL, QT_TR_NOOP("cosh(x):\n Hyperbolic cos function.") },
68  { _T("erf"), 1, erf, NULL,NULL, QT_TR_NOOP("erf(x):\n The error function.") },
69  { _T("erfc"), 1, erfc, NULL,NULL, QT_TR_NOOP("erfc(x):\n Complementary error function erfc(x) = 1 - erf(x).") },
70  { _T("erfz"), 1, erf_Z, NULL,NULL, QT_TR_NOOP("erfz(x):\n The Gaussian probability density function Z(x).") },
71  { _T("erfq"), 1, erf_Q, NULL,NULL, QT_TR_NOOP("erfq(x):\n The upper tail of the Gaussian probability function Q(x).") },
72  { _T("exp"), 1, NULL,NULL,NULL, QT_TR_NOOP("exp(x):\n Exponential function: e raised to the power of x.") },
73  { _T("floor"), 1, floor,NULL,NULL, QT_TR_NOOP("floor(x):\n Round to the next smaller integer,\n largest integer smaller or equal to x.") },
74  { _T("gamma"), 1, gamma, NULL,NULL, QT_TR_NOOP("gamma(x):\n Computes the Gamma function, subject to x not being a negative integer.") },
75  { _T("gammaln"), 1, lngamma,NULL,NULL, QT_TR_NOOP("gammaln(x):\n Computes the logarithm of the Gamma function, subject to x not a being negative integer. For x<0, log(|Gamma(x)|) is returned.") },
76  { _T("hazard"), 1, hazard,NULL,NULL, QT_TR_NOOP("hazard(x):\n Computes the hazard function for the normal distribution h(x) = erfz(x)/erfq(x).") },
77  { _T("if"), 3, NULL,NULL,NULL, QT_TR_NOOP("if(e1, e2, e3):\n if e1 then e2 else e3.") },
78  { _T("ln"), 1, NULL,NULL,NULL, QT_TR_NOOP("ln(x):\n Calculate natural logarithm log_e.") },
79  { _T("log"), 1, NULL,NULL,NULL, QT_TR_NOOP("log(x):\n Calculate decimal logarithm log_10.") },
80  { _T("log10"), 1, NULL,NULL,NULL, QT_TR_NOOP("log10(x):\n Calculate decimal logarithm log_10.") },
81  { _T("log2"), 1, NULL,NULL,NULL, QT_TR_NOOP("log2(x):\n Calculate binary logarithm log_2.") },
82  { _T("min"), -1, NULL,NULL,NULL, QT_TR_NOOP("min(x,y,...):\n Calculate minimum of all arguments.") },
83  { _T("max"), -1, NULL,NULL,NULL, QT_TR_NOOP("max(x,y,...):\n Calculate maximum of all arguments.") },
84  { _T("mod"), 2, NULL,mod,NULL, QT_TR_NOOP("mod(x,y):\n Calculate rest of integer division x/y,\n x modulo y.") },
85  { _T("pow"), 2, NULL,mypow,NULL, QT_TR_NOOP("pow(x,y):\n Raise x to the power of y, x^y.") },
86  { _T("rint"), 1, NULL,NULL,NULL, QT_TR_NOOP("rint(x):\n Round to nearest integer.") },
87  { _T("sign"), 1, NULL,NULL,NULL, QT_TR_NOOP("sign(x):\n Sign function: -1 if x<0; 1 if x>0.") },
88  { _T("sin"), 1, NULL,NULL,NULL, QT_TR_NOOP("sin(x):\n Calculate sine.") },
89  { _T("sinh"), 1, NULL,NULL,NULL, QT_TR_NOOP("sinh(x):\n Hyperbolic sin function.") },
90  { _T("sqrt"), 1, NULL,NULL,NULL, QT_TR_NOOP("sqrt(x):\n Square root function.") },
91  { _T("sum"), -1, NULL,NULL,NULL, QT_TR_NOOP("sum(x,y,...):\n Calculate sum of all arguments.") },
92  { _T("tan"), 1, NULL,NULL,NULL, QT_TR_NOOP("tan(x):\n Calculate tangent function.") },
93  { _T("tanh"), 1, NULL,NULL,NULL, QT_TR_NOOP("tanh(x):\n Hyperbolic tan function.") },
94  { _T("w0"), 1, lambert_W0, NULL, NULL, QT_TR_NOOP("w0(x):\n Compute the principal branch of Lambert's W function, W_0(x).\n W is defined as a solution to the equation W(x)*exp(W(x))=x.\n For x<0, there are two real-valued branches; this function computes the one where W>-1 for x<0 (also see wm1(x)).") },
95  { _T("wm1"), 1, lambert_Wm1, NULL, NULL, QT_TR_NOOP("wm1(x):\n Compute the secondary branch of Lambert's W function, W_{-1}(x).\n W is defined as a solution to the equation W(x)*exp(W(x))=x.\n For x<0, there are two real-valued branches; this function computes the one where W<-1 for x<0. (also see w0(x)).") },
96  {0,0,NULL,NULL,NULL,0}
97 };
98 
99 const QStringList MuParserScripting::mathFunctions() const
100 {
101  QStringList l;
102  for (const mathFunction *i=math_functions; i->name; i++)
103  l << QStringFromString(i->name);
104  return l;
105 }
106 
107 const QString MuParserScripting::mathFunctionDoc (const QString &name) const
108 {
109  for (const mathFunction *i=math_functions; i->name; i++)
110  if (name==i->name)
111  return tr(i->description.toLocal8Bit());
112  return {};
113 }
MuParserScripting::mathFunction::name
const mu::string_type::value_type * name
Definition: MuParserScripting.h:74
QStringFromString
QString QStringFromString(const std::string &x)
Definition: QStringStdString.h:15
MuParserScript.h
Matrix.h
MuParserScripting.h
MuParserScripting::mathFunction
Definition: MuParserScripting.h:73
QStringStdString.h
name
char * name()
Definition: exp_saturation.c:45
MuParserScripting::langName
static const char * langName
Definition: MuParserScripting.h:51
MuParserScripting::mathFunctions
const QStringList mathFunctions() const
Return a list of supported mathematical functions. These should be imported into the global namespace...
Definition: MuParserScripting.cpp:99
MuParserScripting::mathFunctionDoc
const QString mathFunctionDoc(const QString &name) const
Return a documentation string for the given mathematical function.
Definition: MuParserScripting.cpp:107
Table.h
MuParserScripting::math_functions
static const mathFunction math_functions[]
Definition: MuParserScripting.h:81