Skip to content

Commit

Permalink
Migrate glossary terms on 'A'
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Dec 6, 2020
1 parent 4367faf commit 28423cf
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 67 deletions.
46 changes: 28 additions & 18 deletions chapters/arrays.tex
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ \section{Array Declarations}\label{array-declarations}
There is no distinction between a row and column vector.
\end{nonnormative}

The following table shows the two possible forms of declarations and
defines the terminology. \lstinline!C! is a placeholder for any class, including the
built-in type classes \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, \lstinline!String!, and enumeration
types. The type of a dimension upper bound expression, e.g.\ $n$, $m$, $p$, \ldots
in the table below, need to be a subtype of \lstinline!Integer! or \lstinline!EB! for a class \lstinline!EB!
that is an enumeration type or subtype of the \lstinline!Boolean! type.
The following table shows the two possible forms of declarations and defines the terminology.
% Is the use of "class" here meant to exclude types defined as array aliases (see comment in table below)?
\lstinline!C! is a placeholder for any class, including the built-in type classes \lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, \lstinline!String!, and enumeration types.
The type of a dimension upper bound expression, e.g.\ $n$, $m$, $p$, \ldots in the table below, need to be a subtype of \lstinline!Integer! or \lstinline!EB! for a class \lstinline!EB! that is an enumeration type or subtype of the \lstinline!Boolean! type.

Colon (\lstinline!:!) indicates that the dimension upper bound is unknown and is a subtype of \lstinline!Integer!. The size of such a variable can be determined from its binding equation, or the
size of any of its array attributes, see also \cref{flexible-array-sizes-and-resizing-of-arrays-in-functions}. The size cannot be determined from other equations or algorithm.
Expand All @@ -61,6 +59,7 @@ \section{Array Declarations}\label{array-declarations}

% IMPROVETOP
\begin{table}[H]
% henrikt-ma: Doesn't the "Designation" and "Explanation" here assume that C is of non-array type?
\caption{General forms of declaration of arrays. The notation \lstinline!EB! stands for an enumeration type or \lstinline!Boolean!. The general array array can have zero or more dimensions ($k \geq 0$).}
\begin{center}
\begin{tabular}{l l c l l}
Expand All @@ -79,6 +78,21 @@ \section{Array Declarations}\label{array-declarations}
\end{center}
\end{table}

% henrikt-ma: The following paragraph was only modified slightly when migrated from the old glossary to the index, and seems to be in need of more attention:
A component declared with array dimensions, or where the element type is an array type, is called an \firstuse{array variable}\index{array variable}.
It is a component whose components are \willintroduce{array elements} (see below).
For an array variable, the ordering of its components matters:
The $k$:th element in the sequence of components of an array variable \lstinline!x! is the array element with index \lstinline!k!, denoted \lstinline!x[k]!.
% henrikt-ma: The following statement seems like an over-simplification; for Flat Modelica, we've spent some time trying to figure out how to deal with the fact that Modelica arrays are not homogenous in general...
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.

% henrikt-ma: The following paragraph was only modified slightly when migrated from the old glossary to the index, and seems to be in need of more attention:
A component contained in an array variable is called an \firstuse{array element}\index{array element}.
An array element has no identifier.
Instead they are referenced by array access expressions called indices that use enumeration values or positive integer index values.

