1280
 \    \documentclass{article}
\usepackage{myVignette}
\usepackage[authoryear,round]{natbib}
\bibliographystyle{plainnat}
%%\VignetteIndexEntry{Introduction to the Matrix Package}
%%\VignetteDepends{Matrix}
\SweaveOpts{engine=R,eps=FALSE,pdf=TRUE,width=5,height=3,strip.white=true,keep.source=TRUE}
\title{Introduction to the Matrix package --- as of Feb.~2005\footnote{
    There's an unfinished ``2nd Introduction to the Matrix package''
    which contains partly newer information, but is not at all self-contained.
    Eventually that will replace this one.}}
\author{Douglas Bates\\R Core Development Group\\\email{bates@r-project.org}}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
  Linear algebra is at the core of many areas of statistical computing
  and from its inception the \Slang{} has supported numerical linear
  algebra via a matrix data type and several functions and operators,
  such as \code{\%*\%}, \code{qr}, \code{chol}, and \code{solve}.
  However, these data types and functions do not provide direct access
  to all of the facilities for efficient manipulation of dense
  matrices, as provided by the Lapack subroutines, and they do not
  provide for manipulation of sparse matrices.

  The \code{Matrix} package provides a set of S4 classes for dense and
  sparse matrices that extend the basic matrix data type.  Methods for
  a wide variety of functions and operators applied to objects from
  these classes provide efficient access to BLAS (Basic Linear Algebra
  Subroutines), Lapack (dense matrix), TAUCS (sparse matrix) and
  UMFPACK (sparse matrix) routines.  One notable characteristic of the
  package is that whenever a matrix is factored, the factorization is
  stored as part of the original matrix so that further operations on
  the matrix can reuse this factorization.
\end{abstract}
<<preliminaries, echo=FALSE>>=
options(width=75)
@

\section{Introduction}
\label{sec:Intro}

Linear algebra is at the core of many statistical computing techniques
and, from its inception, the \Slang{} has supported numerical linear
algebra via a matrix data type and several functions and operators,
such as \code{\%*\%}, \code{qr}, \code{chol}, and \code{solve}.
Initially the numerical linear algebra functions in \RR{} called
underlying Fortran routines from the Linpack~\citep{Linpack} and
Eispack~\cite{Eispack} libraries but over the years most of these
functions have been switched to use routines from the
Lapack~\cite{Lapack} library.  Furthermore, \RR{} can be configured to
use accelerated BLAS (Basic Linear Algebra Subroutines), such as those
from the Atlas~\cite{Atlas} project or Goto's BLAS~\cite{GotosBLAS}.

Lapack provides routines for operating on several special forms of
matrices, such as triangular matrices and symmetric matrices.
Furthermore,matrix decompositions like the QR decompositions produce
multiple output components that should be regarded as parts of a
single object.  There is some support in R for operations on special
forms of matrices (e.g. the \code{backsolve}, \code{forwardsolve} and
\code{chol2inv} functions) and for special structures (e.g. a QR
structure is implicitly defined as a list by the \code{qr},
\code{qr.qy}, \code{qr.qty}, and related functions) but it is not as
fully developed as it could be.

Also there is no direct support for sparse matrices in R although
\citet{koen:ng:2003} have developed a contributed package for sparse
matrices based on SparseKit.

The \code{Matrix} package provides S4 classes and methods for dense
and sparse matrices.  The methods for dense matrices use Lapack and
BLAS.  The sparse matrix methods use TAUCS~\citep{Taucs},
UMFPACK~\citep{Umfpack}, and Metis~\citep{Metis}.


\section{Classes for dense matrices}
\label{sec:DenseClasses}

The \code{Matrix} package will provide classes for real (stored as
double precision) and complex (stored as double precision complex)
dense matrices.  At present only the real classes have been
implemented.  These classes are
\begin{description}
\item[dgeMatrix] Real matrices in general storage mode
\item[dsyMatrix]