Skip to content

Commit

Permalink
Cleanup related to 'Integer'
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Oct 13, 2020
1 parent 6f66309 commit 657b9fb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 46 deletions.
13 changes: 2 additions & 11 deletions chapters/glossary.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ \chapter{Glossary}\label{glossary}
outputs, e.g.\ by search (generate and test), or by deriving an inverse
algorithm symbolically. (See \cref{statements-and-algorithm-sections}.)

\glossaryitem{array} or array variable: a component whose components are array
elements. For an array, the ordering of its components matters: The kth
element in the sequence of components of an array x is the array element
with index \lstinline!k!, denoted \lstinline!x[k]!. All elements of an array have the same
type. An array element may again be an array, i.e.\ arrays can be nested.
An array element is hence referenced using n indices in general, where n
is the number of dimensions of the array. Special cases are matrix (n=2)
and vector (n=1). Integer indices start with 1, not zero. (See \cref{arrays}.)
\glossaryitem{array} or array variable: a component whose components are array elements. For an array, the ordering of its components matters: The kth element in the sequence of components of an array x is the array element with index \lstinline!k!, denoted \lstinline!x[k]!. All elements of an array have the same type. An array element may again be an array, i.e.\ arrays can be nested. An array element is hence referenced using $n$ indices in general, where $n$ is the number of dimensions of the array. Special cases are matrix ($n=2$) and vector ($n=1$). \lstinline!Integer! indices start with 1, not zero. (See \cref{arrays}.)

\glossaryitem{array constructor}: an array can be built using the
\lstinline!array! function -- with the shorthand \lstinline!{a, b, $\ldots$}! -- and can also
Expand Down Expand Up @@ -144,9 +137,7 @@ \chapter{Glossary}\label{glossary}
\glossaryitem{identifier} or ident: an atomic (not composed) name. Example:
\lstinline!Resistor! (See \cref{identifiers-names-and-keywords}.)

\glossaryitem{index} or \glossaryitem{subscript}: An expression, typically of
Integer type or the colon symbol (:), used to reference a component (or
a range of components) of an array. (See \cref{array-indexing}.)
\glossaryitem{index} or \glossaryitem{subscript}: An expression, typically of \lstinline!Integer! type or the colon symbol (\lstinline!:!), used to reference a component (or a range of components) of an array. (See \cref{array-indexing}.)

\glossaryitem{inheritance interface} or \glossaryitem{class type}: property of a
class, consisting of a number of attributes and a set of public or
Expand Down
10 changes: 3 additions & 7 deletions chapters/overloaded.tex
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,9 @@ \section{Matching Function}\label{matching-function}
...
end f;
\end{lstlisting}
The vector P indicates whether argument m of f has a default value
(\lstinline!true! for default value, \lstinline!false! otherwise). A call
f($A_1$, $a_{2}$,\ldots{}, $a_{k}$,
$b_{1}$ = $w_{1}$ ,\ldots{}, $b_{p}$=
$w_{p}$) with distinct names $b_{j}$ is a valid
match for the function f, provided (treating Integer and Real as the
same type)
The vector P indicates whether argument m of f has a default value (\lstinline!true! for default value, \lstinline!false! otherwise). A call
f($A_1$, $a_{2}$,\ldots{}, $a_{k}$, $b_{1}$ = $w_{1}$ ,\ldots{}, $b_{p}$ = $w_{p}$)
with distinct names $b_{j}$ is a valid match for the function f, provided (treating \lstinline!Integer! and \lstinline!Real! as the same type)

