SCM

SCM Repository

[matrix] Diff of /pkg/tests/simple.R
ViewVC logotype

Diff of /pkg/tests/simple.R

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

revision 1547, Mon Sep 11 14:49:39 2006 UTC revision 1548, Mon Sep 11 22:13:07 2006 UTC
# Line 17  Line 17 
17  assert.EQ.mat(dm4, as(m4, "matrix"))  assert.EQ.mat(dm4, as(m4, "matrix"))
18  if(FALSE)# assert.EQ.. fails for all NA  if(FALSE)# assert.EQ.. fails for all NA
19  assert.EQ.mat(mN, matrix(NA, 3,4))  assert.EQ.mat(mN, matrix(NA, 3,4))
20  sN <- Matrix(, 3,4, sparse=TRUE)# warning: NA coerced to FALSE  sL <- Matrix(, 3,4, sparse=TRUE)# -> "lgC
21  stopifnot(length(sN@i) == 0, # all "FALSE"  stopifnot(##length(sN@i) == 0, # all "FALSE"
22            validObject(Matrix(c(NA,0), 4, 3, byrow = TRUE)),            validObject(Matrix(c(NA,0), 4, 3, byrow = TRUE)),
23            validObject(Matrix(c(NA,0), 4, 4)),            validObject(Matrix(c(NA,0), 4, 4)),
24            is(Matrix(c(NA,0,0,0), 4, 4), "sparseMatrix"))            is(Matrix(c(NA,0,0,0), 4, 4), "sparseMatrix"))
# Line 144  Line 144 
144  assertError(as(m5, "dpoMatrix"))  assertError(as(m5, "dpoMatrix"))
145    
146    
147  ###-- logical sparse : ----------  ###-- sparse nonzero pattern : ----------
148    
149  (lkt <- as(as(kt1, "dgCMatrix"), "lgCMatrix"))# ok  (nkt <- as(as(kt1, "dgCMatrix"), "ngCMatrix"))# ok
150  (clt <- crossprod(lkt))  (clt <- crossprod(nkt))
151  if(FALSE) ## FIXME!  if(FALSE) ## FIXME!
152      crossprod(clt)      crossprod(clt)
153  ## CHOLMOD error: matrix cannot be symmetric  ## CHOLMOD error: matrix cannot be symmetric
# Line 157  Line 157 
157  data(KNex)  data(KNex)
158  mm <- KNex$mm  mm <- KNex$mm
159  xpx <- crossprod(mm)  xpx <- crossprod(mm)
160  lxpx <- as(xpx, "lsCMatrix")  ## extract nonzero pattern
161    if(FALSE) ## FIXME -- {used to work..
162    nxpx <- as(xpx, "nsCMatrix")
163  if(FALSE)  if(FALSE)
164      show(lxpx) ## gives error about "lsC" -> "lgT" coercion ..      show(nxpx) ## gives error about "lsC" -> "lgT" coercion ..
165  ## The bug is actually from *subsetting* the large matrix:  ## The bug is actually from *subsetting* the large matrix:
166  if(FALSE) ## FIXME  if(FALSE) ## FIXME
167      r <- lxpx[1:2,]      r <- nxpx[1:2,]
168    
169  lmm <- as(mm, "lgCMatrix")  lmm <- as(mm, "lgCMatrix")
170    nmm <- as(lmm, "nMatrix")
171  xlx <- crossprod(lmm)  xlx <- crossprod(lmm)
172    x.x <- crossprod(nmm)
173  ## now A = lxpx and B = xlx should be close, but not quite the same  ## now A = lxpx and B = xlx should be close, but not quite the same
174  ## since <x,y> = 0 is well possible when x!=0 and y!=0 .  ## since <x,y> = 0 is well possible when x!=0 and y!=0 .
175  ## However,  A[i,j] != 0 ==> B[i,j] != 0:  ## However,  A[i,j] != 0 ==> B[i,j] != 0:
176  A <- as(as(lxpx, "lgCMatrix"), "lgTMatrix")  if(FALSE) { ## FIXME : nxpx above
177    A <- as(as(nxpx, "lgCMatrix"), "lgTMatrix")
178  B <- as(as(xlx,  "lgCMatrix"), "lgTMatrix")  B <- as(as(xlx,  "lgCMatrix"), "lgTMatrix")
179  ij <- function(a) a@i + ncol(a) * a@j  ij <- function(a) a@i + ncol(a) * a@j
180  stopifnot(all(ij(A) %in% ij(B)))  stopifnot(all(ij(A) %in% ij(B)))
181    }
182    
183    
184    

Legend:
Removed from v.1547  
changed lines
  Added in v.1548

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