commit last state
[ppam-mpi.git] / code / postprocess / visu.R
1 getLabel = function(fileName)
2 {
3 return (as.integer(as.matrix(read.table(fileName))))
4 }
5
6 getData = function(fileName)
7 {
8 return (as.matrix(read.table(fileName,sep=',')))
9 }
10
11 plotCurves = function(data, cols=rep(1,nrow(data)), ylim=range(data), ...)
12 {
13 for (i in 1:nrow(data))
14 {
15 if (dev.cur() > 1)
16 par(new=TRUE)
17 par(mar=c(5,5,2,2))
18 plot(data[i,],type="l",col=cols[i],ylim=ylim, ...)
19 }
20 }
21
22 getDistor = function(data, ctrs)
23 {
24 distor = 0.0
25 for (i in 1:nrow(data))
26 distor = distor + min(sqrt(colSums((t(ctrs) - data[i,])^2)))
27 return (distor)
28 }
29
30 getPartition = function(data, ctrs)
31 {
32 partition = c()
33 for (i in 1:nrow(data))
34 partition = c(partition, which.min(sqrt(colSums((t(ctrs) - data[i,])^2))))
35 return (partition)
36 }
37
38 #~ system("R CMD SHLIB hungarian.c")
39 #~ dyn.load("hungarian.so")
40 comparePartitions = function(partition1, partition2)
41 {
42 result = 1.0
43 n = length(partition1)
44 maxInd = max(partition1)
45 return ( .C("computeCoefSimil", P1=as.integer(partition1), P2=as.integer(partition2),
46 maxInd=as.integer(maxInd), n=as.integer(n), coefSimil=as.double(result))$coefSimil )
47 }