\HeaderA{Matrix-class}{Virtual Class "Matrix" Class of Matrices}{Matrix.Rdash.class}
\aliasA{"!,Matrix-method}{Matrix-class}{"!,Matrix.Rdash.method}
\aliasA{+,Matrix,missing-method}{Matrix-class}{+,Matrix,missing.Rdash.method}
\aliasA{-,Matrix,missing-method}{Matrix-class}{.Rdash.,Matrix,missing.Rdash.method}
\aliasA{Arith,Matrix,Matrix-method}{Matrix-class}{Arith,Matrix,Matrix.Rdash.method}
\aliasA{as.array,Matrix-method}{Matrix-class}{as.array,Matrix.Rdash.method}
\aliasA{as.logical,Matrix-method}{Matrix-class}{as.logical,Matrix.Rdash.method}
\aliasA{as.matrix,Matrix-method}{Matrix-class}{as.matrix,Matrix.Rdash.method}
\aliasA{as.numeric,Matrix-method}{Matrix-class}{as.numeric,Matrix.Rdash.method}
\aliasA{as.vector,Matrix,missing-method}{Matrix-class}{as.vector,Matrix,missing.Rdash.method}
\aliasA{cbind2,ANY,Matrix-method}{Matrix-class}{cbind2,ANY,Matrix.Rdash.method}
\aliasA{cbind2,atomicVector,Matrix-method}{Matrix-class}{cbind2,atomicVector,Matrix.Rdash.method}
\aliasA{cbind2,Matrix,ANY-method}{Matrix-class}{cbind2,Matrix,ANY.Rdash.method}
\aliasA{cbind2,Matrix,atomicVector-method}{Matrix-class}{cbind2,Matrix,atomicVector.Rdash.method}
\aliasA{cbind2,Matrix,Matrix-method}{Matrix-class}{cbind2,Matrix,Matrix.Rdash.method}
\aliasA{cbind2,Matrix,missing-method}{Matrix-class}{cbind2,Matrix,missing.Rdash.method}
\aliasA{cbind2,Matrix,NULL-method}{Matrix-class}{cbind2,Matrix,NULL.Rdash.method}
\aliasA{cbind2,NULL,Matrix-method}{Matrix-class}{cbind2,NULL,Matrix.Rdash.method}
\aliasA{coerce,Matrix,complex-method}{Matrix-class}{coerce,Matrix,complex.Rdash.method}
\aliasA{coerce,Matrix,CsparseMatrix-method}{Matrix-class}{coerce,Matrix,CsparseMatrix.Rdash.method}
\aliasA{coerce,Matrix,denseMatrix-method}{Matrix-class}{coerce,Matrix,denseMatrix.Rdash.method}
\aliasA{coerce,Matrix,integer-method}{Matrix-class}{coerce,Matrix,integer.Rdash.method}
\aliasA{coerce,Matrix,logical-method}{Matrix-class}{coerce,Matrix,logical.Rdash.method}
\aliasA{coerce,Matrix,matrix-method}{Matrix-class}{coerce,Matrix,matrix.Rdash.method}
\aliasA{coerce,matrix,Matrix-method}{Matrix-class}{coerce,matrix,Matrix.Rdash.method}
\aliasA{coerce,Matrix,numeric-method}{Matrix-class}{coerce,Matrix,numeric.Rdash.method}
\aliasA{coerce,Matrix,sparseMatrix-method}{Matrix-class}{coerce,Matrix,sparseMatrix.Rdash.method}
\aliasA{coerce,Matrix,vector-method}{Matrix-class}{coerce,Matrix,vector.Rdash.method}
\aliasA{cov2cor,Matrix-method}{Matrix-class}{cov2cor,Matrix.Rdash.method}
\aliasA{crossprod,ANY,Matrix-method}{Matrix-class}{crossprod,ANY,Matrix.Rdash.method}
\aliasA{crossprod,Matrix,ANY-method}{Matrix-class}{crossprod,Matrix,ANY.Rdash.method}
\aliasA{crossprod,Matrix,Matrix-method}{Matrix-class}{crossprod,Matrix,Matrix.Rdash.method}
\aliasA{crossprod,Matrix,matrix-method}{Matrix-class}{crossprod,Matrix,matrix.Rdash.method}
\aliasA{crossprod,matrix,Matrix-method}{Matrix-class}{crossprod,matrix,Matrix.Rdash.method}
\aliasA{crossprod,Matrix,numeric-method}{Matrix-class}{crossprod,Matrix,numeric.Rdash.method}
\aliasA{crossprod,numeric,Matrix-method}{Matrix-class}{crossprod,numeric,Matrix.Rdash.method}
\aliasA{determinant,Matrix,logical-method}{Matrix-class}{determinant,Matrix,logical.Rdash.method}
\aliasA{determinant,Matrix,missing-method}{Matrix-class}{determinant,Matrix,missing.Rdash.method}
\aliasA{diag,Matrix-method}{Matrix-class}{diag,Matrix.Rdash.method}
\aliasA{diff,Matrix-method}{Matrix-class}{diff,Matrix.Rdash.method}
\aliasA{dim,Matrix-method}{Matrix-class}{dim,Matrix.Rdash.method}
\aliasA{dim<-,Matrix-method}{Matrix-class}{dim<.Rdash.,Matrix.Rdash.method}
\aliasA{dimnames,Matrix-method}{Matrix-class}{dimnames,Matrix.Rdash.method}
\aliasA{dimnames<-,Matrix,list-method}{Matrix-class}{dimnames<.Rdash.,Matrix,list.Rdash.method}
\aliasA{dimnames<-,Matrix,NULL-method}{Matrix-class}{dimnames<.Rdash.,Matrix,NULL.Rdash.method}
\aliasA{drop,Matrix-method}{Matrix-class}{drop,Matrix.Rdash.method}
\aliasA{head,Matrix-method}{Matrix-class}{head,Matrix.Rdash.method}
\aliasA{length,Matrix-method}{Matrix-class}{length,Matrix.Rdash.method}
\aliasA{Logic,ANY,Matrix-method}{Matrix-class}{Logic,ANY,Matrix.Rdash.method}
\aliasA{Logic,logical,Matrix-method}{Matrix-class}{Logic,logical,Matrix.Rdash.method}
\aliasA{Logic,Matrix,ANY-method}{Matrix-class}{Logic,Matrix,ANY.Rdash.method}
\aliasA{Logic,Matrix,logical-method}{Matrix-class}{Logic,Matrix,logical.Rdash.method}
\aliasA{mean,Matrix-method}{Matrix-class}{mean,Matrix.Rdash.method}
\aliasA{Ops,ANY,Matrix-method}{Matrix-class}{Ops,ANY,Matrix.Rdash.method}
\aliasA{Ops,logical,Matrix-method}{Matrix-class}{Ops,logical,Matrix.Rdash.method}
\aliasA{Ops,Matrix,ANY-method}{Matrix-class}{Ops,Matrix,ANY.Rdash.method}
\aliasA{Ops,Matrix,logical-method}{Matrix-class}{Ops,Matrix,logical.Rdash.method}
\aliasA{Ops,Matrix,Matrix-method}{Matrix-class}{Ops,Matrix,Matrix.Rdash.method}
\aliasA{Ops,Matrix,matrix-method}{Matrix-class}{Ops,Matrix,matrix.Rdash.method}
\aliasA{Ops,matrix,Matrix-method}{Matrix-class}{Ops,matrix,Matrix.Rdash.method}
\aliasA{rbind2,ANY,Matrix-method}{Matrix-class}{rbind2,ANY,Matrix.Rdash.method}
\aliasA{rbind2,atomicVector,Matrix-method}{Matrix-class}{rbind2,atomicVector,Matrix.Rdash.method}
\aliasA{rbind2,Matrix,ANY-method}{Matrix-class}{rbind2,Matrix,ANY.Rdash.method}
\aliasA{rbind2,Matrix,atomicVector-method}{Matrix-class}{rbind2,Matrix,atomicVector.Rdash.method}
\aliasA{rbind2,Matrix,Matrix-method}{Matrix-class}{rbind2,Matrix,Matrix.Rdash.method}
\aliasA{rbind2,Matrix,missing-method}{Matrix-class}{rbind2,Matrix,missing.Rdash.method}
\aliasA{rbind2,Matrix,NULL-method}{Matrix-class}{rbind2,Matrix,NULL.Rdash.method}
\aliasA{rbind2,NULL,Matrix-method}{Matrix-class}{rbind2,NULL,Matrix.Rdash.method}
\aliasA{show,Matrix-method}{Matrix-class}{show,Matrix.Rdash.method}
\aliasA{solve,ANY,Matrix-method}{Matrix-class}{solve,ANY,Matrix.Rdash.method}
\aliasA{solve,Matrix,ANY-method}{Matrix-class}{solve,Matrix,ANY.Rdash.method}
\aliasA{solve,Matrix,diagonalMatrix-method}{Matrix-class}{solve,Matrix,diagonalMatrix.Rdash.method}
\aliasA{solve,Matrix,matrix-method}{Matrix-class}{solve,Matrix,matrix.Rdash.method}
\aliasA{solve,matrix,Matrix-method}{Matrix-class}{solve,matrix,Matrix.Rdash.method}
\aliasA{solve,Matrix,missing-method}{Matrix-class}{solve,Matrix,missing.Rdash.method}
\aliasA{solve,Matrix,numeric-method}{Matrix-class}{solve,Matrix,numeric.Rdash.method}
\aliasA{Summary,Matrix-method}{Matrix-class}{Summary,Matrix.Rdash.method}
\aliasA{t,Matrix-method}{Matrix-class}{t,Matrix.Rdash.method}
\aliasA{tail,Matrix-method}{Matrix-class}{tail,Matrix.Rdash.method}
\aliasA{tcrossprod,ANY,Matrix-method}{Matrix-class}{tcrossprod,ANY,Matrix.Rdash.method}
\aliasA{tcrossprod,Matrix,ANY-method}{Matrix-class}{tcrossprod,Matrix,ANY.Rdash.method}
\aliasA{tcrossprod,Matrix,Matrix-method}{Matrix-class}{tcrossprod,Matrix,Matrix.Rdash.method}
\aliasA{tcrossprod,Matrix,matrix-method}{Matrix-class}{tcrossprod,Matrix,matrix.Rdash.method}
\aliasA{tcrossprod,matrix,Matrix-method}{Matrix-class}{tcrossprod,matrix,Matrix.Rdash.method}
\aliasA{tcrossprod,Matrix,numeric-method}{Matrix-class}{tcrossprod,Matrix,numeric.Rdash.method}
\aliasA{tcrossprod,numeric,Matrix-method}{Matrix-class}{tcrossprod,numeric,Matrix.Rdash.method}
\aliasA{unname,Matrix,missing-method}{Matrix-class}{unname,Matrix,missing.Rdash.method}
\aliasA{unname,Matrix-method}{Matrix-class}{unname,Matrix.Rdash.method}
\aliasA{\%*\%,ANY,Matrix-method}{Matrix-class}{.Rpcent.*.Rpcent.,ANY,Matrix.Rdash.method}
\aliasA{\%*\%,Matrix,ANY-method}{Matrix-class}{.Rpcent.*.Rpcent.,Matrix,ANY.Rdash.method}
\aliasA{\%*\%,Matrix,matrix-method}{Matrix-class}{.Rpcent.*.Rpcent.,Matrix,matrix.Rdash.method}
\aliasA{\%*\%,matrix,Matrix-method}{Matrix-class}{.Rpcent.*.Rpcent.,matrix,Matrix.Rdash.method}
\aliasA{\%*\%,Matrix,numeric-method}{Matrix-class}{.Rpcent.*.Rpcent.,Matrix,numeric.Rdash.method}
\aliasA{\%*\%,numeric,Matrix-method}{Matrix-class}{.Rpcent.*.Rpcent.,numeric,Matrix.Rdash.method}
\keyword{classes}{Matrix-class}
\keyword{algebra}{Matrix-class}
\begin{Description}\relax
The \code{Matrix} class is a class contained by all actual
classes in the \pkg{Matrix} package.  It is a \dQuote{virtual} class.
\end{Description}
\begin{Section}{Slots}
Common to \emph{all} matrix objects in the package:
\describe{
\item[\code{Dim}:] Object of class \code{"integer"} - the dimensions
of the matrix - must be an integer vector with exactly two
non-negative values.
\item[\code{Dimnames}:] list of length two; each component
containing NULL or a \code{\LinkA{character}{character}} vector length
equal the corresponding \code{Dim} element.
}
\end{Section}
\begin{Section}{Methods}
\describe{
\item[diff] \code{signature(x = "Matrix")}: As \code{\LinkA{diff}{diff}()}
for traditional matrices, i.e., applying \code{diff()} to each
column.
\item[dim] \code{signature(x = "Matrix")}: extract matrix dimensions
\code{\LinkA{dim}{dim}}.
\item[dim\textless{}-] \code{signature(x = "Matrix", value = "ANY")}: where
\code{value} is integer of length 2.  Allows to \emph{reshape}
Matrix objects, but only when \code{prod(value) == prod(dim(x))}.
\item[dimnames] \code{signature(x = "Matrix")}: extract
\code{\LinkA{dimnames}{dimnames}}.
\item[dimnames\textless{}-] \code{signature(x = "Matrix", value = "list")}: set
the \code{dimnames} to a \code{\LinkA{list}{list}} of length 2, see
\code{\LinkA{dimnames<\Rdash}{dimnames<.Rdash.}}.
\item[length] \code{signature(x = "Matrix")}: simply defined as
\code{prod(dim(x))} (and hence of mode \code{"double"}).
\item[show] \code{signature(object = "Matrix")}: \code{\LinkA{show}{show}}
method for \code{\LinkA{print}{print}}ing.
\item[image] \code{signature(object = "Matrix")}: draws an
\code{\LinkA{image}{image}} of the matrix entries, using
\code{\LinkA{levelplot}{levelplot}()} from package \pkg{lattice}.
\item[head] \code{signature(object = "Matrix")}: return only the
\emph{\dQuote{head}}, i.e., the first few rows.
\item[tail] \code{signature(object = "Matrix")}: return only the
\emph{\dQuote{tail}}, i.e., the last few rows of the respective matrix.
\\ 
\item[as.matrix, as.array] \code{signature(x = "Matrix")}: the same as
\code{as(x, "matrix")}; see also the note below.
\item[as.vector] \code{signature(x = "Matrix", mode = "missing")}:
\code{as.vector(m)} should be identical to \code{as.vector(as(m,
        "matrix"))}, implemented more efficiently for some subclasses.
\item[as(x, "vector"), as(x, "numeric")] etc, similarly.
}
There are many more methods that (conceptually should) work for all
\code{"Matrix"} objects, e.g., \code{\LinkA{colSums}{colSums}},
\code{\LinkA{rowMeans}{rowMeans}}.  Even \pkg{base} functions may work
automagically (if they first call \code{\LinkA{as.matrix}{as.matrix}()} on their
principal argument), e.g., \code{\LinkA{apply}{apply}}, \code{\LinkA{eigen}{eigen}},
\code{\LinkA{svd}{svd}} or \code{\LinkA{kappa}{kappa}} all do work via coercion to a
\dQuote{traditional} (dense) \code{\LinkA{matrix}{matrix}}.
\end{Section}
\begin{Note}\relax
Loading the \code{Matrix} namespace \dQuote{overloads}
\code{\LinkA{as.matrix}{as.matrix}} and \code{\LinkA{as.array}{as.array}} in the \pkg{base}
namespace by the equivalent of \code{function(x) as(x, "matrix")}.
Consequently, \code{as.matrix(m)} or \code{as.array(m)} will properly
work when \code{m} inherits from the \code{"Matrix"} class ---
\emph{also} for functions in package \pkg{base} and other packages.
E.g., \code{\LinkA{apply}{apply}} or \code{\LinkA{outer}{outer}} can therefore be applied
to \code{"Matrix"} matrices.
\end{Note}
\begin{Author}\relax
Douglas Bates \email{bates@stat.wisc.edu} and Martin Maechler
\end{Author}
\begin{SeeAlso}\relax
the classes \code{\LinkA{dgeMatrix}{dgeMatrix.Rdash.class}},
\code{\LinkA{dgCMatrix}{dgCMatrix.Rdash.class}}, and function
\code{\LinkA{Matrix}{Matrix}} for construction (and examples).

Methods, e.g., for \code{\LinkA{kronecker}{kronecker}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
slotNames("Matrix")

cl <- getClass("Matrix")
names(cl@subclasses) # more than 40 ..

showClass("Matrix")#> output with slots and all subclasses

(M <- Matrix(c(0,1,0,0), 6, 4))
dim(M)
diag(M)
diff(M)
## can reshape it even :
dim(M) <- c(2, 12)
M
stopifnot(identical(M, Matrix(c(0,1,0,0), 2,12)))
\end{ExampleCode}
\end{Examples}

