From 8ec8f29055a8e2da158db1ec25c2b74e5e0018c4 Mon Sep 17 00:00:00 2001 From: rhaas Date: Thu, 19 Apr 2012 00:15:34 +0000 Subject: expand expression language, add error checking, and more documentation git-svn-id: http://svn.cactuscode.org/flesh/trunk@4804 17b73243-c579-4c4c-a9d2-2d5706c11dac --- doc/UsersGuide/Notes.tex | 49 ++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'doc/UsersGuide') diff --git a/doc/UsersGuide/Notes.tex b/doc/UsersGuide/Notes.tex index ff0a6f42..d0d897bf 100644 --- a/doc/UsersGuide/Notes.tex +++ b/doc/UsersGuide/Notes.tex @@ -1318,48 +1318,61 @@ expressions in place of explicit values. The usual arithmetic operations as well as C-like transcendental functions and relational operations are supported. Integer division is handled as in C, and any non-null value is interpreted as logical true, which the relational operators return as unity. +The return value of any function whose arguments are integers will be +truncated towards zero. +The remainder operator \verb|%| is internally mapped to the \verb|fmod| +function for both integer and real valued arguments so inherits its +semantics. +The exponentiation operator \verb|**| as well as the unary operators +associate to the left which differs from the common convention in +mathematics. When in doubt use explicit parenthesis to force a desired +order of evaluation. Table~\ref{tab:expression_functions} lists the supported functions. Expressions can refer to already set parameters by using the fully qualified name \texttt{thorn::parameter} as described below. \begin{table} \begin{tabular}{|ll@{\hspace{.5cm}}|ll|} \hline - \multicolumn{2}{|c|}{Relational operators} & \multicolumn{2}{c|}{Mathematical functions} \\ + \multicolumn{2}{|c|}{Logical operators} & \verb|+| & no-op\\ \hline - \verb|=| & tests for equality & \verb|!| & logical not\\ + \verb|&&| & logical and & \verb|!| & logical not\\ \hline - \verb|<| & tests for less than & \verb|acos| & inverse cosine\\ + \verb%||% & logical or & \multicolumn{2}{c|}{Mathematical functions}\\ \hline - \verb|>| & tests for greater than & \verb|asin| & inverse sine\\ + \multicolumn{2}{|c|}{Relational operators} & \verb|acos| & inverse cosine\\ \hline - \verb|<=| & tests for less or equal & \verb|atan| & inverse tangent \\ + \verb|==| & tests for equality & \verb|asin| & inverse sine\\ \hline - \verb|>=| & tests for greater or equal & \verb|ceil| & round up to nearest integer \\ + \verb|!=| & tests for inequality & \verb|atan| & inverse tangent \\ \hline - \verb|&&| & logical and & \verb|cos| & cosine \\ + \verb|<| & tests for less than & \verb|ceil| & round up to nearest integer \\ \hline - \verb%||% & logical or & \verb|cosh| & hyperbolic cosine \\ + \verb|>| & tests for greater than & \verb|cos| & cosine \\ \hline - \multicolumn{2}{|c|}{Unary operators} & \verb|exp| & exponentiation $e^x$\\ + \verb|<=| & tests for less or equal & \verb|cosh| & hyperbolic cosine \\ \hline - \verb|-| & negate sign & \verb|fabs| & absolute value $|x|$\\ + \verb|>=| & tests for greater or equal & \verb|exp| & exponentiation $e^x$\\ \hline - \verb|+| & no-op & \verb|floor| & round down to nearest integer \\ + \multicolumn{2}{|c|}{Binary operators} & \verb|fabs| & absolute value $|x|$\\ \hline - \multicolumn{2}{|c|}{Binary operators} & \verb|log| & natural logarithm \\ + \verb|+| & addition & \verb|floor| & round down to nearest integer \\ \hline - \verb|+| & addition & \verb|log10| & base-10 logarithm \\ + \verb|-| & subtraction & \verb|log| & natural logarithm \\ \hline - \verb|-| & subtraction & \verb|sin| & sine \\ + \verb|/| & C-like division & \verb|log10| & base-10 logarithm \\ \hline - \verb|/| & C-like division & \verb|sinh| & hyperbolic sine \\ + \verb|%| & remainder of division & \verb|sin| & sine \\ \hline - \verb|*| & multiplication & \verb|sqrt| & square root \\ + \verb|*| & multiplication & \verb|sinh| & hyperbolic sine \\ \hline - \verb|^| & exponentiation $x^y$ & \verb|tan| & tangent \\ + \verb|**| & exponentiation $x^y$ & \verb|sqrt| & square root \\ \hline - & & \verb|tanh| & hyperbolic tangent \\ + \multicolumn{2}{|c|}{Unary operators} & \verb|tan| & tangent \\ \hline + \verb|-| & negate sign & \verb|tanh| & hyperbolic tangent \\ + \hline + & & \verb|trunc| & integer part of $x$\\ + \hline \end{tabular} \caption{Supported functions inside of expressions, in increasing order of precedence.} -- cgit v1.2.3