next up previous contents
Next: Effect and Restrictions Up: The Java Adlib API Previous: Effect and Restrictions   Contents

DotProduct

A dotProduct() method is a reduction operation for computing the dot product of two distributed arrays. The function dotProduct takes two aligned arrays as arguments and returns their scalar product--the sum of pairwise products of elements. The situation with element types is complicated because the types of the two arguments need not be identical. If they are different, standard Java binary numeric promotions are applied before multiplying elements. The prototypes are

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{tabbing}
\verb$ $$t_3...
... dotProduct($$t_1$\verb$  ...

and

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{tabbing}
\verb$ boolean dotProduct(boolean  ...

If either of $ t_1$ or $ t_2$ is a floating point type (float or double) the result type, $ t_3$, is double). Otherwise the result type $ t_3$ is long. The second form takes boolean as the arguments and returns the logical ``or'' of all the pairwise logical ``ands'' of elements. The argument multiarrays must have the same shape and must be aligned. The result is broadcasts to all members of the active process group. The dotProduct method is implemented by a schedule object with HPspmd class DotProduct$ t$. Each pair of primitive types other than boolean has its own schedule class. This class has a constructor with arguments identical to the method above, and has one public method with no arguments called execute(), which executes the schedule. The effective public interface of the DotProduct$ t$ class is

$\displaystyle \begin{minipage}[t]{\linewidth}\small\verb$ public class DotProdu...
...t_3$\verb$ execute () { ... }$\\
\verb$ . . .$\\
\verb$ }$
\end{minipage}
$

All primitive type of Java combination other than boolean type is possible for $ t_1$ and $ t_2$. Type of $ t_3$ is depends on the type of arguments $ t_1$ and $ t_2$.

Subsections
next up previous contents
Next: Effect and Restrictions Up: The Java Adlib API Previous: Effect and Restrictions   Contents
Bryan Carpenter 2004-06-09