\begin{example}
The number of dimensions and the dimensions sizes are part of
the type, and shall be checked for example at redeclarations.
Expand Down Expand Up @@ -698,7 +712,7 @@ \subsection{Matrix and Vector Algebra Functions}\label{matrix-and-vector-algebra

\section{Vector, Matrix and Array Constructors}\label{vector-matrix-and-array-constructors}

The constructor function \lstinline!array(A, B, C, $\ldots$)! constructs an array from its arguments according to the following rules:
The \firstuse{array constructor}\index{array constructor} function \lstinline!array(A, B, C, $\ldots$)! constructs an array from its arguments according to the following rules:
\begin{itemize}
\item
Size matching: All arguments must have the same sizes, i.e.,
Expand Down Expand Up @@ -743,11 +757,9 @@ \subsection{Array Constructor with Iterators}\label{array-constructor-with-itera
\begin{lstlisting}[language=grammar]
array "(" expression for iterators ")"
\end{lstlisting}

is an array constructor with iterators. The expressions inside the
iterators of an array constructor shall be vector expressions. They are
evaluated once for each array constructor, and are evaluated in the
scope immediately enclosing the array constructor.
is an \firstuse{array constructor with iterators}\index{array constructor!with iterators}.
The expressions inside the iterators of an array constructor shall be vector expressions.
They are evaluated once for each array constructor, and are evaluated in the scope immediately enclosing the array constructor.

For an iterator:
\begin{lstlisting}[language=modelica]
Expand Down Expand Up @@ -949,12 +961,10 @@ \section{Array Indexing}\label{array-indexing}
number of index arguments is smaller than the number of dimensions of
the array, the trailing indices will use `\lstinline!:!'.

It is also possible to use the array access operator to assign to
element/elements of an array in algorithm sections. If the index is an
array the assignments take place in the order given by the index array.
For assignments to arrays and elements of arrays, the entire right-hand
side and the index on the left-hand side are evaluated before any
element is assigned a new value.
It is also possible to use the array access operator to assign to element/elements of an array in algorithm sections.
This is called an \firstuse{indexed assignment statement}\index{assignment statement!indexed}.
If the index is an array the assignments take place in the order given by the index array.
For assignments to arrays and elements of arrays, the entire right-hand side and the index on the left-hand side are evaluated before any element is assigned a new value.

\begin{nonnormative}
An indexing operation is assumed to take constant time, i.e., largely independent of the size of the array.
Expand Down
18 changes: 8 additions & 10 deletions chapters/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1287,16 +1287,14 @@ \section{Balanced Models}\label{balanced-models}

\section{Predefined Types and Classes}\label{predefined-types-and-classes}

The attributes of the predefined variable types (\lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!,
\lstinline!String!) and \lstinline!enumeration! types are described below with Modelica syntax
although they are predefined. Attributes cannot be accessed using dot
notation, and are not constrained by equations and algorithm sections.
E.g.\ in \lstinline!Real x(unit="kg") = y;! only the values of \lstinline!x! and \lstinline!y! are declared
to be equal, but not their \lstinline!unit! attributes, nor any other attribute of \lstinline!x!
and \lstinline!y!. It is not possible to combine extends from the predefined types,
enumeration types, or this \lstinline!Clock! type with other components. The names
\lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean! and \lstinline!String! are reserved such that it is illegal
to declare an element with these names.
The \firstuse{attributes}\index{attribute} of the predefined variable types (\lstinline!Real!, \lstinline!Integer!, \lstinline!Boolean!, \lstinline!String!) and \lstinline!enumeration! types are described below with Modelica syntax although they are predefined.
All attributes are predefined and attribute values can only be defined using a modification, such as in \lstinline!Real x(unit = "kg")!.
Attributes cannot be accessed using dot notation, and are not constrained by equations and algorithm sections.
E.g.\ in \lstinline!Real x(unit = "kg") = y;! only the values of \lstinline!x! and \lstinline!y! are declared to be equal, but not their \lstinline!unit! attributes, nor any other attribute of \lstinline!x! and \lstinline!y!.

It is not possible to combine extends from the predefined types, enumeration types, or this \lstinline!Clock! type with other components.

The names \lstinline!Real!\index{Real@\robustinline{Real}!reserved name}, \lstinline!Integer!\index{Integer@\robustinline{Integer}!reserved name}, \lstinline!Boolean!\index{Boolean@\robustinline{Boolean}!reserved name} and \lstinline!String!\index{String@\robustinline{String}!reserved name} are reserved such that it is illegal to declare an element with these names.

\begin{nonnormative}
Hence, it is possible to define a normal class called \lstinline!Clock! in a package and extend from it.
Expand Down
33 changes: 0 additions & 33 deletions chapters/glossary.tex
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
\chapter{Glossary}\label{glossary}
\glossaryitem{algorithm section}: part of a class definition consisting of the
keyword \lstinline!algorithm! followed by a sequence of statements. Like an
equation, an algorithm section relates variables, i.e.\ constrains the
values that these variables can take simultaneously. In contrast to an
equation section, an algorithm section distinguishes inputs from
outputs: An algorithm section specifies how to compute output variables
as a function of given input variables. A Modelica processor may
actually invert an algorithm section, i.e.\ compute inputs from given
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$). \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
include an iterator to build an array of expressions. (See \cref{vector-matrix-and-array-constructors}.)

\glossaryitem{array element}: a component contained in an array. An array
element has no identifier. Instead they are referenced by array access
expressions called indices that use enumeration values or positive
integer index values. (See \cref{arrays}.)

\glossaryitem{assignment}: a statement of the form \lstinline!x := expr!. The expression
\lstinline!expr! must not have higher variability than~x. (See \cref{simple-assignment-statements}.)

\glossaryitem{attribute}: a component contained in a scalar component, such as
\lstinline!min!, \lstinline!max!, and \lstinline!unit!. All attributes are predefined and attribute values
can only be defined using a modification, such as in \lstinline!Real x(unit="kg")!.
Attributes cannot be accessed using dot notation, and are not
constrained by equations and algorithm sections. E.g.\ in \lstinline!Real x(unit="kg") = y;! only the values of \lstinline!x! and
\lstinline!y! are declared to be equal,
but not their unit attributes, nor any other attribute of \lstinline!x! and \lstinline!y!. (See
\cref{predefined-types-and-classes}.)

\glossaryitem{base class}: class A is called a base class of B, if class B
extends class A. This relation is specified by an extends clause in B or
Expand Down
3 changes: 1 addition & 2 deletions chapters/operatorsandexpressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,7 @@ \section{Variability of Expressions}\label{variability-of-expressions}
restrictions that simplify reasoning and reporting of errors:
\begin{itemize}
\item
For an assignment \lstinline!v:=expr! or binding equation \lstinline!v=expr!, \lstinline!v! must be declared
to be at least as variable as \lstinline!expr!.
For an assignment \lstinline!v := expr! or binding equation \lstinline!v = expr!, \lstinline!v! must be declared to be at least as variable as \lstinline!expr!.
\item
When determining whether an equation can contribute to solving for a variable \lstinline!v! (for instance,
when applying the perfect matching rule, see \cref{synchronous-data-flow-principle-and-single-assignment-rule}),
Expand Down
14 changes: 10 additions & 4 deletions chapters/statements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ \chapter{Statements and Algorithm Sections}\label{statements-and-algorithm-secti

\section{Algorithm Sections}\label{algorithm-sections}

An algorithm section is comprised of the keyword \lstinline!algorithm!\index{algorithm@\robustinline{algorithm}} followed by a sequence of statements.
An \firstuse{algorithm section}\index{algorithm section} is a part of a class definition comprised of the keyword \lstinline!algorithm!\index{algorithm@\robustinline{algorithm}} followed by a sequence of statements.
The formal syntax is as follows:
\begin{lstlisting}[language=grammar]
algorithm-section :
[ initial ] algorithm { statement ";" | annotation ";" }
\end{lstlisting}

Equation equality \lstinline!=! or any other kind of equation (see \cref{equations}) shall
not be used in an algorithm section.
Like an equation, an algorithm section relates variables, i.e., constrains the values that these variables can take simultaneously.
In contrast to an equation section, an algorithm section distinguishes inputs from outputs:
An algorithm section specifies how to compute output variables as a function of given input variables.
A Modelica tool may actually invert an algorithm section, i.e., compute inputs from given outputs, e.g., by search (generate and test), or by deriving an inverse algorithm symbolically.

Equation equality \lstinline!=! or any other kind of equation (see \cref{equations}) shall not be used in an algorithm section.

\subsection{Initial Algorithm Sections}\label{initial-algorithm-sections}

Expand Down Expand Up @@ -120,14 +124,16 @@ \section{Statements}\label{statements}

\subsection{Simple Assignment Statements}\label{simple-assignment-statements}

The syntax of simple assignment statement is as follows:
The syntax of simple assignment\index{assignment} statement is as follows:
\begin{lstlisting}[language=grammar]
component-reference ":=" expression
\end{lstlisting}

The \lstinline[language=grammar]!expression! is evaluated.
The resulting value is stored into the variable denoted by \lstinline[language=grammar]!component-reference!.

The \lstinline!expression! must not have higher variability than the assigned component, see \cref{variability-of-expressions}.

Assignment to array variables with subscripts is described in \cref{array-indexing}.


Expand Down

0 comments on commit 28423cf

Please sign in to comment.