# SCM Repository

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

# Diff of /pkg/tests/indexing.R

revision 1600, Fri Sep 29 13:37:25 2006 UTC revision 1655, Mon Oct 30 17:16:27 2006 UTC
# Line 45  Line 45
45  m[1:3,]  m[1:3,]
46
47  ## testing operations on logical Matrices rather more than indexing:  ## testing operations on logical Matrices rather more than indexing:
48    m. <- as.matrix(m)
49  g10 <- m [ m > 10 ]  g10 <- m [ m > 10 ]
50  stopifnot(18 == length(g10))  stopifnot(18 == length(g10))
51  stopifnot(10 == length(m[ m <= 10 ]))  stopifnot(10 == length(m[ m <= 10 ]))
52  sel <- (20 <  m) & (m <  150)  sel <- (20 <  m) & (m <  150)
53    sel.<- (20 <  m.)& (m.<  150)
54  nsel <-(20 >= m) | (m >= 150)  nsel <-(20 >= m) | (m >= 150)
55  (ssel <- as(sel, "sparseMatrix"))  (ssel <- as(sel, "sparseMatrix"))
56  stopifnot(is(sel, "lMatrix"), is(ssel, "lsparseMatrix"),  stopifnot(is(sel, "lMatrix"), is(ssel, "lsparseMatrix"),
57              identical3(as.mat(sel.), as.mat(sel), as.mat(ssel)),
58            identical3(!sel, !ssel, nsel), # !<sparse> is typically dense            identical3(!sel, !ssel, nsel), # !<sparse> is typically dense
59            identical3(m[ sel],  m[ ssel], as.matrix(m)[as.matrix( ssel)]),            identical3(m[ sel],  m[ ssel], as.matrix(m)[as.matrix( ssel)]),
60            identical3(m[!sel],  m[!ssel], as.matrix(m)[as.matrix(!ssel)])            identical3(m[!sel],  m[!ssel], as.matrix(m)[as.matrix(!ssel)])

Legend:
 Removed from v.1600 changed lines Added in v.1655