SCM

SCM Repository

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

Diff of /pkg/man/lsparseMatrix-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{lsparseMatrix-classes}  \name{lsparseMatrix-classes}
2    \title{Sparse logical matrices}
3  \docType{class}  \docType{class}
4  \alias{lsparseMatrix-class}  \alias{lsparseMatrix-class}
5  \alias{lgCMatrix-class}  \alias{lgCMatrix-class}
# Line 26  Line 27 
27  \alias{\%*\%,ldenseMatrix,lsparseMatrix-method}  \alias{\%*\%,ldenseMatrix,lsparseMatrix-method}
28    
29  \alias{coerce,lsparseMatrix,matrix-method}  \alias{coerce,lsparseMatrix,matrix-method}
30    \alias{coerce,lsparseMatrix,dsparseMatrix-method}
31  \alias{coerce,lgCMatrix,dgCMatrix-method}  \alias{coerce,lgCMatrix,dgCMatrix-method}
32  \alias{coerce,lgCMatrix,lgTMatrix-method}  \alias{coerce,lgCMatrix,lgTMatrix-method}
33  \alias{coerce,lgCMatrix,lgeMatrix-method}  \alias{coerce,lgCMatrix,lgeMatrix-method}
# Line 86  Line 88 
88  \alias{tcrossprod,lgCMatrix,missing-method}  \alias{tcrossprod,lgCMatrix,missing-method}
89  \alias{tcrossprod,lgTMatrix,missing-method}  \alias{tcrossprod,lgTMatrix,missing-method}
90  \alias{tcrossprod,lsparseMatrix,missing-method}  \alias{tcrossprod,lsparseMatrix,missing-method}
 \title{Sparse logical matrices}  
91  \description{The \code{lsparseMatrix} class is a virtual class of sparse  \description{The \code{lsparseMatrix} class is a virtual class of sparse
92    matrices with \code{TRUE}/\code{FALSE} entries.  Only the positions of the    matrices with \code{TRUE}/\code{FALSE} entries.  Only the positions of the
93    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
# Line 164  Line 165 
165  str(mmG.1 <- (KNex $ mm) > 0.1)# "lgC..."  str(mmG.1 <- (KNex $ mm) > 0.1)# "lgC..."
166  table(mmG.1@x)# however with many ``non-structural zeros''  table(mmG.1@x)# however with many ``non-structural zeros''
167  ## from logical to nz_pattern -- okay when there are no NA's :  ## from logical to nz_pattern -- okay when there are no NA's :
168  nmG.1 <- as(mmG.1, "nMatrix")  nmG.1 <- as(mmG.1, "nMatrix") # <<< has "TRUE" also where mmG.1 had FALSE
169  ## from logical to "double"  ## from logical to "double"
170  dmG.1 <- as(mmG.1, "dMatrix") # and back:  dmG.1 <- as(mmG.1, "dMatrix") # has '0' and back:
171  lmG.1 <- as(dmG.1, "lMatrix")  lmG.1 <- as(dmG.1, "lMatrix") # has no extra FALSE, i.e. drop0() included
172  stopifnot(validObject(lmG.1), identical(lmG.1, mmG.1))  stopifnot(identical(nmG.1, as((KNex $ mm) != 0,"nMatrix")),
173              validObject(lmG.1), all(lmG.1@x),
174              # same "logical" but lmG.1 has no 'FALSE' in x slot:
175              all(lmG.1 == mmG.1))
176    
177  class(xnx <- crossprod(nmG.1))# "nsC.."  class(xnx <- crossprod(nmG.1))# "nsC.."
178  class(xlx <- crossprod(mmG.1))# "dsC.." : numeric  class(xlx <- crossprod(mmG.1))# "dsC.." : numeric
# Line 176  Line 180 
180  mean(as.vector(is0))# 99.3\% zeros: quite sparse, but  mean(as.vector(is0))# 99.3\% zeros: quite sparse, but
181  table(xlx@x == 0)# more than half of the entries are (non-structural!) 0  table(xlx@x == 0)# more than half of the entries are (non-structural!) 0
182  stopifnot(isSymmetric(xlx), isSymmetric(xnx),  stopifnot(isSymmetric(xlx), isSymmetric(xnx),
183            ## compare xnx and  drop0(xlx) :            ## compare xnx and xlx : have the *same* non-structural 0s :
184            sapply(slotNames(xnx),            sapply(slotNames(xnx),
185                   function(n) identical(slot(xnx, n), slot(drop0(xlx), n))))                   function(n) identical(slot(xnx, n), slot(xlx, n))))
186  }  }
187  \keyword{classes}  \keyword{classes}
188  \keyword{algebra}  \keyword{algebra}

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