doc: small changes
parent
e96f180c50
commit
8745880bde
|
@ -10341,7 +10341,7 @@ The following operators can be used on booleans:
|
||||||
|
|
||||||
The following operators can be used on doubles:
|
The following operators can be used on doubles:
|
||||||
|
|
||||||
* Arithmetic operators: ``+, -, *, /``
|
* Arithmetic operators: ``+, -, *, /, ^``
|
||||||
* Comparison operators: ``<, >, <=, >=, ==, !=``
|
* Comparison operators: ``<, >, <=, >=, ==, !=``
|
||||||
* Logical operators: ``&&, ||, !``
|
* Logical operators: ``&&, ||, !``
|
||||||
* Integer ranges, using the following syntax:
|
* Integer ranges, using the following syntax:
|
||||||
|
@ -10349,7 +10349,7 @@ The following operators can be used on doubles:
|
||||||
integer array ``[1,2,3,4]``)
|
integer array ``[1,2,3,4]``)
|
||||||
* Functions: ``max, min, mod, exp, ln, log10, sin, cos, tan, asin, acos,
|
* Functions: ``max, min, mod, exp, ln, log10, sin, cos, tan, asin, acos,
|
||||||
atan, sqrt, cbrt, sign, floor, ceil, trunc, erf, erfc, gamma, lgamma,
|
atan, sqrt, cbrt, sign, floor, ceil, trunc, erf, erfc, gamma, lgamma,
|
||||||
round, normpdf, normcdf``
|
round, normpdf, normcdf``. NB `log` can be used instead of `ln`
|
||||||
|
|
||||||
The following operators can be used on strings:
|
The following operators can be used on strings:
|
||||||
|
|
||||||
|
@ -10394,14 +10394,13 @@ Macro directives
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
.. macrodir:: @#includepath "PATH"
|
.. macrodir:: @#includepath "PATH"
|
||||||
@#includepath MACRO_VARIABLE
|
|
||||||
@#includepath MACRO_EXPRESSION
|
@#includepath MACRO_EXPRESSION
|
||||||
|
|
||||||
|br| This directive adds the path contained in PATH to the list of those to
|
|br| This directive adds the path contained in PATH to the list of those to
|
||||||
search when looking for a ``.mod`` file specified by ``@#include``. If
|
search when looking for a ``.mod`` file specified by ``@#include``. If
|
||||||
provided with a MACRO_VARIABLE or MACRO_EXPRESSION argument, the argument
|
provided with a MACRO_EXPRESSION argument, the argument must evaluate to a
|
||||||
must evaluate to a string. Note that these paths are added *after* any
|
string. Note that these paths are added *after* any paths passed using
|
||||||
paths passed using :opt:`-I <-I\<\<path\>\>>`.
|
:opt:`-I <-I\<\<path\>\>>`.
|
||||||
|
|
||||||
*Example*
|
*Example*
|
||||||
|
|
||||||
|
@ -10412,17 +10411,16 @@ Macro directives
|
||||||
|
|
||||||
|
|
||||||
.. macrodir:: @#include "FILENAME"
|
.. macrodir:: @#include "FILENAME"
|
||||||
@#include MACRO_VARIABLE
|
|
||||||
@#include MACRO_EXPRESSION
|
@#include MACRO_EXPRESSION
|
||||||
|
|
||||||
|br| This directive simply includes the content of another file in its
|
|br| This directive simply includes the content of another file in its
|
||||||
place; it is exactly equivalent to a copy/paste of the content of the
|
place; it is exactly equivalent to a copy/paste of the content of the
|
||||||
included file. If provided with a MACRO_VARIABLE or MACRO_EXPRESSION
|
included file. If provided with a MACRO_EXPRESSION argument, the argument
|
||||||
argument, the argument must evaluate to a string. Note that it is possible
|
must evaluate to a string. Note that it is possible to nest includes
|
||||||
to nest includes (i.e. to include a file from an included file). The file
|
(i.e. to include a file from an included file). The file will be searched
|
||||||
will be searched for in the current directory. If it is not found, the file
|
for in the current directory. If it is not found, the file will be searched
|
||||||
will be searched for in the folders provided by :opt:`-I <-I\<\<path\>\>>`
|
for in the folders provided by :opt:`-I <-I\<\<path\>\>>` and
|
||||||
and ``@#includepath``.
|
``@#includepath``.
|
||||||
|
|
||||||
*Example*
|
*Example*
|
||||||
|
|
||||||
|
@ -10489,6 +10487,15 @@ Macro directives
|
||||||
value. Conversely, ``@#ifndef`` will evaluate to true if the MACRO_VARIABLE
|
value. Conversely, ``@#ifndef`` will evaluate to true if the MACRO_VARIABLE
|
||||||
has not yet been defined.
|
has not yet been defined.
|
||||||
|
|
||||||
|
Note that if a double appears as the result of the MACRO_EXPRESSION, it
|
||||||
|
will be interpreted as a boolean; a value of 0 is interpreted as `false`,
|
||||||
|
otherwise it is interpreted as `true`. Further note that because of the
|
||||||
|
imprecision of doubles, extra care must be taken when testing them in the
|
||||||
|
MACRO_EXPRESSION. For example, `exp(log(5)) == 5` will evaluate to
|
||||||
|
`false`. Hence, when comparing double values, you should generally use a
|
||||||
|
zero tolerance around the value desired, e.g. `exp(log(5)) > 5-1e-14 &&
|
||||||
|
exp(log(5)) < 5+1e-14`
|
||||||
|
|
||||||
*Example*
|
*Example*
|
||||||
|
|
||||||
Choose between two alternative monetary policy rules using a
|
Choose between two alternative monetary policy rules using a
|
||||||
|
@ -10515,12 +10522,17 @@ Macro directives
|
||||||
|
|
||||||
*Example*
|
*Example*
|
||||||
|
|
||||||
Choose between two alternative monetary policy rules. In this example,
|
Choose between two alternative monetary policy rules using a
|
||||||
as ``linear_mon_pol`` was not previously defined, the first equation
|
macro-variable. The only difference between this example and the
|
||||||
will be chosen::
|
previous one is the use of `@#ifdef` instead of `@#if`. Even though
|
||||||
|
``linear_mon_pol`` contains the value `false` because `@#ifdef` only
|
||||||
|
checks that the variable has been defined, the linear monetary policy
|
||||||
|
is output::
|
||||||
|
|
||||||
|
@#define linear_mon_pol = false // 0 would be treated the same
|
||||||
|
...
|
||||||
model;
|
model;
|
||||||
@#ifndef linear_mon_pol
|
@#ifdef linear_mon_pol
|
||||||
i = w*i(-1) + (1-w)*i_ss + w2*(pie-piestar);
|
i = w*i(-1) + (1-w)*i_ss + w2*(pie-piestar);
|
||||||
@#else
|
@#else
|
||||||
i = i(-1)^w * i_ss^(1-w) * (pie/piestar)^w2;
|
i = i(-1)^w * i_ss^(1-w) * (pie/piestar)^w2;
|
||||||
|
|
Loading…
Reference in New Issue