From bf835b8d4b7a84cf078106dbf3adb7b16a146933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Thu, 30 May 2024 10:04:26 +0200 Subject: [PATCH] macroprocessor doc: misc changes for summer school 2024 (cherry picked from commit 34ec8ece78063d6cb1cf3137ecd90d726ab1fcc4) --- doc/macroprocessor/macroprocessor.tex | 34 ++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/doc/macroprocessor/macroprocessor.tex b/doc/macroprocessor/macroprocessor.tex index 3c9c61f4..2586f5fe 100644 --- a/doc/macroprocessor/macroprocessor.tex +++ b/doc/macroprocessor/macroprocessor.tex @@ -15,7 +15,7 @@ \pgfdeclareimage[height=0.8cm]{logo}{dlogo} \institute[Dynare Team]{\pgfuseimage{logo}} -\date{23 May 2023} +\date{31 May 2024} \AtBeginSection[] { @@ -156,9 +156,9 @@ \item comparison operators: \texttt{< > <= >= == !=} \item logical operators: \verb+&& || !+ \item range with unit increment: \texttt{1:4} is equivalent to - real array \texttt{[1, 2, 3, 4]}. (NB: \texttt{[1:4]} is equivalent to an + real array \texttt{[1, 2, 3, 4]} \\ (NB: \texttt{[1:4]} is equivalent to an array containing an array of reals, \textit{i.e.} \texttt{[[1, 2, 3, 4]]}) - \item range with user-defined increment: \texttt{4:-1.1:-1} is equivalent to real array \texttt{[4, 2.9, 1.8, 0.7, -0.4]}. + \item range with user-defined increment: \\ \texttt{4:-1.1:-1} is equivalent to real array \texttt{[4, 2.9, 1.8, 0.7, -0.4]} \end{itemize} \end{block} @@ -314,7 +314,7 @@ Then \texttt{distance(3, 4)} will be equivalent to \texttt{5}. \end{frame} \begin{frame}[fragile=singleslide] - \frametitle{Defining macro-variables} + \frametitle{Defining macro-variables (1/2)} The value of a macro-variable can be defined with the \verb+@#define+ directive. @@ -335,9 +335,31 @@ Then \texttt{distance(3, 4)} will be equivalent to \texttt{5}. @#define t = ("US" in w) // Equals true \end{verbatim} \end{block} - NB: You can define macro variables on the Dynare command line by using the \texttt{-D} option \end{frame} +\begin{frame}[fragile=singleslide] + \frametitle{Defining macro-variables (2/2)} + Macro variables can also be defined on the Dynare command line by using the + \texttt{-D} option, for easily switching between different flavours of a model. + + \begin{block}{Example 1} +\begin{verbatim} +dynare myfile.mod -Dx=5 +\end{verbatim} +The macro-variable \texttt{x} will be equal to \texttt{5} when running \texttt{myfile.mod}. +\end{block} + +\begin{block}{Example 2} + Use single quotes around the \texttt{-D} option when there are spaces or + special characters in the variable definition. +\begin{verbatim} +dynare myfile.mod '-DA=[ i in [1,2,3] when i > 1 ]' +\end{verbatim} +The macro-variable \texttt{A} will be equal to \texttt{[2,3]} when running \texttt{myfile.mod}. +\end{block} +\end{frame} + + \begin{frame}[fragile=singleslide] \frametitle{Expression substitution} \framesubtitle{Dummy example} @@ -866,7 +888,7 @@ rhos = [ 0.8, 0.9, 1]; \ccbysa \column{0.71\textwidth} \tiny - Copyright © 2008-2023 Dynare Team \\ + Copyright © 2008-2024 Dynare Team \\ License: \href{http://creativecommons.org/licenses/by-sa/4.0/}{Creative Commons Attribution-ShareAlike 4.0} \end{columns} -- GitLab