SciDAVis
1.D4
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
scidavis
src
MuParserScripting.h
Go to the documentation of this file.
1
/***************************************************************************
2
File : MuParserScripting.h
3
Project : SciDAVis
4
--------------------------------------------------------------------
5
6
Copyright : (C) 2006 by Ion Vasilief,
7
Tilman Benkert,
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 <gsl/gsl_errno.h>
44
46
class
MuParserScripting
:
public
ScriptingEnv
47
{
48
Q_OBJECT
49
50
public
:
51
static
const
char
*
langName
;
52
MuParserScripting
(
ApplicationWindow
*parent) :
ScriptingEnv
(parent,
langName
) {
53
d_initialized
=
true
;
54
gsl_set_error_handler_off();
55
}
56
static
ScriptingEnv
*
constructor
(
ApplicationWindow
*parent) {
return
new
MuParserScripting
(parent); }
57
58
bool
isRunning
()
const
{
return
true
; }
59
Script
*
newScript
(
const
QString &code, QObject *context,
const
QString &name=
"<input>"
)
60
{
61
return
new
MuParserScript
(
this
, code, context, name);
62
}
63
64
// we do not support global variables
65
bool
setQObject
(QObject*,
const
char
*) {
return
false
; }
66
bool
setInt
(
int
,
const
char
*) {
return
false
; }
67
bool
setDouble
(
double
,
const
char
*) {
return
false
; }
68
69
const
QStringList
mathFunctions
()
const
;
70
const
QString
mathFunctionDoc
(
const
QString &name)
const
;
71
72
struct
mathFunction
73
{
74
const
char
*
name
;
75
int
numargs
;
76
double (*
fun1
)(double);
77
double (*
fun2
)(double,double);
78
double (*
fun3
)(double,double,double);
79
QString
description
;
80
};
81
static
const
mathFunction
math_functions
[];
82
83
private
:
84
#define SPECIAL(fname, arg) gsl_sf_result result; if (gsl_sf_##fname##_e(arg, &result) == GSL_SUCCESS) return result.val; else return NAN
85
#define SPECIAL2(fname, arg1, arg2) gsl_sf_result result; if (gsl_sf_##fname##_e(arg1, arg2, &result) == GSL_SUCCESS) return result.val; else return NAN
86
static
double
ceil
(
double
x)
87
{
return
ceil
(x); }
88
static
double
floor
(
double
x)
89
{
return
floor
(x); }
90
static
double
mod
(
double
x,
double
y)
91
{
return
fmod(x,y); }
92
static
double
mypow
(
double
x,
double
y)
93
{
return
pow(x,y); }
94
static
double
bessel_J0
(
double
x)
95
{
SPECIAL
(
bessel_J0
,x); }
96
static
double
bessel_J1
(
double
x)
97
{
SPECIAL
(
bessel_J1
,x); }
98
static
double
bessel_Jn
(
double
x,
double
n)
99
{
SPECIAL2
(
bessel_Jn
,(
int
)n, x); }
100
static
double
bessel_Yn
(
double
x,
double
n)
101
{
SPECIAL2
(
bessel_Yn
,(
int
)n, x); }
102
static
double
bessel_Jn_zero
(
double
n,
double
s)
103
{
SPECIAL2
(bessel_zero_Jnu,n, (
unsigned
int
) s); }
104
static
double
bessel_Y0
(
double
x)
105
{
SPECIAL
(
bessel_Y0
,x); }
106
static
double
bessel_Y1
(
double
x)
107
{
SPECIAL
(
bessel_Y1
,x); }
108
static
double
beta
(
double
a,
double
b)
109
{
SPECIAL2
(
beta
,a,b); }
110
static
double
erf
(
double
x)
111
{
SPECIAL
(
erf
,x); }
112
static
double
erfc
(
double
x)
113
{
SPECIAL
(
erfc
,x); }
114
static
double
erf_Z
(
double
x)
115
{
SPECIAL
(
erf_Z
,x); }
116
static
double
erf_Q
(
double
x)
117
{
SPECIAL
(
erf_Q
,x); }
118
static
double
gamma
(
double
x)
119
{
SPECIAL
(
gamma
,x); }
120
static
double
lngamma
(
double
x)
121
{
SPECIAL
(
lngamma
,x); }
122
static
double
hazard
(
double
x)
123
{
SPECIAL
(
hazard
,x); }
124
static
double
lambert_W0
(
double
x)
125
{
SPECIAL
(
lambert_W0
,x); }
126
static
double
lambert_Wm1
(
double
x)
127
{
SPECIAL
(
lambert_Wm1
,x); }
128
};
129
130
class
EmptySourceError
:
public
mu::ParserError
131
{
132
public
:
133
EmptySourceError
() {}
134
};
135
136
#endif
Generated by
1.8.1