\HeaderA{matmult}{Matrix Multiplication}{matmult}
\aliasA{\%*\%}{matmult}{.Rpcent.*.Rpcent.}
\keyword{array}{matmult}
\keyword{arith}{matmult}
\begin{Description}\relax
Multiplies two matrices, if they are conformable.
If one argument is a vector, it will be promoted to either a row or
column matrix to make the two arguments conformable.
If both are vectors it will return the inner product.
\end{Description}
\begin{Usage}
\begin{verbatim}
x %*% y
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x, y}] numeric or complex matrices or vectors.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
When a vector is promoted to a matrix, its names are not
promoted to row or column names, unlike \code{\LinkA{as.matrix}{as.matrix}}.

This operator is S4 generic but not S3 generic.  S4 methods need to be
written for a function of two arguments named \code{x} and \code{y}.
\end{Details}
\begin{Value}
The matrix product.  Use \code{\LinkA{drop}{drop}} to get rid of dimensions
which have only one level.
\end{Value}
\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{\LinkA{matrix}{matrix}},
\code{\LinkA{Arithmetic}{Arithmetic}},
\code{\LinkA{diag}{diag}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- 1:4
(z <- x %*% x)    # scalar ("inner") product (1 x 1 matrix)
drop(z)             # as scalar

y <- diag(x)
z <- matrix(1:12, ncol = 3, nrow = 4)
y %*% z
y %*% x
x %*% z
\end{ExampleCode}
\end{Examples}

