\Header{kronecker}{Kronecker Product of Arrays}
\alias{\%x\%}{kronecker}
\keyword{array}{kronecker}
\begin{Description}\relax
Computes the generalised kronecker product of two arrays,
\code{X} and \code{Y}.  \code{kronecker(X, Y)} returns an array
\code{A} with dimensions \code{dim(X) * dim(Y)}.\end{Description}
\begin{Usage}
\begin{verbatim}
kronecker(X, Y, FUN = "*", ...)
X %x% Y
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{X}] vector or array.
\item[\code{Y}] vector or array.
\item[\code{FUN}] a function, possibly specified as character (string).
\item[\code{...}] optional arguments to be passed to \code{FUN}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If \code{X} and \code{Y} do not have the same number of dimensions,
the smaller array is padded with dimensions of size one.  \code{A}
consists of submatrices constructed by taking \code{X} one term at a time
and expanding that term as \code{FUN(x, Y, ...)}.

\code{\%x\%} is an \code{\Link{.Alias}} for \code{kronecker} (where
\code{FUN} is hardwired to \code{"*"}).\end{Details}
\begin{Author}\relax
Jonathan Rougier\end{Author}
\begin{References}\relax
Searle, Shayle R. (1982)
\emph{Matrix Algebra Useful for Statistics}; John Wiley and Sons.\end{References}
\begin{SeeAlso}\relax
\code{\Link{outer}} on which \code{kronecker} is built and
\code{\Link{matmult}} for usual matrix multiplication.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# simple scalar multiplication
( M <- matrix(1:6, ncol=2) )
stopifnot(kronecker(4, M) == 4 * M)

( A <- matrix(0:3, ncol=2) )
A %x% cbind(2:3)
# Block diagonal array:
kronecker(diag(3), M)
stopifnot(kronecker(diag(3), M) == diag(3) %x% M)
\end{ExampleCode}
\end{Examples}

