~showard314/ubuntu/natty/qtiplot/Python2.7_fix

« back to all changes in this revision

Viewing changes to qtiplot/src/muParserScripting.h

  • Committer: Bazaar Package Importer
  • Author(s): Gudjon I. Gudjonsson
  • Date: 2007-03-25 12:06:27 UTC
  • Revision ID: james.westby@ubuntu.com-20070325120627-5pvdufddr7i0r74x
Tags: upstream-0.9~rc2
ImportĀ upstreamĀ versionĀ 0.9~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    File                 : muParserScripting.h
 
3
    Project              : QtiPlot
 
4
    --------------------------------------------------------------------
 
5
 
 
6
    Copyright            : (C) 2006 by Ion Vasilief, 
 
7
                           Tilman Hoener zu Siederdissen,
 
8
                           Knut Franke
 
9
    Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net,
 
10
                           knut.franke*gmx.de
 
11
    Description          : Evaluate mathematical expressions using muParser
 
12
                           
 
13
 ***************************************************************************/
 
14
 
 
15
/***************************************************************************
 
16
 *                                                                         *
 
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.                                    *
 
21
 *                                                                         *
 
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.                           *
 
26
 *                                                                         *
 
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                                           *
 
31
 *                                                                         *
 
32
 ***************************************************************************/
 
33
#ifndef MUPARSER_SCRIPTING_H
 
34
#define MUPARSER_SCRIPTING_H
 
35
 
 
36
#include "ScriptingEnv.h"
 
37
#include "Script.h"
 
38
#include "muParserScript.h"
 
39
 
 
40
#include <muParser.h>
 
41
#include "math.h"
 
42
#include <gsl/gsl_sf.h>
 
43
#include <q3asciidict.h>
 
44
 
 
45
//! TODO
 
46
class muParserScripting: public ScriptingEnv
 
47
{
 
48
  Q_OBJECT
 
49
 
 
50
  public:
 
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); }
 
54
 
 
55
    bool isRunning() const { return true; }
 
56
    Script *newScript(const QString &code, QObject *context, const QString &name="<input>")
 
57
    {
 
58
      return new muParserScript(this, code, context, name);
 
59
    }
 
60
 
 
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; }
 
65
    
 
66
    const QStringList mathFunctions() const;
 
67
    const QString mathFunctionDoc (const QString &name) const;
 
68
 
 
69
    struct mathFunction
 
70
    {
 
71
      char *name;
 
72
      int numargs;
 
73
      double (*fun1)(double);
 
74
      double (*fun2)(double,double);
 
75
      double (*fun3)(double,double,double);
 
76
      char *description;
 
77
    };
 
78
    static const mathFunction math_functions[];
 
79
 
 
80
  private:
 
81
    static double ceil(double x)
 
82
      { return ceil(x); }
 
83
    static double floor(double x)
 
84
      { return floor(x); }
 
85
    static double mod(double x, double y)
 
86
      { return fmod(x,y); }
 
87
    static double mypow(double x, double y)
 
88
      { return pow(x,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); }
 
123
};
 
124
 
 
125
class EmptySourceError : public mu::ParserError
 
126
{
 
127
        public:
 
128
                EmptySourceError() {}
 
129
};
 
130
 
 
131
#endif