1
/***************************************************************************
2
File : muParserScripting.h
4
--------------------------------------------------------------------
6
Copyright : (C) 2006 by Ion Vasilief,
7
Tilman Hoener zu Siederdissen,
9
Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net,
11
Description : Evaluate mathematical expressions using muParser
13
***************************************************************************/
15
/***************************************************************************
17
* This program is free software; you can redistribute it and/or modify *
18
* it under the terms of the GNU General Public License as published by *
19
* the Free Software Foundation; either version 2 of the License, or *
20
* (at your option) any later version. *
22
* This program is distributed in the hope that it will be useful, *
23
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
24
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
25
* GNU General Public License for more details. *
27
* You should have received a copy of the GNU General Public License *
28
* along with this program; if not, write to the Free Software *
29
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
30
* Boston, MA 02110-1301 USA *
32
***************************************************************************/
33
#ifndef MUPARSER_SCRIPTING_H
34
#define MUPARSER_SCRIPTING_H
36
#include "ScriptingEnv.h"
38
#include "muParserScript.h"
42
#include <gsl/gsl_sf.h>
43
#include <q3asciidict.h>
46
class muParserScripting: public ScriptingEnv
51
static const char *langName;
52
muParserScripting(ApplicationWindow *parent) : ScriptingEnv(parent, langName) { d_initialized=true; }
53
static ScriptingEnv *constructor(ApplicationWindow *parent) { return new muParserScripting(parent); }
55
bool isRunning() const { return true; }
56
Script *newScript(const QString &code, QObject *context, const QString &name="<input>")
58
return new muParserScript(this, code, context, name);
61
// we do not support global variables
62
bool setQObject(QObject*, const char*) { return false; }
63
bool setInt(int, const char*) { return false; }
64
bool setDouble(double, const char*) { return false; }
66
const QStringList mathFunctions() const;
67
const QString mathFunctionDoc (const QString &name) const;
73
double (*fun1)(double);
74
double (*fun2)(double,double);
75
double (*fun3)(double,double,double);
78
static const mathFunction math_functions[];
81
static double ceil(double x)
83
static double floor(double x)
85
static double mod(double x, double y)
87
static double mypow(double x, double y)
89
static double bessel_J0(double x)
90
{ return gsl_sf_bessel_J0 (x); }
91
static double bessel_J1(double x)
92
{ return gsl_sf_bessel_J1 (x); }
93
static double bessel_Jn(double x, double n)
94
{ return gsl_sf_bessel_Jn ((int)n, x); }
95
static double bessel_Yn(double x, double n)
96
{ return gsl_sf_bessel_Yn ((int)n, x); }
97
static double bessel_Jn_zero(double n, double s)
98
{ return gsl_sf_bessel_zero_Jnu(n, (unsigned int) s); }
99
static double bessel_Y0(double x)
100
{ return gsl_sf_bessel_Y0 (x); }
101
static double bessel_Y1(double x)
102
{ return gsl_sf_bessel_Y1 (x); }
103
static double beta(double a, double b)
104
{ return gsl_sf_beta (a,b); }
105
static double erf(double x)
106
{ return gsl_sf_erf (x); }
107
static double erfc(double x)
108
{ return gsl_sf_erfc (x); }
109
static double erf_Z(double x)
110
{ return gsl_sf_erf_Z (x); }
111
static double erf_Q(double x)
112
{ return gsl_sf_erf_Q (x); }
113
static double gamma(double x)
114
{ return gsl_sf_gamma (x); }
115
static double lngamma(double x)
116
{ return gsl_sf_lngamma (x); }
117
static double hazard(double x)
118
{ return gsl_sf_hazard (x); }
119
static double lambert_W0(double x)
120
{ return gsl_sf_lambert_W0(x); }
121
static double lambert_Wm1(double x)
122
{ return gsl_sf_lambert_Wm1(x); }
125
class EmptySourceError : public mu::ParserError
128
EmptySourceError() {}