\HeaderA{colSums}{Form Row and Column Sums and Means}{colSums}
\aliasA{colMeans}{colSums}{colMeans}
\aliasA{colMeans,CsparseMatrix-method}{colSums}{colMeans,CsparseMatrix.Rdash.method}
\aliasA{colMeans,ddenseMatrix-method}{colSums}{colMeans,ddenseMatrix.Rdash.method}
\aliasA{colMeans,denseMatrix-method}{colSums}{colMeans,denseMatrix.Rdash.method}
\aliasA{colMeans,dgCMatrix-method}{colSums}{colMeans,dgCMatrix.Rdash.method}
\aliasA{colMeans,igCMatrix-method}{colSums}{colMeans,igCMatrix.Rdash.method}
\aliasA{colMeans,lgCMatrix-method}{colSums}{colMeans,lgCMatrix.Rdash.method}
\aliasA{colMeans,ngCMatrix-method}{colSums}{colMeans,ngCMatrix.Rdash.method}
\aliasA{colMeans,RsparseMatrix-method}{colSums}{colMeans,RsparseMatrix.Rdash.method}
\aliasA{colMeans,TsparseMatrix-method}{colSums}{colMeans,TsparseMatrix.Rdash.method}
\aliasA{colSums,CsparseMatrix-method}{colSums}{colSums,CsparseMatrix.Rdash.method}
\aliasA{colSums,ddenseMatrix-method}{colSums}{colSums,ddenseMatrix.Rdash.method}
\aliasA{colSums,denseMatrix-method}{colSums}{colSums,denseMatrix.Rdash.method}
\aliasA{colSums,dgCMatrix-method}{colSums}{colSums,dgCMatrix.Rdash.method}
\aliasA{colSums,igCMatrix-method}{colSums}{colSums,igCMatrix.Rdash.method}
\aliasA{colSums,lgCMatrix-method}{colSums}{colSums,lgCMatrix.Rdash.method}
\aliasA{colSums,ngCMatrix-method}{colSums}{colSums,ngCMatrix.Rdash.method}
\aliasA{colSums,RsparseMatrix-method}{colSums}{colSums,RsparseMatrix.Rdash.method}
\aliasA{colSums,TsparseMatrix-method}{colSums}{colSums,TsparseMatrix.Rdash.method}
\aliasA{rowMeans}{colSums}{rowMeans}
\aliasA{rowMeans,CsparseMatrix-method}{colSums}{rowMeans,CsparseMatrix.Rdash.method}
\aliasA{rowMeans,ddenseMatrix-method}{colSums}{rowMeans,ddenseMatrix.Rdash.method}
\aliasA{rowMeans,denseMatrix-method}{colSums}{rowMeans,denseMatrix.Rdash.method}
\aliasA{rowMeans,dgCMatrix-method}{colSums}{rowMeans,dgCMatrix.Rdash.method}
\aliasA{rowMeans,igCMatrix-method}{colSums}{rowMeans,igCMatrix.Rdash.method}
\aliasA{rowMeans,lgCMatrix-method}{colSums}{rowMeans,lgCMatrix.Rdash.method}
\aliasA{rowMeans,ngCMatrix-method}{colSums}{rowMeans,ngCMatrix.Rdash.method}
\aliasA{rowMeans,RsparseMatrix-method}{colSums}{rowMeans,RsparseMatrix.Rdash.method}
\aliasA{rowMeans,TsparseMatrix-method}{colSums}{rowMeans,TsparseMatrix.Rdash.method}
\aliasA{rowSums}{colSums}{rowSums}
\aliasA{rowSums,CsparseMatrix-method}{colSums}{rowSums,CsparseMatrix.Rdash.method}
\aliasA{rowSums,ddenseMatrix-method}{colSums}{rowSums,ddenseMatrix.Rdash.method}
\aliasA{rowSums,denseMatrix-method}{colSums}{rowSums,denseMatrix.Rdash.method}
\aliasA{rowSums,dgCMatrix-method}{colSums}{rowSums,dgCMatrix.Rdash.method}
\aliasA{rowSums,igCMatrix-method}{colSums}{rowSums,igCMatrix.Rdash.method}
\aliasA{rowSums,lgCMatrix-method}{colSums}{rowSums,lgCMatrix.Rdash.method}
\aliasA{rowSums,ngCMatrix-method}{colSums}{rowSums,ngCMatrix.Rdash.method}
\aliasA{rowSums,RsparseMatrix-method}{colSums}{rowSums,RsparseMatrix.Rdash.method}
\aliasA{rowSums,TsparseMatrix-method}{colSums}{rowSums,TsparseMatrix.Rdash.method}
\keyword{array}{colSums}
\keyword{algebra}{colSums}
\keyword{arith}{colSums}
\begin{Description}\relax
Form row and column sums and means for \code{\LinkA{Matrix}{Matrix.Rdash.class}} objects.
\end{Description}
\begin{Usage}
\begin{verbatim}
colSums (x, na.rm = FALSE, dims = 1, ...)
rowSums (x, na.rm = FALSE, dims = 1, ...)
colMeans(x, na.rm = FALSE, dims = 1, ...)
rowMeans(x, na.rm = FALSE, dims = 1, ...)

## S4 method for signature 'CsparseMatrix':
colSums(x, na.rm = FALSE,
        dims = 1, sparseResult = FALSE)
## S4 method for signature 'CsparseMatrix':
rowSums(x, na.rm = FALSE,
        dims = 1, sparseResult = FALSE)
## S4 method for signature 'CsparseMatrix':
colMeans(x, na.rm = FALSE,
        dims = 1, sparseResult = FALSE)
## S4 method for signature 'CsparseMatrix':
rowMeans(x, na.rm = FALSE,
        dims = 1, sparseResult = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a Matrix, i.e., inheriting from  \code{\LinkA{Matrix}{Matrix.Rdash.class}}.
\item[\code{na.rm}] logical. Should missing values (including \code{NaN})
be omitted from the calculations?
\item[\code{dims}] completely ignored by the \code{Matrix} methods.
\item[\code{...}] potentially further arguments, for method \code{<->}
generic compatibility.
\item[\code{sparseResult}] logical indicating if the result should be sparse,
i.e., inheriting from class \code{\LinkA{sparseVector}{sparseVector.Rdash.class}}.
\end{ldescription}
\end{Arguments}
\begin{Value}
returns a numeric vector if \code{sparseResult} is \code{FALSE} as per
default.  Otherwise, returns a \code{\LinkA{sparseVector}{sparseVector.Rdash.class}}.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{colSums}{colSums}} and the
\code{\LinkA{sparseVector}{sparseVector.Rdash.class}} classes.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
(M <- bdiag(Diagonal(2), matrix(1:3, 3,4), diag(3:2))) # 7 x 8
colSums(M)
d <- Diagonal(10, c(0,0,10,0,2,rep(0,5)))
MM <- kronecker(d, M)
dim(MM) # 70 80
length(MM@x) # 160, but many are '0' ; drop those:
MM <- drop0(MM)
length(MM@x) # 32
  cm <- colSums(MM)
(scm <- colSums(MM, sparseResult = TRUE))
stopifnot(is(scm, "sparseVector"),
          identical(cm, as.numeric(scm)))
rowSums(MM, sparseResult = TRUE) # 16 of 70 are not zero
colMeans(MM, sparseResult = TRUE)
## Since we have no 'NA's, these two are equivalent :
stopifnot(identical(rowMeans(MM, sparseResult = TRUE),
                    rowMeans(MM, sparseResult = TRUE, na.rm = TRUE)))
\end{ExampleCode}
\end{Examples}

