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 2097, Sat Dec 8 13:36:13 2007 UTC revision 2098, Sun Dec 9 00:35:14 2007 UTC
# Line 249  Line 249 
249  stopifnot(is(T, "dtCMatrix"), identical(T[,3], c(10,10,10,0,0)))  stopifnot(is(T, "dtCMatrix"), identical(T[,3], c(10,10,10,0,0)))
250    
251    
252  ## "Vector indices" --- now ``work'' but wrongly __FIXME__  ## "Vector indices" -------------------
 i <- c(1,3,6); v <- c(10,15,20)  
253  D <- Diagonal(6)  D <- Diagonal(6)
254    M <- as(D,"dgeMatrix")
255  m <- as(D,"matrix")  m <- as(D,"matrix")
256  s <- as(D,"sparseMatrix")  s <- as(D,"TsparseMatrix")
257    S <- as(s,"CsparseMatrix")
258    i <- c(3,1,6); v <- c(10,15,20)
259    ## (logical,value) which both are recycled:
260    L <- c(TRUE, rep(FALSE,8)) ; z <- c(50,99)
261    
262  D[i] <- v; D  ## vector subassignment, both with integer & logical
263  s[i] <- v; s  ## these now work correctly {though not very efficiently; hence warnings}
264  m[i] <- v; m  m[i] <- v # the role model: only first column is affected
265    M[i] <- v; assert.EQ.mat(M,m) # dge
266    D[i] <- v; assert.EQ.mat(D,m) # ddi -> dtT -> dgT
267    s[i] <- v; assert.EQ.mat(s,m) # dtT -> dgT
268    S[i] <- v; assert.EQ.mat(S,m); S # dtC -> dtT -> dgT -> dgC
269    ## logical
270    m[L] <- z
271    M[L] <- z; assert.EQ.mat(M,m)
272    D[L] <- z; assert.EQ.mat(D,m)
273    s[L] <- z; assert.EQ.mat(s,m)
274    S[L] <- z; assert.EQ.mat(S,m) ; S
275    
276    ## indexing [i]  vs  [i,] --- now ok
277    stopifnot(identical4(m[i], M[i], D[i], s[i]), identical(s[i],S[i]))
278    stopifnot(identical4(m[L], M[L], D[L], s[L]), identical(s[L],S[L]))
279    assert.EQ.mat(D[i,], m[i,])
280    assert.EQ.mat(M[i,], m[i,])
281    assert.EQ.mat(s[i,], m[i,])
282    assert.EQ.mat(S[i,], m[i,])
283    
284    assert.EQ.mat(D[,i], m[,i])
285    assert.EQ.mat(M[,i], m[,i])
286    assert.EQ.mat(s[,i], m[,i])
287    assert.EQ.mat(S[,i], m[,i])
288    
289    
290  ## --- negative indices ----------  ## --- negative indices ----------

Legend:
Removed from v.2097  
changed lines
  Added in v.2098

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