next up previous contents
Next: Integer subscripts in sequential Up: Translation of array sections Previous: Translation of array sections   Contents

Simple array section - no scalar subscripts

Figure 4.16 represents a schema for translating array section with no scalar subscripts. The macro PROCESS_SUBSCRIPTS will be defined here in a tail-recursive way. The intention is that it should be expanded to a compile-time loop over $ s$. Let $ R$ be the rank of the subscripted array. If $ s = R$, then the macro

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\small\begin{tabbing}
$\mbo...
...a, s\right) \equiv \emptyset$\
\end{tabbing}
\end{minipage}
\end{displaymath}

Otherwise, if subs$ _s$ is the degenerate triplet, :, then

Otherwise, if subs$ _s$ is the triplet, $ e_{\mbox{\small lo}}$: $ e_{\mbox{\small hi}}$: $ e_{\mbox{\small stp}}$, and the $ s$th dimension of $ a$ is distributed, then

where $ a'_s = {\bf T}_{s}\left[{a}\right]$, , $ e_{\mbox{\small hi}}' = {\bf T}\left[{e_{\mbox{\small hi}}}\right]$, and $ e_{\mbox{\small stp}}' = {\bf T}\left[{e_{\mbox{\small stp}}}\right]$. Otherwise, if subs$ _s$ is the triplet, $ e_{\mbox{\small lo}}$: $ e_{\mbox{\small hi}}$: $ e_{\mbox{\small stp}}$, and the $ s$th dimension of $ a$ is sequential, then

with definitions as above. Two similar cases using the two-argument form of subrng() take care of triplets of the form $ e_{\mbox{\small lo}}$: $ e_{\mbox{\small hi}}$. Otherwise, if subs$ _s$ is the splitting subscript, <>, then

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\small\begin{tabbing}
$\mbo...
...TS}\left(v, r+2, a, s+1\right)$
\end{tabbing}
\end{minipage}
\end{displaymath}

where $ x$, $ u$, and are the names of new temporaries.

Figure 4.16: Translation of array section without any scalar subscripts in distributed dimensions.

SOURCE:

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{tabbing}
$v$\verb$ = $$a$\verb$ [[$$$subs$\displaystyle _0 \verb$, $ \ldots \verb$, $$subs$\displaystyle _{R-1}$\verb$]] ;$
\end{tabbing}
\end{minipage}
$

TRANSLATION:

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{tabbing}
\verb$int $...
... = new ArrayBase($$p$\verb$, $$b$\verb$) ;$ \\
\end{tabbing}
\end{minipage}
$

where:



next up previous contents
Next: Integer subscripts in sequential Up: Translation of array sections Previous: Translation of array sections   Contents
Bryan Carpenter 2004-06-09