1 #test matrix [de]standardization
2 test.de_standardize = function()
6 M = matrix(rnorm(n*m,mean=2.0,sd=2.0),nrow=n,ncol=m)
8 std = synclust:::standardize(M)
10 checkEquals(rep(0.0, m), colMeans(std$M))
11 #result is standardized:
12 checkEquals(rep(1.0, m), sqrt( unlist( apply(std$M, 2, var) ) ))
15 M_rec = synclust:::destandardize(std)
19 #test neighborhoods remapping into one smaller component
20 test.remap_neighbors = function()
22 #connex comp : 1-2-5-8-10
23 #to remap into 1-2-3-4-5
40 c(1.0,2.0,3.0,4.0), #2
42 c(1.0,1.0,1.0,1.0), #4
45 c(1.0,1.0,1.0,1.0), #7
48 c(3.0,4.0,2.0,1.0), #10
52 indices = c(1,2,5,8,10)
53 locNI = synclust:::remapNeighbors(NI, indices)
54 checkEquals(2, length(locNI))
55 checkEquals(length(indices), length(locNI$ix))
56 checkEquals(length(indices), length(locNI$ds))
58 #formerly index 1 (now 1)
59 checkEquals(c(2,4,5), locNI$ix[[1]])
60 checkEquals(NI$ds[[1]], locNI$ds[[1]],)
61 #formerly index 2 (now 2)
62 checkEquals(c(1,3,4,5), locNI$ix[[2]])
63 checkEquals(NI$ds[[2]], locNI$ds[[2]])
64 #formerly index 5 (now 3)
65 checkEquals(c(2,5), locNI$ix[[3]])
66 checkEquals(NI$ds[[5]], locNI$ds[[3]])
67 #formerly index 8 (now 4)
68 checkEquals(c(1,2,5), locNI$ix[[4]])
69 checkEquals(NI$ds[[8]], locNI$ds[[4]])
70 #formerly index 10 (now 5)
71 checkEquals(c(1,2,3,4), locNI$ix[[5]])
72 checkEquals(NI$ds[[10]], locNI$ds[[5]])