SCM

SCM Repository

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

Diff of /pkg/tests/indexing.R

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

revision 1226, Mon Mar 13 14:07:58 2006 UTC revision 1315, Mon Jul 10 16:08:05 2006 UTC
# Line 70  Line 70 
70    
71  stopifnot(identical(mC[7,  drop = FALSE],  stopifnot(identical(mC[7,  drop = FALSE],
72                      mC[7,, drop = FALSE]))                      mC[7,, drop = FALSE]))
73  mT[,c(2,4)]  validObject(print(mT[,c(2,4)]))
74  stopifnot(all.equal(mT[1,], mm[1,]))  stopifnot(all.equal(mT[2,], mm[2,]),
75              ## row or column indexing in combination with t() :
76              identical(mT[2,], t(mT)[,2]),
77              identical(mT[-2,], t(t(mT)[,-2])),
78              identical(mT[c(2,5),], t(t(mT)[,c(2,5)]))
79              )
80  assert.EQ.mat(mT[4,, drop = FALSE], mm[4,, drop = FALSE])  assert.EQ.mat(mT[4,, drop = FALSE], mm[4,, drop = FALSE])
81  stopifnot(identical3(mm[,1], mC[,1], mT[,1]),  stopifnot(identical3(mm[,1], mC[,1], mT[,1]),
82            identical3(mm[3,], mC[3,], mT[3,]),            identical3(mm[3,], mC[3,], mT[3,]),
# Line 125  Line 130 
130  mt[1:5, 2:6]  mt[1:5, 2:6]
131  as((mt0 - mt)[1:5,], "dsparseMatrix")# [1,5] and lines 2:3  as((mt0 - mt)[1:5,], "dsparseMatrix")# [1,5] and lines 2:3
132    
133  mt[c(2,4), ] <- 0  mt[c(2,4), ] <- 0; stopifnot(as(mt[c(2,4), ],"matrix") == 0)
134  mt[2:3, 4:7] <- 33  mt[2:3, 4:7] <- 33
135  validObject(mt)  validObject(mt)
136  mt  mt
137    
138  mc[1,4] <- -99  mc[1,4] <- -99 ; stopifnot(mc[1,4] == -99)
139    mc[1,4] <-  00 ; stopifnot(mc[1,4] ==  00)
140    mc[1,4] <- -99 ; stopifnot(mc[1,4] == -99)
141    mc[1:2,4:3] <- 4:1; stopifnot(as.matrix(mc[1:2,4:3]) == 4:1)
142    
143    ## Debugging:  R bug --   debug(Matrix:::replCmat)  has no effect
144    
145  mc[-1, 3] <- -2:1 # 0 should not be entered; 'value' recycled  mc[-1, 3] <- -2:1 # 0 should not be entered; 'value' recycled
146  mt[-1, 3] <- -2:1  mt[-1, 3] <- -2:1
147  stopifnot(mc@x != 0, mt@x != 0)  stopifnot(mc@x != 0, mt@x != 0,
148  mc[1:5 %% 2 == 0, 3] <- 0            mc[-1,3] == -2:1, mt[-1,3] == -2:1) ##--> BUG -- fixed
149    ## source("~/R/Pkgs/Matrix/R/Tsparse.R")
150    ## Matrix_expand_pointers <- Matrix:::Matrix_expand_pointers
151    ## -> open ../R/dgCMatrix.R  --> replCmat  .. now eval-line by line ..
152    
153    ev <- 1:5 %% 2 == 0
154    mc[ev, 3] <- 0:1
155    ##FIXME stopifnot(mc[ev, 3] == 0:1) ##-> BUG  {very peculiar; the 2nd time it works ...}
156  validObject(mc)  validObject(mc)
157  mc  mc # now shows a non-structural zeros
158  mc[ii, jj] <- 1:6  mc[ii, jj] <- 1:6
159  mc[c(2,5), c(3,5)] <- 3.2  mc[c(2,5), c(3,5)] <- 3.2
160  validObject(mc)  validObject(mc)
161  mc  (m. <- mc)
162    ## FIXME: mc[4,] <- 0 # -> error -- another Bug
163    
164  cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons''  cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons''

Legend:
Removed from v.1226  
changed lines
  Added in v.1315

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