# SCM Repository

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

# Diff of /pkg/tests/indexing.R

revision 1575, Mon Sep 18 14:47:40 2006 UTC revision 1599, Fri Sep 29 09:39:50 2006 UTC
# Line 44  Line 44
44  m[, 1] <- -1  m[, 1] <- -1
45  m[1:3,]  m[1:3,]
46
47    ## testing operations on logical Matrices rather more than indexing:
48  g10 <- m [ m > 10 ]  g10 <- m [ m > 10 ]
49  stopifnot(18 == length(g10))  stopifnot(18 == length(g10))
50  stopifnot(10 == length(m[ m <= 10 ]))  stopifnot(10 == length(m[ m <= 10 ]))
51  sel <- (20 < m) & (m < 150)  sel <- (20 < m) & (m < 150)
52    nsel <-(20 >= m) | (m >= 150)
53  (ssel <- as(sel, "sparseMatrix"))  (ssel <- as(sel, "sparseMatrix"))
54  stopifnot(is(sel, "lMatrix"), is(ssel, "lsparseMatrix"),  stopifnot(is(sel, "lMatrix"), is(ssel, "lsparseMatrix"),
55            identical(  m[ ssel], as.matrix(m)[as.matrix( ssel)]),            identical3(!sel, !ssel, nsel), # !<sparse> is typically dense
56            identical(  m[!ssel], as.matrix(m)[as.matrix(!ssel)])            identical3(m[ sel],  m[ ssel], as.matrix(m)[as.matrix( ssel)]),
57              identical3(m[!sel],  m[!ssel], as.matrix(m)[as.matrix(!ssel)])
58            )            )
59
60  ## more sparse Matrices --------------------------------------  ## more sparse Matrices --------------------------------------

Legend:
 Removed from v.1575 changed lines Added in v.1599