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

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

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

