Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ClarifyEach' into ConstrainArray…
Browse files Browse the repository at this point in the history
…Assignment
  • Loading branch information
HansOlsson committed Dec 14, 2022
2 parents 2d4a795 + f7e8217 commit de1b6a6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion chapters/abstract.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% Can't use the 'abstract' environment as long as LaTeXML puts the abstract before the title page, see LaTeXML issue:
% - https://github.com/brucemiller/LaTeXML/issues/1395
% - https://github.com/brucemiller/LaTeXML/issues/1395 (fixed on master 2022-12-10)
\begin{center}
\large\bfseries\sffamily
\abstractname
Expand Down
2 changes: 1 addition & 1 deletion chapters/equations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ \section{Initialization, initial equation, and initial algorithm}\label{initiali
but not in one of the specific forms, the \lstinline!when!-clause is not active during initialization: \lstinline!when not initial() then print("simulation started"); end when;!
\end{nonnormative}

The algorithmic statements within a \lstinline!when!-statement are active during initialization, if and only they are explicitly enabled with \lstinline!initial()!, and only in one of the two forms \lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!.
The algorithmic statements within a \lstinline!when!-statement are active during initialization, if and only if they are explicitly enabled with \lstinline!initial()!, and only in one of the two forms \lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!.
In this case, the algorithmic statements within the \lstinline!when!-statement remain active during the whole initialization phase.

An active \lstinline!when!-clause inactivates the following \lstinline!elsewhen! (similarly as for \lstinline!when!-clauses during simulation), but apart from that the first \lstinline!elsewhen initial() then! or \lstinline!elsewhen {$\ldots$, initial(), $\ldots$} then! is similarly active during initialization as \lstinline!when initial() then! or \lstinline!when {$\ldots$, initial(), $\ldots$} then!.
Expand Down
13 changes: 11 additions & 2 deletions chapters/inheritance.tex
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ \subsection{Modifiers for Array Elements}\label{modifiers-for-array-elements}
The following rules apply to modifiers:
\begin{itemize}
\item
The \lstinline!each!\indexinline{each} keyword on a modifier requires that it is applied in an array declaration/modification, and the modifier is applied individually to each element of the enclosing array (with regard to the position of \lstinline!each!).
The \lstinline!each!\indexinline{each} keyword on a modifier requires that it is applied inside an array declaration or modification of an array, and the modifier is applied individually to each element of the enclosing array (with regard to the position of \lstinline!each!).
In case of nested modifiers this implies it is applied individually to each element of each element of the enclosing array; see example.
If the modified element is a vector and the modifier does not contain the \lstinline!each! prefix, the modification is split such that the first element in the vector is applied to the first element of the vector of elements, the second to the second element, until the last element of the vector is applied to the last element of the array; it is an error if these sizes do not match.
Matrices and general arrays of elements are treated by viewing those as vectors of vectors etc.
Expand All @@ -477,7 +477,7 @@ \subsection{Modifiers for Array Elements}\label{modifiers-for-array-elements}

model B
C c[5](each a = {1, 2, 3}, d = {1, 2, 3, 4, 5});
parameter Real b = 0;
parameter Real p = 0;
end B;
\end{lstlisting}
This implies \lstinline!c[i].a[j] = j! and \lstinline!c[i].d = i!.
Expand Down Expand Up @@ -508,6 +508,15 @@ \subsection{Modifiers for Array Elements}\label{modifiers-for-array-elements}
Real[2] work2(each start = 2); // Legal
end F;
\end{lstlisting}
Note that the array is not necessarily the closest enclosing identifier.
\begin{lstlisting}[language=modelica]
model G
C c[2](each a = {1, 2, 3}, d(start={4, 5}, each fixed=true));
// The second each relies on c being an array,
// without the second each we would have to write:
C c2[2](each a = {1, 2, 3}, d(start={4, 5}, fixed=fill(true, 2)));
end G;
\end{lstlisting}
\end{example}

\subsection{Final Element Modification Prevention}\label{final-element-modification-prevention}
Expand Down
2 changes: 1 addition & 1 deletion chapters/operatorsandexpressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ \section{Operator Precedence and Associativity}\label{operator-precedence-and-as
All operators are binary except the postfix operators and those shown as unary together with \emph{expr}, the conditional operator, the array construction operator
% Beware that the array construction operator, normally expressed as \lstinline!{ }! needs escaped braces inside \caption.
% This isn't handled correctly by LaTeXML, as reported here:
% - https://github.com/brucemiller/LaTeXML/issues/1377
% - https://github.com/brucemiller/LaTeXML/issues/1377 (fixed on master 2022-12-10)
\ifpdf
\lstinline!\{ \}! % Intentional space at end of line.
\else
Expand Down

0 comments on commit de1b6a6

Please sign in to comment.