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 1466, Wed Aug 30 03:35:53 2006 UTC revision 1467, Wed Aug 30 21:35:09 2006 UTC
# Line 11  Line 11 
11  (o4 <- Matrix(1+diag(4)))  (o4 <- Matrix(1+diag(4)))
12  (m4 <- Matrix(cbind(0,rbind(6*diag(3),0))))  (m4 <- Matrix(cbind(0,rbind(6*diag(3),0))))
13  dm4 <- Matrix(m4, sparse = FALSE)  dm4 <- Matrix(m4, sparse = FALSE)
14    class(mN <-  Matrix(NA, 3,4)) # NA *is* logical
15  stopifnot(validObject(d4), validObject(z4), validObject(o4),  stopifnot(validObject(d4), validObject(z4), validObject(o4),
16            validObject(m4), validObject(dm4))            validObject(m4), validObject(dm4), validObject(mN))
17  assert.EQ.mat(dm4, as(m4, "matrix"))  assert.EQ.mat(dm4, as(m4, "matrix"))
18    if(FALSE)# assert.EQ.. fails for all NA
19    assert.EQ.mat(mN, matrix(NA, 3,4))
20    sN <- Matrix(, 3,4, sparse=TRUE)# warning: NA coerced to FALSE
21    stopifnot(length(sN@i) == 0, # all "FALSE"
22              validObject(Matrix(c(NA,0), 4, 3, byrow = TRUE)),
23              validObject(Matrix(c(NA,0), 4, 4)),
24              is(Matrix(c(NA,0,0,0), 4, 4), "sparseMatrix"))
25    
26  ## large sparse ones: these now directly "go sparse":  ## large sparse ones: these now directly "go sparse":
27  str(m0 <- Matrix(0,     nrow=100, ncol = 1000))  str(m0 <- Matrix(0,     nrow=100, ncol = 1000))
28  str(l0 <- Matrix(FALSE, nrow=100, ncol = 200))  str(l0 <- Matrix(FALSE, nrow=100, ncol = 200))
# Line 75  Line 84 
84  ###-- row- and column operations  {was ./rowcolOps.R }  ###-- row- and column operations  {was ./rowcolOps.R }
85    
86  set.seed(321)  set.seed(321)
87    (m1 <- round(Matrix(rnorm(25), 5), 2))
88  m1k <- Matrix(round(rnorm(1000), 2), 50, 20)  m1k <- Matrix(round(rnorm(1000), 2), 50, 20)
89  m.m <- as(m1k, "matrix")  m.m <- as(m1k, "matrix")
90  stopifnot(all.equal(colMeans(m1k), colMeans(m.m)),  stopifnot(all.equal(colMeans(m1k), colMeans(m.m)),
# Line 82  Line 92 
92            all.equal(rowMeans(m1k), rowMeans(m.m)),            all.equal(rowMeans(m1k), rowMeans(m.m)),
93            all.equal(rowSums (m1k), rowSums (m.m)))            all.equal(rowSums (m1k), rowSums (m.m)))
94    
 ###-- Testing expansions of factorizations {was ./expand.R }  
   
 (m1 <- round(Matrix(rnorm(25), 5), 2))  
 (lul <- expand(lu(m1)))  
 stopifnot(all.equal(as(m1, "matrix"),  
                     as(lul$P %*% (lul$L %*% lul$U), "matrix")))  
   
   
95  ###-- kronecker for nonsparse uses Matrix(.):  ###-- kronecker for nonsparse uses Matrix(.):
96  stopifnot(is(kr <- kronecker(m1, m6), "Matrix"))  stopifnot(is(kr <- kronecker(m1, m6), "Matrix"))
97  assert.EQ.mat(kr,  assert.EQ.mat(kr,

Legend:
Removed from v.1466  
changed lines
  Added in v.1467

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