# SCM Repository

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

# Diff of /pkg/tests/indexing.R

revision 1833, Tue May 8 12:25:57 2007 UTC revision 1834, Fri May 11 10:07:17 2007 UTC
# Line 96  Line 96
96      j <- sample(sample(ncol(mC), 6), 17, replace = TRUE)      j <- sample(sample(ncol(mC), 6), 17, replace = TRUE)
97      assert.EQ.mat(mC[i,j], mm[i,j])      assert.EQ.mat(mC[i,j], mm[i,j])
98  }  }
99  ## symmetric index of symmetric matrix --- not yet  ok
100  m. <- mC; m.[, c(2, 7:12)] <- 0  ##---- Symmetric indexing of symmetric Matrix ----------
102  ss <- as(S, "matrix")  ss <- as(S, "matrix")
103  T <- as(S, "TsparseMatrix")  T <- as(S, "TsparseMatrix")
# Line 113  Line 113
113      assert.EQ.mat(Tii, ss[i,i])      assert.EQ.mat(Tii, ss[i,i])
114  }  }
115
116  ## repeeated ones:  ## repeated ones ``the challenge'' (to do smartly):
117  j <- c(4, 4, 9, 12, 9, 4, 17, 3, 18, 4, 12, 18, 4, 9)  j <- c(4, 4, 9, 12, 9, 4, 17, 3, 18, 4, 12, 18, 4, 9)
if(FALSE) ## FIXME
118  assert.EQ.mat(T[j,j], ss[j,j])  assert.EQ.mat(T[j,j], ss[j,j])
119    ## and another two sets  (a, A) &  (a., A.) :
120    a <- matrix(0, 6,6)
121    a[upper.tri(a)] <- (utr <- c(2, 0,-1, 0,0,5, 7,0,0,0, 0,0,-2,0,8))
122    ta <- t(a); ta[upper.tri(a)] <- utr; a <- t(ta)
123    diag(a) <- c(0,3,0,4,6,0)
124    A <- as(Matrix(a), "TsparseMatrix")
125    A. <- A
126    diag(A.) <- 10 * (1:6)
127    a. <- as(A., "matrix")
128    ## More testing {this was not working for a long time..}
129    set.seed(1)
130    for(n in 1:100) {
131        i <- sample(1:nrow(A), 3+2*rpois(1, lam=3), replace=TRUE)
132        Aii  <- A[i,i]
133        A.ii <- A.[i,i]
134        stopifnot(class(Aii) == class(A),
135                  class(A.ii) == class(A.))
136        assert.EQ.mat(Aii , a [i,i])
137        assert.EQ.mat(A.ii, a.[i,i])
138        assert.EQ.mat(T[i,i], ss[i,i])
139    }
140
141
142  stopifnot(all.equal(mC[,3], mm[,3]),  stopifnot(all.equal(mC[,3], mm[,3]),

Legend:
 Removed from v.1833 changed lines Added in v.1834