\HeaderA{sparseMatrix-class}{Virtual Class "sparseMatrix" --- Mother of Sparse Matrices}{sparseMatrix.Rdash.class}
\aliasA{-,sparseMatrix,missing-method}{sparseMatrix-class}{.Rdash.,sparseMatrix,missing.Rdash.method}
\aliasA{cbind2,matrix,sparseMatrix-method}{sparseMatrix-class}{cbind2,matrix,sparseMatrix.Rdash.method}
\aliasA{cbind2,numeric,sparseMatrix-method}{sparseMatrix-class}{cbind2,numeric,sparseMatrix.Rdash.method}
\aliasA{cbind2,sparseMatrix,matrix-method}{sparseMatrix-class}{cbind2,sparseMatrix,matrix.Rdash.method}
\aliasA{cbind2,sparseMatrix,numeric-method}{sparseMatrix-class}{cbind2,sparseMatrix,numeric.Rdash.method}
\aliasA{cbind2,sparseMatrix,sparseMatrix-method}{sparseMatrix-class}{cbind2,sparseMatrix,sparseMatrix.Rdash.method}
\aliasA{coerce,ANY,sparseMatrix-method}{sparseMatrix-class}{coerce,ANY,sparseMatrix.Rdash.method}
\aliasA{coerce,dgTMatrix,graphNEL-method}{sparseMatrix-class}{coerce,dgTMatrix,graphNEL.Rdash.method}
\aliasA{coerce,factor,sparseMatrix-method}{sparseMatrix-class}{coerce,factor,sparseMatrix.Rdash.method}
\aliasA{coerce,graph,CsparseMatrix-method}{sparseMatrix-class}{coerce,graph,CsparseMatrix.Rdash.method}
\aliasA{coerce,graph,sparseMatrix-method}{sparseMatrix-class}{coerce,graph,sparseMatrix.Rdash.method}
\aliasA{coerce,graphAM,sparseMatrix-method}{sparseMatrix-class}{coerce,graphAM,sparseMatrix.Rdash.method}
\aliasA{coerce,graphNEL,CsparseMatrix-method}{sparseMatrix-class}{coerce,graphNEL,CsparseMatrix.Rdash.method}
\aliasA{coerce,graphNEL,TsparseMatrix-method}{sparseMatrix-class}{coerce,graphNEL,TsparseMatrix.Rdash.method}
\aliasA{coerce,sparseMatrix,generalMatrix-method}{sparseMatrix-class}{coerce,sparseMatrix,generalMatrix.Rdash.method}
\aliasA{coerce,sparseMatrix,graph-method}{sparseMatrix-class}{coerce,sparseMatrix,graph.Rdash.method}
\aliasA{coerce,sparseMatrix,graphNEL-method}{sparseMatrix-class}{coerce,sparseMatrix,graphNEL.Rdash.method}
\aliasA{coerce,sparseMatrix,symmetricMatrix-method}{sparseMatrix-class}{coerce,sparseMatrix,symmetricMatrix.Rdash.method}
\aliasA{coerce,sparseMatrix,triangularMatrix-method}{sparseMatrix-class}{coerce,sparseMatrix,triangularMatrix.Rdash.method}
\aliasA{coerce,TsparseMatrix,graphNEL-method}{sparseMatrix-class}{coerce,TsparseMatrix,graphNEL.Rdash.method}
\aliasA{cov2cor,sparseMatrix-method}{sparseMatrix-class}{cov2cor,sparseMatrix.Rdash.method}
\aliasA{determinant,dgCMatrix,logical-method}{sparseMatrix-class}{determinant,dgCMatrix,logical.Rdash.method}
\aliasA{determinant,dsparseMatrix,logical-method}{sparseMatrix-class}{determinant,dsparseMatrix,logical.Rdash.method}
\aliasA{determinant,dtCMatrix,logical-method}{sparseMatrix-class}{determinant,dtCMatrix,logical.Rdash.method}
\aliasA{determinant,sparseMatrix,logical-method}{sparseMatrix-class}{determinant,sparseMatrix,logical.Rdash.method}
\aliasA{determinant,sparseMatrix,missing-method}{sparseMatrix-class}{determinant,sparseMatrix,missing.Rdash.method}
\aliasA{diag,sparseMatrix-method}{sparseMatrix-class}{diag,sparseMatrix.Rdash.method}
\aliasA{dim<-,sparseMatrix-method}{sparseMatrix-class}{dim<.Rdash.,sparseMatrix.Rdash.method}
\aliasA{lu,sparseMatrix-method}{sparseMatrix-class}{lu,sparseMatrix.Rdash.method}
\aliasA{Math,sparseMatrix-method}{sparseMatrix-class}{Math,sparseMatrix.Rdash.method}
\aliasA{norm,sparseMatrix,character-method}{sparseMatrix-class}{norm,sparseMatrix,character.Rdash.method}
\aliasA{Ops,diagonalMatrix,sparseMatrix-method}{sparseMatrix-class}{Ops,diagonalMatrix,sparseMatrix.Rdash.method}
\aliasA{Ops,numeric,sparseMatrix-method}{sparseMatrix-class}{Ops,numeric,sparseMatrix.Rdash.method}
\aliasA{Ops,sparseMatrix,diagonalMatrix-method}{sparseMatrix-class}{Ops,sparseMatrix,diagonalMatrix.Rdash.method}
\aliasA{Ops,sparseMatrix,numeric-method}{sparseMatrix-class}{Ops,sparseMatrix,numeric.Rdash.method}
\aliasA{Ops,sparseMatrix,sparseMatrix-method}{sparseMatrix-class}{Ops,sparseMatrix,sparseMatrix.Rdash.method}
\aliasA{print,sparseMatrix-method}{sparseMatrix-class}{print,sparseMatrix.Rdash.method}
\aliasA{rbind2,matrix,sparseMatrix-method}{sparseMatrix-class}{rbind2,matrix,sparseMatrix.Rdash.method}
\aliasA{rbind2,numeric,sparseMatrix-method}{sparseMatrix-class}{rbind2,numeric,sparseMatrix.Rdash.method}
\aliasA{rbind2,sparseMatrix,matrix-method}{sparseMatrix-class}{rbind2,sparseMatrix,matrix.Rdash.method}
\aliasA{rbind2,sparseMatrix,numeric-method}{sparseMatrix-class}{rbind2,sparseMatrix,numeric.Rdash.method}
\aliasA{rbind2,sparseMatrix,sparseMatrix-method}{sparseMatrix-class}{rbind2,sparseMatrix,sparseMatrix.Rdash.method}
\aliasA{rcond,sparseMatrix,character-method}{sparseMatrix-class}{rcond,sparseMatrix,character.Rdash.method}
\aliasA{show,sparseMatrix-method}{sparseMatrix-class}{show,sparseMatrix.Rdash.method}
\aliasA{summary,sparseMatrix-method}{sparseMatrix-class}{summary,sparseMatrix.Rdash.method}
\keyword{classes}{sparseMatrix-class}
\begin{Description}\relax
Virtual Mother Class of All Sparse Matrices
\end{Description}
\begin{Section}{Slots}
\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}:] a list of length two - inherited from class
\code{Matrix}, see \code{\LinkA{Matrix}{Matrix.Rdash.class}}.
}
\end{Section}
\begin{Section}{Extends}
Class \code{"Matrix"}, directly.
\end{Section}
\begin{Section}{Methods}
\describe{
\item[show] \code{(object = "sparseMatrix")}: The
\code{\LinkA{show}{show}} method for sparse matrices prints
\emph{\dQuote{structural}} zeroes as \code{"."} using
\code{\LinkA{printSpMatrix}{printSpMatrix}()} which allows further customization.
\item[print] \code{signature(x = "sparseMatrix")}, ....\\
The \code{\LinkA{print}{print}} method for sparse matrices by default is the
same as \code{show()} but can be called with extra optional
arguments, see \code{\LinkA{printSpMatrix}{printSpMatrix}()}.
\item[summary] \code{(object = "sparseMatrix")}: Returns
an object of S3 class \code{"sparseSummary"} which is basically a
\code{\LinkA{data.frame}{data.frame}} with columns \code{(i,j,x)} (or just
\code{(i,j)} for \code{\LinkA{nsparseMatrix}{nsparseMatrix.Rdash.class}} class objects)
with the stored (typically non-zero) entries.  The
\code{\LinkA{print}{print}} method resembles Matlab's way of printing
sparse matrices, and also the MatrixMarket format, see
\code{\LinkA{writeMM}{writeMM}}.
\item[determinant] \code{(x = "sparseMatrix", logarithm=TRUE)}:
\code{\LinkA{determinant}{determinant}()} methods for sparse matrices typically
work via \code{\LinkA{Cholesky}{Cholesky}} or \code{\LinkA{lu}{lu}} decompositions.
\item[diag] \code{(x = "sparseMatrix")}: extracts the diagonal of a
sparse matrix.
\item[dim\textless{}-] \code{signature(x = "sparseMatrix", value = "ANY")}:
allows to \emph{reshape} a sparse matrix to a sparse matrix with
the same entries but different dimensions. \code{value} must be of
length two and fulfill \code{prod(value) == prod(dim(x))}.
\item[coerce] \code{signature(from = "factor", to = "sparseMatrix")}:
Coercion of a factor to \code{"sparseMatrix"} produces the matrix
of indicator \bold{rows} stored as an object of class
\code{"dgCMatrix"}.  To obtain columns representing the interaction
of the factor and a numeric covariate, replace the \code{"x"} slot
of the result by the numeric covariate then take the transpose.
Missing values (\code{\LinkA{NA}{NA}}) from the factor are translated
to columns of all \code{0}s.
}
See also \code{\LinkA{colSums}{colSums}}, \code{\LinkA{norm}{norm}},
... 
for methods with separate help pages.
\end{Section}
\begin{Note}\relax
In method selection for multiplication operations (i.e. \code{\%*\%}
and the two-argument form of \code{\LinkA{crossprod}{crossprod}})
the sparseMatrix class takes precedence in the sense that if one
operand is a sparse matrix and the other is any type of dense matrix
then the dense matrix is coerced to a \code{dgeMatrix} and the
appropriate sparse matrix method is used.
\end{Note}
\begin{Examples}
\begin{ExampleCode}
showClass("sparseMatrix") ## and look at the help() of its subclasses
M <- Matrix(0, 10000, 100)
M[1,1] <- M[2,3] <- 3.14
M  ## show(.) method suppresses printing of the majority of rows

data(CAex); dim(CAex) # 72 x 72 matrix
determinant(CAex) # works via sparse lu(.)

## factor -> t( <sparse design matrix> ) :
(fact <- gl(5, 3, 30, labels = LETTERS[1:5]))
(Xt <- as(fact, "sparseMatrix"))  # indicator rows

## missing values --> all-0 columns:
f.mis <- fact
i.mis <- c(3:5, 17)
is.na(f.mis) <- i.mis
Xt != (X. <- as(f.mis, "sparseMatrix")) # differ only in columns 3:5,17
stopifnot(all(X.[,i.mis] == 0), all(Xt[,-i.mis] == X.[,-i.mis]))
\end{ExampleCode}
\end{Examples}

