Skip to content

Commit

Permalink
More use of math for operator formal parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Sep 14, 2020
1 parent 2502257 commit 03a8fcb
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions chapters/operatorsandexpressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -379,64 +379,64 @@ \subsection{Numeric Functions and Conversion Functions}\label{numeric-functions-

\begin{operatordefinition*}[abs]
\begin{synopsis}\begin{lstlisting}
abs(v)
abs($v$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Expands into \lstinline!noEvent(if v >= 0 then v else -v)!. Argument \lstinline!v! needs to be an \lstinline!Integer! or \lstinline!Real! expression.
Expands into \lstinline!noEvent(if $v$ >= 0 then $v$ else -$v$)!. Argument $v$ needs to be an \lstinline!Integer! or \lstinline!Real! expression.
\end{semantics}
\end{operatordefinition*}

\begin{operatordefinition*}[sign]
\begin{synopsis}\begin{lstlisting}
sign(v)
sign($v$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Expands into \lstinline!noEvent(if v>0 then 1 else if v<0 then -1 else 0)!. Argument \lstinline!v! needs to be an \lstinline!Integer! or \lstinline!Real! expression.
Expands into \lstinline!noEvent(if $v$ > 0 then 1 else if $v$ < 0 then -1 else 0)!. Argument $v$ needs to be an \lstinline!Integer! or \lstinline!Real! expression.
\end{semantics}
\end{operatordefinition*}

\begin{operatordefinition*}[sqrt]
\begin{synopsis}\begin{lstlisting}
sqrt(v)
sqrt($v$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Square root of \lstinline!v! if $\text{\lstinline!v!} \geq 0$, otherwise an error occurs. Argument \lstinline!v! needs to be an \lstinline!Integer! or \lstinline!Real! expression.
Square root of $v$ if $v \geq 0$, otherwise an error occurs. Argument $v$ needs to be an \lstinline!Integer! or \lstinline!Real! expression.
\end{semantics}
\end{operatordefinition*}

\begin{operatordefinition*}[Integer]
\begin{synopsis}\begin{lstlisting}
Integer(e)
Integer($e$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Ordinal number of the expression \lstinline!e! of enumeration type that evaluates to the enumeration value \lstinline!E.enumvalue!, where \lstinline!Integer(E.e1) = 1!, \lstinline!Integer(E.en) = n!,
Ordinal number of the expression $e$ of enumeration type that evaluates to the enumeration value \lstinline!E.enumvalue!, where \lstinline!Integer(E.e1) = 1!, \lstinline!Integer(E.en) = n!,
for an enumeration type \lstinline!E = enumeration(e1, ..., en)!. See also \cref{type-conversion-of-enumeration-values-to-string-or-integer}.
\end{semantics}
\end{operatordefinition*}

\begin{operatordefinition*}[<EnumTypeName>]
\begin{synopsis}\begin{lstlisting}
EnumTypeName(i)
EnumTypeName($i$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
For any enumeration type \lstinline!EnumTypeName!, returns the enumeration value \lstinline!EnumTypeName.e! such that \lstinline!Integer(EnumTypeName.e) = i!. Refer to the definition of
For any enumeration type \lstinline!EnumTypeName!, returns the enumeration value \lstinline!EnumTypeName.e! such that $\text{\lstinline!Integer(EnumTypeName.e)!} = i$. Refer to the definition of
\lstinline!Integer! above.

It is an error to attempt to convert values of \lstinline!i! that do not correspond to values of the enumeration type. See also \cref{type-conversion-of-integer-to-enumeration-values}.
It is an error to attempt to convert values of $i$ that do not correspond to values of the enumeration type. See also \cref{type-conversion-of-integer-to-enumeration-values}.
\end{semantics}
\end{operatordefinition*}

\begin{operatordefinition*}[String]
\begin{synopsis}\begin{lstlisting}
String(b, <options>)
String(i, <options>)
String(r, significantDigits=d, <options>)
String(r, format=s)
String(e, <options>)
String($b$, <options>)
String($i$, <options>)
String($r$, significantDigits=$d$, <options>)
String($r$, format=$s$)
String($e$, <options>)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Convert a scalar non-\lstinline!String! expression to a \lstinline!String! representation. The first argument may be a \lstinline!Boolean b!, an \lstinline!Integer i!, a \lstinline!Real r! or an
enumeration value \lstinline!e! (\cref{type-conversion-of-enumeration-values-to-string-or-integer}). The other arguments must use named arguments. For \lstinline!Real! expressions the output shall be according to the Modelica grammar.
Convert a scalar non-\lstinline!String! expression to a \lstinline!String! representation. The first argument may be a \lstinline!Boolean! $b$, an \lstinline!Integer! $i$, a \lstinline!Real! $r$ or an
enumeration value $e$ (\cref{type-conversion-of-enumeration-values-to-string-or-integer}). The other arguments must use named arguments. For \lstinline!Real! expressions the output shall be according to the Modelica grammar.

The optional \lstinline!<options>! are:
\begin{itemize}
Expand Down Expand Up @@ -489,10 +489,10 @@ \subsubsection{Event Triggering Mathematical Functions}\label{event-triggering-m

\begin{operatordefinition}[div]
\begin{synopsis}\begin{lstlisting}
div(x, y)
div($x$, $y$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Returns the algebraic quotient \lstinline!x / y! with any fractional part discarded (also known as truncation toward zero).
Returns the algebraic quotient $x / y$ with any fractional part discarded (also known as truncation toward zero).
\begin{nonnormative}
This is defined for \lstinline!/! in C99; in C89 the result for negative numbers is implementation-defined, so the standard function \lstinline[language=C]!div! must be used.
\end{nonnormative}
Expand All @@ -502,10 +502,10 @@ \subsubsection{Event Triggering Mathematical Functions}\label{event-triggering-m

\begin{operatordefinition}[mod]
\begin{synopsis}\begin{lstlisting}
mod(x, y)
mod($x$, $y$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Returns the integer modulus of \lstinline!x / y!, i.e. \lstinline!mod(x, y) = x - floor(x / y) * y!. Result and arguments shall have type \lstinline!Real! or \lstinline!Integer!. If either of the arguments is \lstinline!Real! the result is \lstinline!Real! otherwise \lstinline!Integer!.
Returns the integer modulus of $x / y$, i.e. \lstinline!mod($x$, $y$) = $x$ - floor($x$ / $y$) * $y$!. Result and arguments shall have type \lstinline!Real! or \lstinline!Integer!. If either of the arguments is \lstinline!Real! the result is \lstinline!Real! otherwise \lstinline!Integer!.
\begin{nonnormative}
Note, outside of a when-clause state events are triggered when the return value changes discontinuously. Examples: \lstinline!mod(3, 1.4) = 0.2!, \lstinline!mod(-3, 1.4) = 1.2!, \lstinline!mod(3, -1.4) = -1.2!.
\end{nonnormative}
Expand All @@ -514,10 +514,10 @@ \subsubsection{Event Triggering Mathematical Functions}\label{event-triggering-m

\begin{operatordefinition}[rem]
\begin{synopsis}\begin{lstlisting}
rem(x, y)
rem($x$, $y$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Returns the integer remainder of \lstinline!x / y!, such that \lstinline!div(x, y) * y + rem(x, y) = x!. Result and arguments shall have type \lstinline!Real! or \lstinline!Integer!. If either of the arguments is \lstinline!Real! the result is \lstinline!Real! otherwise \lstinline!Integer!.
Returns the integer remainder of $x / y$, such that \lstinline!div($x$, $y$) * $y$ + rem($x$, $y$) = $x$!. Result and arguments shall have type \lstinline!Real! or \lstinline!Integer!. If either of the arguments is \lstinline!Real! the result is \lstinline!Real! otherwise \lstinline!Integer!.
\begin{nonnormative}
Note, outside of a when-clause state events are triggered when the return value changes discontinuously. Examples: \lstinline!rem(3, 1.4) = 0.2!, \lstinline!rem(-3, 1.4) = -0.2!.
\end{nonnormative}
Expand All @@ -526,10 +526,10 @@ \subsubsection{Event Triggering Mathematical Functions}\label{event-triggering-m

\begin{operatordefinition}[ceil]
\begin{synopsis}\begin{lstlisting}
ceil(x)
ceil($x$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Returns the smallest integer not less than \lstinline!x!. Result and argument shall have type \lstinline!Real!.
Returns the smallest integer not less than $x$. Result and argument shall have type \lstinline!Real!.
\begin{nonnormative}
Note, outside of a when-clause state events are triggered when the return value changes discontinuously.
\end{nonnormative}
Expand All @@ -538,10 +538,10 @@ \subsubsection{Event Triggering Mathematical Functions}\label{event-triggering-m

\begin{operatordefinition}[floor]
\begin{synopsis}\begin{lstlisting}
floor(x)
floor($x$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Returns the largest integer not greater than \lstinline!x!. Result and argument shall have type \lstinline!Real!.
Returns the largest integer not greater than $x$. Result and argument shall have type \lstinline!Real!.
\begin{nonnormative}
Note, outside of a when-clause state events are triggered when the return value changes discontinuously.
\end{nonnormative}
Expand All @@ -550,10 +550,10 @@ \subsubsection{Event Triggering Mathematical Functions}\label{event-triggering-m

\begin{operatordefinition}[integer]
\begin{synopsis}\begin{lstlisting}
integer(x)
integer($x$)
\end{lstlisting}\end{synopsis}
\begin{semantics}
Returns the largest integer not greater than \lstinline!x!. The argument shall have type \lstinline!Real!. The result has type \lstinline!Integer!.
Returns the largest integer not greater than $x$. The argument shall have type \lstinline!Real!. The result has type \lstinline!Integer!.
\begin{nonnormative}
Note, outside of a when-clause state events are triggered when the return value changes discontinuously.
\end{nonnormative}
Expand Down

0 comments on commit 03a8fcb

Please sign in to comment.