Revision 47b430f6e116f153b5f406d88ce26f868027a447 authored by Toni Giorgino on 30 November 2007, 00:00:00 UTC, committed by Gabor Csardi on 30 November 2007, 00:00:00 UTC
1 parent f3fa0a2
backtrack.R
###############################################################
# #
# (c) Toni Giorgino <toni.giorgino@gmail.com> #
# Laboratory for Biomedical Informatics #
# University of Pavia - Italy #
# www.labmedinfo.org #
# #
# $Id: backtrack.R 51 2007-12-11 10:59:08Z tonig $
# #
###############################################################
########################################
## Backtrack the steps taken - internal
`backtrack` <-
function(jmin, gcm) {
## mapping lists
ii<-c();
jj<-c();
dir<-gcm$stepPatterns;
n <- dim(gcm$costMatrix)[1];
m <- dim(gcm$costMatrix)[2];
i <- n;
j <- jmin;
repeat {
## cross fingers for termination
if(i==1 && j==1) {
break;
}
## direction taken
s<-gcm$directionMatrix[i,j];
## undo the steps
steps<-.extractpattern(dir,s);
ns<-dim(steps)[1];
for(k in 1:(ns-1)) {
## take note of current cell, prepending to mapping lists
ii <- c(i-steps[k,1],ii);
jj <- c(j-steps[k,2],jj);
## The final cell is not appended; it will be done
## processing step 0,0 at the next iteration
}
## And don't forget where we arrived
i<-i-steps[ns,1];
j<-j-steps[ns,2];
}
## The very final point of the backtrack is not otherwise appended
ii<-c(1,ii);
jj<-c(1,jj);
out<-list();
out$index1<-ii;
out$index2<-jj;
return(out);
}
Computing file changes ...