00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef MUPARSER_SCRIPTING_H
00034 #define MUPARSER_SCRIPTING_H
00035
00036 #include "ScriptingEnv.h"
00037 #include "Script.h"
00038 #include "muParserScript.h"
00039
00040 #include <muParser.h>
00041 #include "math.h"
00042 #include <gsl/gsl_sf.h>
00043 #include <q3asciidict.h>
00044
00046 class muParserScripting: public ScriptingEnv
00047 {
00048 Q_OBJECT
00049
00050 public:
00051 static const char *langName;
00052 muParserScripting(ApplicationWindow *parent) : ScriptingEnv(parent, langName) { d_initialized=true; }
00053 static ScriptingEnv *constructor(ApplicationWindow *parent) { return new muParserScripting(parent); }
00054
00055 bool isRunning() const { return true; }
00056 Script *newScript(const QString &code, QObject *context, const QString &name="<input>")
00057 {
00058 return new muParserScript(this, code, context, name);
00059 }
00060
00061
00062 bool setQObject(QObject*, const char*) { return false; }
00063 bool setInt(int, const char*) { return false; }
00064 bool setDouble(double, const char*) { return false; }
00065
00066 const QStringList mathFunctions() const;
00067 const QString mathFunctionDoc (const QString &name) const;
00068
00069 struct mathFunction
00070 {
00071 char *name;
00072 int numargs;
00073 double (*fun1)(double);
00074 double (*fun2)(double,double);
00075 double (*fun3)(double,double,double);
00076 char *description;
00077 };
00078 static const mathFunction math_functions[];
00079
00080 private:
00081 static double ceil(double x)
00082 { return ceil(x); }
00083 static double floor(double x)
00084 { return floor(x); }
00085 static double mod(double x, double y)
00086 { return fmod(x,y); }
00087 static double mypow(double x, double y)
00088 { return pow(x,y); }
00089 static double bessel_J0(double x)
00090 { return gsl_sf_bessel_J0 (x); }
00091 static double bessel_J1(double x)
00092 { return gsl_sf_bessel_J1 (x); }
00093 static double bessel_Jn(double x, double n)
00094 { return gsl_sf_bessel_Jn ((int)n, x); }
00095 static double bessel_Yn(double x, double n)
00096 { return gsl_sf_bessel_Yn ((int)n, x); }
00097 static double bessel_Jn_zero(double n, double s)
00098 { return gsl_sf_bessel_zero_Jnu(n, (unsigned int) s); }
00099 static double bessel_Y0(double x)
00100 { return gsl_sf_bessel_Y0 (x); }
00101 static double bessel_Y1(double x)
00102 { return gsl_sf_bessel_Y1 (x); }
00103 static double beta(double a, double b)
00104 { return gsl_sf_beta (a,b); }
00105 static double erf(double x)
00106 { return gsl_sf_erf (x); }
00107 static double erfc(double x)
00108 { return gsl_sf_erfc (x); }
00109 static double erf_Z(double x)
00110 { return gsl_sf_erf_Z (x); }
00111 static double erf_Q(double x)
00112 { return gsl_sf_erf_Q (x); }
00113 static double gamma(double x)
00114 { return gsl_sf_gamma (x); }
00115 static double lngamma(double x)
00116 { return gsl_sf_lngamma (x); }
00117 static double hazard(double x)
00118 { return gsl_sf_hazard (x); }
00119 static double lambert_W0(double x)
00120 { return gsl_sf_lambert_W0(x); }
00121 static double lambert_Wm1(double x)
00122 { return gsl_sf_lambert_Wm1(x); }
00123 };
00124
00125 class EmptySourceError : public mu::ParserError
00126 {
00127 public:
00128 EmptySourceError() {}
00129 };
00130
00131 #endif