\Header{outer}{Outer Product of Arrays}
\alias{\%o\%}{outer}
\keyword{array}{outer}
\begin{Description}\relax
The outer product of the arrays \code{X} and \code{Y} is the array
\code{A} with dimension \code{c(dim(X), dim(Y))} where element
\code{A[c(arrayindex.x, arrayindex.y)]
    = FUN(X[arrayindex.x], Y[arrayindex.y], ...)}.
\end{Description}
\begin{Usage}
\begin{verbatim}
outer(X, Y, FUN="*", ...)
X %o% Y
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{X}] A vector or array.
\item[\code{Y}] A vector or array.
\item[\code{FUN}] a function to use on the outer products, it may be a quoted
string.
\item[\code{...}] optional arguments to be passed to \code{FUN}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{FUN} must be a function (or the name of it) which expects at
least two arguments and which operates elementwise on arrays.

Where they exist, the [dim]names of \code{X} and \code{Y} will be
preserved.

\code{\%o\%} is an alias for \code{outer} (where \code{FUN}
cannot be changed from \code{"*"}).
\end{Details}
\begin{Author}\relax
Jonathan Rougier
\end{Author}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\Link{\%*\%}} for usual (\emph{inner}) matrix vector
multiplication;
\code{\Link{kronecker}} which is based on \code{outer}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- 1:9; names(x) <- x
# Multiplication & Power Tables
x %o% x
y <- 2:8; names(y) <- paste(y,":",sep="")
outer(y, x, "^")

outer(month.abb, 1999:2003, FUN = "paste")

## three way multiplication table:
x %o% x %o% y[1:3]
\end{ExampleCode}
\end{Examples}

