... | ... | @@ -4,7 +4,7 @@ GetDP uses three kinds of numeric variables: parser variables, run-time variable |
|
|
|
|
|
Parser variables are created when the input `.pro` files are parsed, once at the beginning of a calculation. Such variables cannot be changed at run-time during a calculation, i.e. during pre-processing (`Constraint` evaluations), processing (`Resolution` operations) or post-processing (`PostOperation` operations). Parser variables are the most common in GetDP `.pro` files. They involve the least overhead at run-time, as their value is computed once, when the `.pro` file is read. They can be defined (almost) anywhere in `.pro` files, i.e. outside or inside objects like `Function` or `Resolution`.
|
|
|
|
|
|
In the following example `a`, `b` and `c` are parser variables; they can be used inside lists like `d()` (which are also parser variables), or within functions like `e[]` (which will only be evaluated at run-time):
|
|
|
In the following example `a`, `b` and `c` are parser variables; they can be used inside lists and strings like `d()` and `e` (which are also parser variables), or within functions like `f[]` (which will only be evaluated at run-time):
|
|
|
|
|
|
```cpp
|
|
|
a = 1;
|
... | ... | @@ -12,7 +12,8 @@ b = Sin[2*Pi/4] - a; |
|
|
Function{
|
|
|
c = (b < 1) ? -4e6 : 2.2e2;
|
|
|
d() = {a,b,c};
|
|
|
e[] = a + b + c;
|
|
|
e = Sprintf["string %g", c];
|
|
|
f[] = a + b + c;
|
|
|
If(c > 1) // this test is performed at parse time
|
|
|
Printf["c is greater than 1"]; // print message at parse time
|
|
|
Else
|
... | ... | |