muParserScripting.h
Go to the documentation of this file.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 #ifndef MUPARSER_SCRIPTING_H
00031 #define MUPARSER_SCRIPTING_H
00032
00033 #include "ScriptingEnv.h"
00034 #include "Script.h"
00035 #include "muParserScript.h"
00036
00037 #include <muParser.h>
00038 #include "math.h"
00039 #include <gsl/gsl_sf.h>
00040 #include <gsl/gsl_cdf.h>
00041 #include <q3asciidict.h>
00042
00044 class muParserScripting: public ScriptingEnv
00045 {
00046 Q_OBJECT
00047
00048 public:
00049 static const char *langName;
00050 muParserScripting(ApplicationWindow *parent) : ScriptingEnv(parent, langName) { d_initialized=true; }
00051 static ScriptingEnv *constructor(ApplicationWindow *parent) { return new muParserScripting(parent); }
00052
00053 bool isRunning() const { return true; }
00054 Script *newScript(const QString &code, QObject *context, const QString &name="<input>")
00055 {
00056 return new muParserScript(this, code, context, name);
00057 }
00058
00059
00060 bool setQObject(QObject*, const char*) { return false; }
00061 bool setInt(int, const char*) { return false; }
00062 bool setDouble(double, const char*) { return false; }
00063
00064 const QStringList mathFunctions() const;
00065 const QString mathFunctionDoc (const QString &name) const;
00066
00067 struct mathFunction
00068 {
00069 char *name;
00070 int numargs;
00071 double (*fun1)(double);
00072 double (*fun2)(double,double);
00073 double (*fun3)(double,double,double);
00074 char *description;
00075 };
00076 static const mathFunction math_functions[];
00077
00078 private:
00079 static double mod(double x, double y)
00080 { return fmod(x,y); }
00081 static double bessel_J0(double x)
00082 { return gsl_sf_bessel_J0 (x); }
00083 static double bessel_J1(double x)
00084 { return gsl_sf_bessel_J1 (x); }
00085 static double bessel_Jn(double x, double n)
00086 { return gsl_sf_bessel_Jn ((int)n, x); }
00087 static double bessel_Yn(double x, double n)
00088 { return gsl_sf_bessel_Yn ((int)n, x); }
00089 static double bessel_Jn_zero(double n, double s)
00090 { return gsl_sf_bessel_zero_Jnu(n, (unsigned int) s); }
00091 static double bessel_Y0(double x)
00092 { return gsl_sf_bessel_Y0 (x); }
00093 static double bessel_Y1(double x)
00094 { return gsl_sf_bessel_Y1 (x); }
00095 static double beta(double a, double b)
00096 { return gsl_sf_beta (a,b); }
00097 static double erf(double x)
00098 { return gsl_sf_erf (x); }
00099 static double erfc(double x)
00100 { return gsl_sf_erfc (x); }
00101 static double erf_Z(double x)
00102 { return gsl_sf_erf_Z (x); }
00103 static double erf_Q(double x)
00104 { return gsl_sf_erf_Q (x); }
00105 static double gamma(double x)
00106 { return gsl_sf_gamma (x); }
00107 static double lngamma(double x)
00108 { return gsl_sf_lngamma (x); }
00109 static double hazard(double x)
00110 { return gsl_sf_hazard (x); }
00111 static double lambert_W0(double x)
00112 { return gsl_sf_lambert_W0(x); }
00113 static double lambert_Wm1(double x)
00114 { return gsl_sf_lambert_Wm1(x); }
00115 static double ttable(double x, double n)
00116 { return gsl_cdf_tdist_Pinv(x, n); }
00117 };
00118
00119 class EmptySourceError : public mu::ParserError
00120 {
00121 public:
00122 EmptySourceError() {}
00123 };
00124
00125 #endif