Skip to content

Commit

Permalink
Add example for array sizes in declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
HansOlsson committed Jul 5, 2019
1 parent 1dfa8b0 commit 7167b69
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions chapters/classes.tex
Expand Up @@ -193,19 +193,22 @@ \subsection{Component Declaration Static Semantics}\doublelabel{component-declar

Array dimensions shall be scalar non-negative parameter expressions of type Integer,
a reference to a type (which must an enumeration type or Boolean, see \autoref{enumeration-types}),
or the colon operator denoting that the array dimension is left unspecified.
or the colon operator denoting that the array dimension is left unspecified (see \autoref{array-declarations}).
All variants can also be part of short class definitions.

\begin{nonnormative}
Example of variables with array dimensions.
\begin{lstlisting}[language=modelica]
model ArrayVariants
type T=Real[:];
type T=Real[:]; // Unspecified size for type
parameter T x=ones(4);
parameter T y[3]=ones(3, 4);
parameter Real a[2]=ones(2);
parameter Real b[2, 0]=ones(2, 0);
parameter Real c[:]=ones(0);
parameter T y[3]=ones(3, 4);
parameter Real a[2]=ones(2); // Specified using Integer
parameter Real b[2, 0]=ones(2, 0); // Size 0 is allowed
parameter Real c[:]=ones(0); // Unspecified size for variable
parameter Integer n=0;
Real x[n*2]=cat(1,ones(n),zeros(n)};// Parameter expressions are allowed
Boolean notV[Boolean]={true,false}; // Indexing with type
end ArrayVariants;
\end{lstlisting}
\end{nonnormative}
Expand Down

0 comments on commit 7167b69

Please sign in to comment.