\begin{itemize}
\item
Expand Down
18 changes: 8 additions & 10 deletions chapters/revisions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ \subsection{Main changes in Modelica 3.4}\label{main-changes-in-modelica-3-4}
Flattening is clearly specified (MCP-0019), \cref{simple-name-lookup} and \cref{flattening-process}.
Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1829}{\#1829}.
\item
Convert from Integer to Enumeration (MCP-0022), primarily
\cref{type-conversion-of-integer-to-enumeration-values}. Ticket
\href{https://github.com/modelica/ModelicaSpecification/issues/1842}{\#1842}.
Convert from \lstinline!Integer! to Enumeration (MCP-0022), primarily \cref{type-conversion-of-integer-to-enumeration-values}.
Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1842}{\#1842}.
\item
Explicitly casting a Model to Record (MCP-0023), \cref{casting-to-record}.
Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1953}{\#1953}.
Expand Down Expand Up @@ -566,8 +565,8 @@ \subsection{Main changes in Modelica 3.3 Revision 1}\label{main-changes-in-model
check); \cref{restrictions-of-connections-and-connectors}. Ticket
\href{https://github.com/modelica/ModelicaSpecification/issues/1284}{\#1284}.
\item
Clarified arrays with non-Integer dimensions, \cref{array-declarations}. Ticket
\href{https://github.com/modelica/ModelicaSpecification/issues/1501}{\#1501}.
Clarified arrays with non-\lstinline!Integer! dimensions, \cref{array-declarations}.
Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1501}{\#1501}.
\item
Clarified that ndims is allow for a scalar, \cref{array-dimension-and-size-functions}. Ticket
\href{https://github.com/modelica/ModelicaSpecification/issues/1303}{\#1303}.
Expand All @@ -582,8 +581,8 @@ \subsection{Main changes in Modelica 3.3 Revision 1}\label{main-changes-in-model
\cref{array-constructor-with-iterators}. Ticket
\href{https://github.com/modelica/ModelicaSpecification/issues/1521}{\#1521}.
\item
Clarified arrays with non-Integer dimensions, \cref{indexing-with-boolean-or-enumeration-values}. Ticket
\href{https://github.com/modelica/ModelicaSpecification/issues/1463}{\#1463}.
Clarified arrays with non-\lstinline!Integer! dimensions, \cref{indexing-with-boolean-or-enumeration-values}.
Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/1463}{\#1463}.
\item
Clarified calling function as specialized class, \cref{function-as-a-specialized-class}. Ticket
\href{https://github.com/modelica/ModelicaSpecification/issues/1362}{\#1362}.
Expand Down Expand Up @@ -2038,10 +2037,9 @@ \subsection{Main Changes in Modelica 2.1}\label{main-changes-in-modelica-2-1}
\item
Statement \lstinline!return! in a Modelica function.
\item
Built-in function \lstinline!String! to provide a string representation of \lstinline!Boolean!, \lstinline!Integer!, \lstinline!Real! and \lstinline!Enumeration! types.
Built-in function \lstinline!String! to provide a string representation of \lstinline!Boolean!, \lstinline!Integer!, \lstinline!Real! and enumeration types.
\item
Built-in function \lstinline!Integer! to provide the \lstinline!Integer! representation of
an \lstinline!Enumeration! type.
Built-in function \lstinline!Integer! to provide the \lstinline!Integer! representation of an enumeration type.
\item
Built-in function \lstinline!semiLinear! to define a characteristics with two
slopes and a set of rules for symbolic transformations, especially
Expand Down
2 changes: 1 addition & 1 deletion chapters/scoping.tex
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ \subsubsection{Steps of Instantiation}\label{steps-of-instantiation}
\item
Instantiate the \lstinline!M.b.a.p! using the class \lstinline!E! inheriting from \lstinline!Integer! with modifier \lstinline!=1!
\item
Instantiate the base-class Integer with modifier \lstinline!=1!, and insert as unnamed node in \lstinline!M.b.a.p!.
Instantiate the base-class \lstinline!Integer! with modifier \lstinline!=1!, and insert as unnamed node in \lstinline!M.b.a.p!.
\end{enumerate}
\end{enumerate}

Expand Down
32 changes: 15 additions & 17 deletions chapters/statements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -199,45 +199,43 @@ \subsection{For-statement}\label{for-statement}

\begin{example}
\begin{lstlisting}[language=modelica]
for i in 1:10 loop // i takes the values 1,2,3,...,10
for i in 1 : 10 loop // i takes the values 1, 2, 3, ..., 10
for r in 1.0 : 1.5 : 5.5 loop // r takes the values 1.0, 2.5, 4.0, 5.5
for i in {1,3,6,7} loop // i takes the values 1, 3, 6, 7
for i in {1, 3, 6, 7} loop // i takes the values 1, 3, 6, 7
for i in TwoEnums loop // i takes the values TwoEnums.one, TwoEnums.two
// for TwoEnums = enumeration(one,two)
// for TwoEnums = enumeration(one, two)
\end{lstlisting}
The loop-variable may hide other variables as in the following
example. Using another name for the loop-variable is, however, strongly
recommended.
The loop-variable may hide other variables as in the following example. Using another name for the loop-variable is, however, strongly recommended.
\begin{lstlisting}[language=modelica]
constant Integer j=4;
constant Integer j = 4;
Real x[j];
equation
for j in 1:j loop // The loop-variable j takes the values 1,2,3,4
x[j]=j; // Uses the loop-variable j
for j in 1:j loop // The loop-variable j takes the values 1, 2, 3, 4
x[j] = j; // Uses the loop-variable j
end for;
\end{lstlisting}
\end{example}

\subsubsection{Implicit Iteration Ranges}\label{implicit-iteration-ranges}

An iterator \lstinline!IDENT in range-expr! without the \lstinline!in range-expr! requires that the \lstinline!IDENT! appears as the subscript of one or several subscripted expressions, where the expressions are not part of an array in a component of an expandable connector. The dimension size of the array expression in the indexed position is used to deduce the \lstinline!range-expr! as \lstinline!1:size(array-expression,indexpos)! if the indices are a subtype of Integer, or as \lstinline!E.e1:E.en! if the indices are of an enumeration type \lstinline!E = enumeration(e1, $\ldots$, en)!, or as \lstinline!false:true! if the indices are of type \lstinline!Boolean!. If it is used to subscript several expressions, their ranges must be identical. The \lstinline!IDENT! may also, inside a reduction-expression, array constructor expression, for-statement, or for-equation, occur freely outside of subscript positions, but only as a reference to the variable \lstinline!IDENT!, and not for deducing ranges.
An iterator \lstinline!IDENT in range-expr! without the \lstinline!in range-expr! requires that the \lstinline!IDENT! appears as the subscript of one or several subscripted expressions, where the expressions are not part of an array in a component of an expandable connector. The dimension size of the array expression in the indexed position is used to deduce the \lstinline!range-expr! as \lstinline!1:size(array-expression,indexpos)! if the indices are a subtype of \lstinline!Integer!, or as \lstinline!E.e1:E.en! if the indices are of an enumeration type \lstinline!E = enumeration(e1, $\ldots$, en)!, or as \lstinline!false:true! if the indices are of type \lstinline!Boolean!. If it is used to subscript several expressions, their ranges must be identical. The \lstinline!IDENT! may also, inside a reduction-expression, array constructor expression, for-statement, or for-equation, occur freely outside of subscript positions, but only as a reference to the variable \lstinline!IDENT!, and not for deducing ranges.

The \lstinline!IDENT! may also be used as a subscript for an array in a component of an expandable connector
but it is only seen as a reference to the variable \lstinline!IDENT! and cannot be used for deducing ranges.

\begin{example}
\begin{lstlisting}[language=modelica]
Real x[4];
Real xsquared[:]={x[i]*x[i] for i};
// Same as: {x[i]*x[i] for i in 1:size(x,1)}
Real xsquared2[size(x,1)];
Real xsquared3[size(x,1)];
Real xsquared[:] = {x[i] * x[i] for i};
// Same as: {x[i] * x[i] for i in 1 : size(x, 1)}
Real xsquared2[size(x, 1)];
Real xsquared3[size(x, 1)];
equation
for i loop // Same as: for i in 1:size(x,1) loop ...
xsquared2[i]=x[i]^2;
for i loop // Same as: for i in 1 : size(x, 1) loop ...
xsquared2[i] = x[i]^2;
end for;
algorithm
for i loop // Same as: for i in 1:size(x,1) loop ...
for i loop // Same as: for i in 1 : size(x, 1) loop ...
xsquared3[i] := x[i]^2;
end for;
\end{lstlisting}
Expand Down

0 comments on commit 657b9fb

Please sign in to comment.