SCM

SCM Repository

[matrix] Diff of /pkg/man/nsparseMatrix-classes.Rd
ViewVC logotype

Diff of /pkg/man/nsparseMatrix-classes.Rd

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2184, Sat Apr 26 20:32:39 2008 UTC revision 2185, Sat Apr 26 20:33:16 2008 UTC
# Line 1  Line 1 
1  \name{nsparseMatrix-classes}  \name{nsparseMatrix-classes}
2  \title{Sparse logical matrices}  \title{Sparse "pattern" Matrices}
3  \docType{class}  \docType{class}
4  \alias{nsparseMatrix-class}  \alias{nsparseMatrix-class}
5  \alias{ngCMatrix-class}  \alias{ngCMatrix-class}
# Line 19  Line 19 
19  \alias{\%*\%,nsparseMatrix,ndenseMatrix-method}  \alias{\%*\%,nsparseMatrix,ndenseMatrix-method}
20  \alias{\%*\%,ndenseMatrix,nsparseMatrix-method}  \alias{\%*\%,ndenseMatrix,nsparseMatrix-method}
21    
22    \alias{coerce,nsparseMatrix,dsparseMatrix-method}
23  \alias{coerce,matrix,ngCMatrix-method}  \alias{coerce,matrix,ngCMatrix-method}
24  \alias{coerce,matrix,ngTMatrix-method}  \alias{coerce,matrix,ngTMatrix-method}
25  \alias{coerce,matrix,ntCMatrix-method}  \alias{coerce,matrix,ntCMatrix-method}
# Line 99  Line 100 
100  \alias{Ops,nsparseMatrix,sparseMatrix-method}  \alias{Ops,nsparseMatrix,sparseMatrix-method}
101  %  %
102  \description{The \code{nsparseMatrix} class is a virtual class of sparse  \description{The \code{nsparseMatrix} class is a virtual class of sparse
103    matrices with \code{TRUE}/\code{FALSE} entries.  Only the positions of the    \emph{\dQuote{pattern}} matrices, i.e., binary matrices conceptually
104      with \code{TRUE}/\code{FALSE} entries.  Only the positions of the
105    elements that are \code{TRUE} are stored.  These can be stored in the    elements that are \code{TRUE} are stored.  These can be stored in the
106    ``triplet'' form (classes \code{ngTMatrix}, \code{nsTMatrix}, and    ``triplet'' form (classes \code{ngTMatrix}, \code{nsTMatrix}, and
107    \code{ntTMatrix} which really contain pairs, not triplets) or in    \code{ntTMatrix} which really contain pairs, not triplets) or in
# Line 112  Line 114 
114  \section{Objects from the Class}{  \section{Objects from the Class}{
115    Objects can be created by calls of the form \code{new("ngCMatrix",    Objects can be created by calls of the form \code{new("ngCMatrix",
116      ...)} and so on.  More frequently objects are created by coercion of      ...)} and so on.  More frequently objects are created by coercion of
117    a numeric sparse matrix to the logical form for use in    a numeric sparse matrix to the pattern form for use in
118    the symbolic analysis phase    the symbolic analysis phase
119    of an algorithm involving sparse matrices.  Such algorithms often    of an algorithm involving sparse matrices.  Such algorithms often
120    involve two phases: a symbolic phase wherein the positions of the    involve two phases: a symbolic phase wherein the positions of the
121    non-zeros in the result are determined and a numeric phase wherein the    non-zeros in the result are determined and a numeric phase wherein the
122    actual results are calculated.  During the symbolic phase only the    actual results are calculated.  During the symbolic phase only the
123    positions of the non-zero elements in any operands are of interest,    positions of the non-zero elements in any operands are of interest,
124    hence any numeric sparse matrices can be treated as logical sparse    hence numeric sparse matrices can be treated as sparse pattern
125    matrices.    matrices.
126  }  }
127  \section{Slots}{  \section{Slots}{
# Line 151  Line 153 
153  }  }
154  \section{Methods}{  \section{Methods}{
155    \describe{    \describe{
156      \item{coerce}{\code{signature(from = "dgCMatrix", to = "ngCMatrix")}}      \item{coerce}{\code{signature(from = "dgCMatrix", to =
157            "ngCMatrix")}, and many similar ones; typically you should
158          coerce to \code{"nsparseMatrix"} (or \code{"nMatrix"}).  Note that
159          coercion to a sparse pattern matrix records all the potential
160          non-zero entries, i.e., explicit (\dQuote{non-structural}) zeroes
161          are coerced to \code{TRUE}, not \code{FALSE}, see the example.
162        }
163      \item{t}{\code{signature(x = "ngCMatrix")}: returns the transpose      \item{t}{\code{signature(x = "ngCMatrix")}: returns the transpose
164        of \code{x}}        of \code{x}}
165    }    }
# Line 172  Line 180 
180  stopifnot(xor(as( nm, "matrix"),  stopifnot(xor(as( nm, "matrix"),
181                as(!nm, "matrix")))                as(!nm, "matrix")))
182    
183    
184    
185  data(KNex)  data(KNex)
186  nmm <- as(KNex $ mm, "ngCMatrix")  nmm <- as(KNex $ mm, "ngCMatrix")
187  str(xlx <- crossprod(nmm))# "nsCMatrix"  str(xlx <- crossprod(nmm))# "nsCMatrix"

Legend:
Removed from v.2184  
changed lines
  Added in v.2185

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge