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 955, Thu Sep 29 19:32:14 2005 UTC revision 956, Fri Sep 30 17:28:00 2005 UTC
# Line 59  Line 59 
59  ###-- row- and column operations  {was ./rowcolOps.R }  ###-- row- and column operations  {was ./rowcolOps.R }
60    
61  set.seed(321)  set.seed(321)
62  mm <- Matrix(round(rnorm(1000), 2), 50, 20)  m1k <- Matrix(round(rnorm(1000), 2), 50, 20)
63  m1 <- as(mm, "matrix")  m.m <- as(m1k, "matrix")
64  stopifnot(all.equal(colMeans(mm), colMeans(m1)),  stopifnot(all.equal(colMeans(m1k), colMeans(m.m)),
65            all.equal(colSums(mm), colSums(m1)),            all.equal(colSums (m1k), colSums (m.m)),
66            all.equal(rowMeans(mm), rowMeans(m1)),            all.equal(rowMeans(m1k), rowMeans(m.m)),
67            all.equal(rowSums(mm), rowSums(m1)))            all.equal(rowSums (m1k), rowSums (m.m)))
68    
69  ###-- Testing expansions of factorizations {was ./expand.R }  ###-- Testing expansions of factorizations {was ./expand.R }
70    
# Line 74  Line 74 
74                      as(lul$P %*% (lul$L %*% lul$U), "matrix")))                      as(lul$P %*% (lul$L %*% lul$U), "matrix")))
75    
76    
77    ###-- kronecker for nonsparse uses Matrix(.):
78    stopifnot(is(kr <- kronecker(m1, m6), "Matrix"))
79    assert.EQ.mat(kr,
80                  kronecker(as(m1, "matrix"),
81                            as(m6, "matrix")),
82                  tol = 0)
83    ## sparse:
84    (kt1 <- kronecker(t1, tu))
85    kt2 <- kronecker(t1c, cu)
86    ktf <- kronecker(as.matrix(t1), as.matrix(tu))
87    
88    assert.EQ.mat(kt1, ktf, tol= 0)
89    assert.EQ.mat(kt2, ktf, tol= 0)
90    ## but kt1 and kt2, both "dgT" are different since entries are not ordered!
91    
92    
93    ###-- logical sparse : ----------
94    
95    (lkt <- as(as(kt1, "dgCMatrix"), "lgCMatrix"))# ok
96    (clt <- crossprod(lkt))
97    if(FALSE) ## FIXME: This gives CHOLMOD errors and a *seg.fault* !!!
98        crossprod(clt)
99    ## CHOLMOD error: matrix cannot be symmetric
100    ## CHOLMOD error: argument missing
101    
102    ### "d" <-> "l"  for (symmetric) sparse :
103    data(mm)
104    xpx <- crossprod(mm)
105    lxpx <- as(xpx, "lsCMatrix")
106    if(FALSE)
107        show(lxpx) ## gives error about "lsC" -> "lgT" coercion ..
108    ## The bug is actually from *subsetting* the large matrix:
109    if(FALSE) ## FIXME
110        r <- lxpx[1:2,]
111    
112    lmm <- as(mm, "lgCMatrix")
113    xlx <- crossprod(lmm)
114    ## now xlx and lxpx should really be the same -- at least `as matrix':
115    m1 <- as(xlx,  "matrix")
116    m2 <- as(lxpx, "matrix")
117    if(FALSE) ## BUG -- FIXME -- these should be equal!
118        stopifnot(identical(m1,m2))
119    ## bug :
120    table(m1 == m2)
121    ##  FALSE   TRUE
122    ##     78 506866
123    
124    
125    
126  proc.time()  proc.time()

Legend:
Removed from v.955  
changed lines
  Added in v.956

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