00001 #include "DTW.h"
00002
00003 using std::ostringstream;
00004 using namespace Marsyas;
00005
00006 DTW::DTW(mrs_string name):MarSystem("DTW", name)
00007 {
00008 addControls();
00009 }
00010
00011 DTW::DTW(const DTW& a):MarSystem(a)
00012 {
00013 ctrl_mode_ = getctrl("mrs_string/mode");
00014 ctrl_localPath_ = getctrl("mrs_string/localPath");
00015 ctrl_startPos_ = getctrl("mrs_string/startPos");
00016 ctrl_lastPos_ = getctrl("mrs_string/lastPos");
00017 ctrl_totalDis_ = getctrl("mrs_real/totalDistance");
00018 ctrl_sizes_ = getctrl("mrs_realvec/sizes");
00019 ctrl_weight_ = getctrl("mrs_bool/weight");
00020 }
00021
00022 DTW::~DTW()
00023 {
00024 }
00025
00026 MarSystem*
00027 DTW::clone() const
00028 {
00029 return new DTW(*this);
00030 }
00031
00032 void
00033 DTW::addControls()
00034 {
00035 totalDis_ = 0;
00036 addControl("mrs_string/mode", "normal", ctrl_mode_);
00037 addControl("mrs_string/localPath", "normal", ctrl_localPath_);
00038 addControl("mrs_string/startPos", "zero", ctrl_startPos_);
00039 addControl("mrs_string/lastPos", "end", ctrl_lastPos_);
00040 addControl("mrs_real/totalDistance", totalDis_, ctrl_totalDis_);
00041 addControl("mrs_realvec/sizes", realvec(), ctrl_sizes_);
00042 addControl("mrs_bool/weight", false, ctrl_weight_);
00043 }
00044
00045 void DTW::myUpdate(MarControlPtr sender)
00046 {
00047 (void) sender;
00048
00049 ctrl_onSamples_->setValue(2,NOUPDATE);
00050 ctrl_onObservations_->setValue(ctrl_inSamples_+ctrl_inObservations_, NOUPDATE);
00051 ctrl_osrate_->setValue(ctrl_osrate_,NOUPDATE);
00052 ostringstream oss;
00053 for(mrs_natural o=0; o<ctrl_onObservations_->to<mrs_natural>(); ++o)
00054 oss << "DTW_" << o << ",";
00055 ctrl_onObsNames_->setValue(oss.str(), NOUPDATE);
00056
00057 MarControlAccessor acc(ctrl_sizes_);
00058 realvec& tmpvec = acc.to<mrs_realvec>();
00059 if(tmpvec.getRows() == 1 && tmpvec.getCols() >= 2)
00060 {
00061 sizes_.create(tmpvec.getCols());
00062 for(mrs_natural i=0; i<tmpvec.getCols(); ++i)
00063 {
00064 sizes_(i) = (mrs_natural)tmpvec(0,i);
00065 }
00066 }
00067 else if(tmpvec.getRows() >= 2 && tmpvec.getCols() == 1)
00068 {
00069 sizes_.create(tmpvec.getRows());
00070 for(mrs_natural i=0; i<tmpvec.getRows(); ++i)
00071 {
00072 sizes_(i) = (mrs_natural)tmpvec(i,0);
00073 }
00074 }
00075
00076 alignment_.create(ctrl_inObservations_->to<mrs_natural>(), ctrl_inSamples_->to<mrs_natural>());
00077 if(ctrl_localPath_->to<mrs_string>() == "normal")
00078 {
00079 costMatrix_.create(ctrl_inObservations_->to<mrs_natural>(), 2);
00080 matrixPos_.create(2);
00081 }
00082 else if(ctrl_localPath_->to<mrs_string>() == "diagonal")
00083 {
00084 costMatrix_.create(ctrl_inObservations_->to<mrs_natural>(), 3);
00085 matrixPos_.create(3);
00086 }
00087 if(ctrl_mode_->to<mrs_string>() == "OnePass")
00088 {
00089 mrs_natural nTemplates = sizes_.getSize()-1;
00090 beginPos_.create(nTemplates);
00091 endPos_.create(nTemplates);
00092 beginPos_(0) = 0;
00093 for(mrs_natural l=1; l<nTemplates; l++)
00094 {
00095 beginPos_(l) = sizes_(l) + beginPos_(l-1);
00096 }
00097 for(mrs_natural l=0; l<nTemplates; l++)
00098 {
00099 endPos_(l) = beginPos_(l) + sizes_(l+1);
00100
00101 }
00102 }
00103 }
00104
00105 void
00106 DTW::myProcess(realvec& in, realvec& out)
00107 {
00108 mrs_natural i, j, k, l;
00109 j = 0;
00110
00111 mrs_real nObs = in.getRows();
00112 mrs_real nSmp = in.getCols();
00113 mrs_real tmpReal = 0.0;
00114 mrs_bool weight = ctrl_weight_->to<mrs_bool>();
00115
00116 if(inSamples_ > 0)
00117 {
00118 if(ctrl_mode_->to<mrs_string>() == "normal")
00119 {
00120 if(ctrl_localPath_->to<mrs_string>() == "normal" || ((nSmp > 2*nObs || nObs > 2*nSmp) && ctrl_localPath_->to<mrs_string>() == "diagonal"))
00121 {
00122 if((nSmp > 2*nObs || nObs > 2*nSmp) && ctrl_localPath_->to<mrs_string>() == "diagonal")
00123 MRSWARN("DTW::myProcess - invalid local path control: diagonal (processes with normal local path)");
00124
00125 for(i=0; i<2; ++i)
00126 {
00127 matrixPos_(i) = i;
00128 }
00129
00130
00131 if(ctrl_startPos_->to<mrs_string>() == "zero")
00132 {
00133
00134 costMatrix_(0,(mrs_natural)matrixPos_(0)) = in(0,0);
00135 alignment_(0,0) = 0;
00136
00137 for(j=1; j<nObs; j++)
00138 {
00139 costMatrix_(j,(mrs_natural)matrixPos_(0)) = in(j,0)+costMatrix_(j-1,(mrs_natural)matrixPos_(0));
00140 alignment_(j,0) = 1;
00141 }
00142 }
00143 else if(ctrl_startPos_->to<mrs_string>() == "lowest")
00144 {
00145
00146 for(j=0; j<nObs; j++)
00147 {
00148 costMatrix_(j, (mrs_natural)matrixPos_(0)) = in(j,0);
00149 alignment_(j,0) = 0;
00150 }
00151 }
00152
00153 for(i=1; i<nSmp; ++i)
00154 {
00155 costMatrix_(0,(mrs_natural)matrixPos_(1)) = costMatrix_(0,(mrs_natural)matrixPos_(0)) + in(0,i);
00156 alignment_(0,i) = 3;
00157 for(j=1; j<nObs; j++)
00158 {
00159 costMatrix_(j,(mrs_natural)matrixPos_(1)) = costMatrix_(j-1,(mrs_natural)matrixPos_(1)) + in(j,i);
00160 alignment_(j,i) = 1;
00161 tmpReal = costMatrix_(j-1,(mrs_natural)matrixPos_(0)) + in(j,i);
00162 if(weight)
00163 tmpReal += in(j,i);
00164 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(1)))
00165 {
00166 costMatrix_(j,(mrs_natural)matrixPos_(1)) = tmpReal;
00167 alignment_(j,i) = 2;
00168 }
00169 tmpReal = costMatrix_(j,(mrs_natural)matrixPos_(0)) + in(j,i);
00170 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(1)))
00171 {
00172 costMatrix_(j,(mrs_natural)matrixPos_(1)) = tmpReal;
00173 alignment_(j,i) = 3;
00174 }
00175 }
00176 matrixPos_(0) = 1-matrixPos_(0);
00177 matrixPos_(1) = 1-matrixPos_(1);
00178 }
00179
00180
00181 for(i=0; i<out.getRows(); ++i)
00182 {
00183 for(j=0; j<out.getCols(); j++)
00184 {
00185 out(i,j) = -1;
00186 }
00187 }
00188 if(ctrl_lastPos_->to<mrs_string>() == "end")
00189 {
00190 totalDis_ = costMatrix_((mrs_natural)(nObs-1),(mrs_natural)matrixPos_(0));
00191 ctrl_totalDis_->setValue(totalDis_);
00192 i = (mrs_natural)(nSmp-1);
00193 j = (mrs_natural)(nObs-1);
00194 }
00195 else if(ctrl_lastPos_->to<mrs_string>() == "lowest")
00196 {
00197 tmpReal = costMatrix_(0, (mrs_natural)matrixPos_(0));
00198 j = 0;
00199 for(i=1; i<nObs; ++i)
00200 {
00201 if(costMatrix_(i, (mrs_natural)matrixPos_(0)) < tmpReal)
00202 {
00203 tmpReal = costMatrix_(i, (mrs_natural)matrixPos_(0));
00204 j = i;
00205 }
00206 }
00207 i = (mrs_natural)(nSmp-1);
00208 totalDis_ = tmpReal;
00209 ctrl_totalDis_->setValue(totalDis_);
00210 }
00211 k = (mrs_natural)(nSmp + nObs - 1);
00212 while(alignment_(j,i) != 0 && k>=0)
00213 {
00214 if(alignment_(j,i) == 1)
00215 {
00216 out(k,0) = i;
00217 out(k,1) = j;
00218 j--;
00219 k--;
00220 }
00221 else if(alignment_(j,i) == 2)
00222 {
00223 out(k,0) = i;
00224 out(k,1) = j;
00225 k--;
00226 if(weight)
00227 {
00228 out(k,0) = i;
00229 out(k,1) = j;
00230 k--;
00231 }
00232 i--;
00233 j--;
00234 }
00235 else if(alignment_(j,i) == 3)
00236 {
00237 out(k,0) = i;
00238 out(k,1) = j;
00239 k--;
00240 i--;
00241 }
00242 }
00243 out(k,0) = i;
00244 out(k,1) = j;
00245 }
00246
00247 else if(ctrl_localPath_->to<mrs_string>() == "diagonal")
00248 {
00249 for(i=0; i<3; ++i)
00250 {
00251 matrixPos_(i) = i;
00252 }
00253
00254
00255 if(ctrl_startPos_->to<mrs_string>() == "zero")
00256 {
00257
00258 costMatrix_(0,(mrs_natural)matrixPos_(0)) = in(0,0);
00259 alignment_(0,0) = 0;
00260
00261 costMatrix_(1,(mrs_natural)matrixPos_(1)) = costMatrix_(0,(mrs_natural)matrixPos_(0)) + in(1,1);
00262 if(weight)
00263 costMatrix_(1,(mrs_natural)matrixPos_(1)) += in(1,1);
00264 costMatrix_(2,(mrs_natural)matrixPos_(1)) = costMatrix_(0,(mrs_natural)matrixPos_(0)) + in(1,1) + in(2,1);
00265 if(weight)
00266 costMatrix_(2,(mrs_natural)matrixPos_(1)) += in(1,1);
00267 alignment_(1,1) = 2;
00268 alignment_(2,1) = 1;
00269
00270 costMatrix_(1,(mrs_natural)matrixPos_(2)) = costMatrix_(0,(mrs_natural)matrixPos_(0)) + in(1,1) + in(1,2);
00271 if(weight)
00272 costMatrix_(1,(mrs_natural)matrixPos_(2)) += in(1,1);
00273 alignment_(1,2) = 3;
00274 costMatrix_(2,(mrs_natural)matrixPos_(2)) = costMatrix_(1,(mrs_natural)matrixPos_(1)) + in(2,2);
00275 if(weight)
00276 costMatrix_(2,(mrs_natural)matrixPos_(2)) += in(2,2);
00277 alignment_(2,2) = 2;
00278 costMatrix_(3,(mrs_natural)matrixPos_(2)) = costMatrix_(2,(mrs_natural)matrixPos_(1)) + in(3,2);
00279 if(weight)
00280 costMatrix_(3,(mrs_natural)matrixPos_(2)) += in(3,2);
00281 alignment_(3,2) = 2;
00282 tmpReal = costMatrix_(1,(mrs_natural)matrixPos_(1)) + in(2,2) + in(3,2);
00283 if(weight)
00284 tmpReal += in(2,2);
00285 if(tmpReal < costMatrix_(3,(mrs_natural)matrixPos_(2)))
00286 {
00287 costMatrix_(3,(mrs_natural)matrixPos_(2)) = tmpReal;
00288 alignment_(3,2) = 1;
00289 }
00290 }
00291 else if(ctrl_startPos_->to<mrs_string>() == "lowest")
00292 {
00293
00294 for(j=0; j<nObs; j++)
00295 {
00296 costMatrix_(j, (mrs_natural)matrixPos_(0)) = in(j,0);
00297 alignment_(j,0) = 0;
00298 }
00299
00300 costMatrix_(1,(mrs_natural)matrixPos_(1)) = costMatrix_(0,(mrs_natural)matrixPos_(0)) + in(1,1);
00301 if(weight)
00302 costMatrix_(1,(mrs_natural)matrixPos_(1)) += in(1,1);
00303 alignment_(1,1) = 2;
00304 for(j=2; j<nObs; j++)
00305 {
00306 costMatrix_(j,(mrs_natural)matrixPos_(1)) = costMatrix_(j-1,(mrs_natural)matrixPos_(0)) + in(j,1);
00307 if(weight)
00308 costMatrix_(j,(mrs_natural)matrixPos_(1)) += in(j,1);
00309 alignment_(j,1) = 2;
00310 tmpReal = costMatrix_(j-2,(mrs_natural)matrixPos_(0)) + in(j-1,1) + in(j,1);
00311 if(weight)
00312 tmpReal += in(j-1,1);
00313 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(1)))
00314 {
00315 costMatrix_(j,(mrs_natural)matrixPos_(1)) = tmpReal;
00316 alignment_(j,1) = 1;
00317 }
00318 }
00319
00320 costMatrix_(1,(mrs_natural)matrixPos_(2)) = costMatrix_(0,(mrs_natural)matrixPos_(0)) + in(1,1) + in(1,2);
00321 if(weight)
00322 costMatrix_(1,(mrs_natural)matrixPos_(2)) += in(1,1);
00323 alignment_(1,2) = 3;
00324 for(j=2; j<nObs; j++)
00325 {
00326 costMatrix_(j,(mrs_natural)matrixPos_(2)) = costMatrix_(j-1,(mrs_natural)matrixPos_(1)) + in(j,2);
00327 if(weight)
00328 costMatrix_(j,(mrs_natural)matrixPos_(2)) += in(j,2);
00329 alignment_(j,2) = 2;
00330 if(alignment_(j-2,2) != 0)
00331 {
00332 tmpReal = costMatrix_(j-2,(mrs_natural)matrixPos_(1)) + in(j-1,2) + in(j,2);
00333 if(weight)
00334 tmpReal += in(j-1,2);
00335 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(2)))
00336 {
00337 costMatrix_(j,(mrs_natural)matrixPos_(2));
00338 alignment_(j,2) = 1;
00339 }
00340 }
00341 tmpReal = costMatrix_(j-1,(mrs_natural)matrixPos_(0)) + in(j,1) + in(j,2);
00342 if(weight)
00343 tmpReal += in(j,1);
00344 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(2)))
00345 {
00346 costMatrix_(j,(mrs_natural)matrixPos_(2)) = tmpReal;
00347 alignment_(j,2) = 3;
00348 }
00349 }
00350 }
00351 for(i=0; i<3; ++i)
00352 {
00353 matrixPos_(i)++;
00354 if(matrixPos_(i)>=3)
00355 matrixPos_(i) = 0;
00356 }
00357
00358 for(i=3; i<nSmp; ++i)
00359 {
00360 for(j=2; j<nObs; j++)
00361 {
00362 if(alignment_(j-1,i-2) != 0)
00363 {
00364 costMatrix_(j,(mrs_natural)matrixPos_(2)) = costMatrix_(j-1,(mrs_natural)matrixPos_(0)) + in(j,i-1) + in(j,i);
00365 if(weight)
00366 costMatrix_(j,(mrs_natural)matrixPos_(2)) += in(j,i-1);
00367 alignment_(j,i) = 3;
00368 if(alignment_(j-1,i-1) != 0)
00369 {
00370 tmpReal = costMatrix_(j-1,(mrs_natural)matrixPos_(1)) + in(j,i);
00371 if(weight)
00372 tmpReal += in(j,i);
00373 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(2)))
00374 {
00375 costMatrix_(j,(mrs_natural)matrixPos_(2)) = tmpReal;
00376 alignment_(j,i) = 2;
00377 }
00378 }
00379 if(alignment_(j-2,i-1) != 0)
00380 {
00381 tmpReal = costMatrix_(j-2,(mrs_natural)matrixPos_(1)) + in(j-1,i) + in(j,i);
00382 if(weight)
00383 tmpReal += in(j-1,i);
00384 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(2)))
00385 {
00386 costMatrix_(j,(mrs_natural)matrixPos_(2)) = tmpReal;
00387 alignment_(j,i) = 1;
00388 }
00389 }
00390 }
00391 else if(alignment_(j-1,i-1) != 0)
00392 {
00393 costMatrix_(j,(mrs_natural)matrixPos_(2)) = costMatrix_(j-1,(mrs_natural)matrixPos_(1)) + in(j,i);
00394 if(weight)
00395 costMatrix_(j,(mrs_natural)matrixPos_(2)) += in(j,i);
00396 alignment_(j,i) = 2;
00397 if(alignment_(j-2,i-1) != 0)
00398 {
00399 tmpReal = costMatrix_(j-2,(mrs_natural)matrixPos_(1)) + in(j-1,i) + in(j,i);
00400 if(weight)
00401 tmpReal += in(j-1,i);
00402 alignment_(j,i) = 1;
00403 }
00404 }
00405 else if(alignment_(j-2,i-1) != 0)
00406 {
00407 costMatrix_(j,(mrs_natural)matrixPos_(2)) = costMatrix_(j-2,(mrs_natural)matrixPos_(1)) + in(j-1,i) + in(j,i);
00408 if(weight)
00409 costMatrix_(j,(mrs_natural)matrixPos_(2)) += in(j-1,i);
00410 alignment_(j,i) = 1;
00411 }
00412 }
00413 for(j=0; j<3; j++)
00414 {
00415 matrixPos_(j)++;
00416 if(matrixPos_(j) >= 3)
00417 matrixPos_(j) = 0;
00418 }
00419 }
00420
00421
00422 for(i=0; i<out.getRows(); ++i)
00423 {
00424 for(j=0; j<out.getCols(); j++)
00425 {
00426 out(i,j) = -1;
00427 }
00428 }
00429 if(ctrl_lastPos_->to<mrs_string>() == "end")
00430 {
00431 totalDis_ = costMatrix_((mrs_natural)(nObs-1),(mrs_natural)matrixPos_(1));
00432 ctrl_totalDis_->setValue(totalDis_);
00433 i = (mrs_natural)(nSmp-1);
00434 j = (mrs_natural)(nObs-1);
00435 }
00436 else if(ctrl_lastPos_->to<mrs_string>() == "lowest")
00437 {
00438 tmpReal = costMatrix_((mrs_natural)(nObs-1), (mrs_natural)matrixPos_(1));
00439 j = (mrs_natural)(nObs-1);
00440 for(i=0; i<nObs-1; ++i)
00441 {
00442 if(costMatrix_(i, (mrs_natural)matrixPos_(1)) < tmpReal && alignment_(i,(mrs_natural)(nSmp-1)) != 0)
00443 {
00444 tmpReal = costMatrix_(i, (mrs_natural)matrixPos_(1));
00445 j = i;
00446 }
00447 }
00448 i = (mrs_natural)(nSmp-1);
00449 totalDis_ = tmpReal;
00450 ctrl_totalDis_->setValue(totalDis_);
00451 }
00452 k = (mrs_natural)(nSmp + nObs - 1);
00453 while(alignment_(j,i) != 0 && k>=0)
00454 {
00455 if(alignment_(j,i) == 1)
00456 {
00457 out(k,0) = i;
00458 out(k,1) = j;
00459 j--;
00460 k--;
00461 out(k,0) = i;
00462 out(k,1) = j;
00463 k--;
00464 if(weight)
00465 {
00466 out(k,0) = i;
00467 out(k,1) = j;
00468 k--;
00469 }
00470 i--;
00471 j--;
00472 }
00473 else if(alignment_(j,i) == 2)
00474 {
00475 out(k,0) = i;
00476 out(k,1) = j;
00477 k--;
00478 if(weight)
00479 {
00480 out(k,0) = i;
00481 out(k,1) = j;
00482 k--;
00483 }
00484 i--;
00485 j--;
00486 }
00487 else if(alignment_(j,i) == 3)
00488 {
00489 out(k,0) = i;
00490 out(k,1) = j;
00491 k--;
00492 i--;
00493 out(k,0) = i;
00494 out(k,1) = j;
00495 k--;
00496 if(weight)
00497 {
00498 out(k,0) = i;
00499 out(k,1) = j;
00500 k--;
00501 }
00502 i--;
00503 j--;
00504 }
00505 }
00506 out(k,0) = i;
00507 out(k,1) = j;
00508 }
00509 }
00510
00511 else if(ctrl_mode_->to<mrs_string>() == "OnePass")
00512 {
00513 mrs_natural nTemplates = sizes_.getSize()-1;
00514 if(sizes_.getSize() > 0)
00515 {
00516
00517 if(ctrl_localPath_->to<mrs_string>() == "normal")
00518 {
00519 for(i=0; i<2; ++i)
00520 {
00521 matrixPos_(i) = i;
00522 }
00523
00524
00525 if(ctrl_startPos_->to<mrs_string>() == "zero")
00526 {
00527
00528 for(l=0; l<nTemplates; l++)
00529 {
00530 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(0)) = in((mrs_natural)beginPos_(l),0);
00531 alignment_((mrs_natural)beginPos_(l),0) = 0;
00532 }
00533
00534 for(l=0; l<nTemplates; l++)
00535 {
00536 for(j=(mrs_natural)beginPos_(l)+1; j<endPos_(l); j++)
00537 {
00538 costMatrix_(j,(mrs_natural)matrixPos_(0)) = in(j,0) + costMatrix_(j-1,(mrs_natural)matrixPos_(0));
00539 alignment_(j,0) = 1;
00540 }
00541 }
00542 }
00543 else if(ctrl_startPos_->to<mrs_string>() == "lowest")
00544 {
00545
00546 for(j=0; j<nObs; j++)
00547 {
00548 costMatrix_(j,(mrs_natural)matrixPos_(0)) = in(j,0);
00549 alignment_(j,0) = 0;
00550 }
00551 }
00552
00553 for(i=1; i<nSmp; ++i)
00554 {
00555 for(l=0; l<nTemplates; l++)
00556 {
00557 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(1)) = costMatrix_((mrs_natural)endPos_(l)-1,(mrs_natural)matrixPos_(0)) + in((mrs_natural)beginPos_(l),i);
00558 if(weight)
00559 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(1)) += in((mrs_natural)beginPos_(l),i);
00560 alignment_((mrs_natural)beginPos_(l),i) = -1*(endPos_(l)-1);
00561 tmpReal = costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(0)) + in((mrs_natural)beginPos_(l),i);
00562 if(tmpReal < costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(1)))
00563 {
00564 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(1)) = tmpReal;
00565 alignment_((mrs_natural)beginPos_(l), i) = 3;
00566 }
00567 for(j=(mrs_natural)beginPos_(l)+1; j<(mrs_natural)endPos_(l); j++)
00568 {
00569 costMatrix_(j,(mrs_natural)matrixPos_(1)) = costMatrix_(j-1,(mrs_natural)matrixPos_(1)) + in(j,i);
00570 alignment_(j,i) = 1;
00571 tmpReal = costMatrix_(j-1,(mrs_natural)matrixPos_(0)) + in(j,i);
00572 if(weight)
00573 tmpReal += in(j,i);
00574 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(1)))
00575 {
00576 costMatrix_(j,(mrs_natural)matrixPos_(1)) = tmpReal;
00577 alignment_(j,i) = 2;
00578 }
00579 tmpReal = costMatrix_(j,(mrs_natural)matrixPos_(0)) + in(j,i);
00580 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(1)))
00581 {
00582 costMatrix_(j,(mrs_natural)matrixPos_(1)) = tmpReal;
00583 alignment_(j,i) = 3;
00584 }
00585 }
00586 }
00587 matrixPos_(0) = 1-matrixPos_(0);
00588 matrixPos_(1) = 1-matrixPos_(1);
00589 }
00590
00591
00592 for(i=0; i<out.getRows(); ++i)
00593 {
00594 for(j=0; j<out.getCols(); j++)
00595 {
00596 out(i,j) = -1;
00597 }
00598 }
00599 if(ctrl_lastPos_->to<mrs_string>() == "end")
00600 {
00601 tmpReal = costMatrix_((mrs_natural)endPos_(0)-1,(mrs_natural)matrixPos_(0));
00602 j = (mrs_natural)endPos_(0)-1;
00603 for(l=1; l<nTemplates; l++)
00604 {
00605 if(costMatrix_((mrs_natural)endPos_(l)-1,(mrs_natural)matrixPos_(0)) < tmpReal)
00606 {
00607 tmpReal = costMatrix_((mrs_natural)endPos_(l)-1,(mrs_natural)matrixPos_(0));
00608 j = (mrs_natural)endPos_(l)-1;
00609 }
00610 }
00611 totalDis_ = tmpReal;
00612 ctrl_totalDis_->setValue(totalDis_);
00613 i = (mrs_natural)(nSmp-1);
00614 }
00615 else if(ctrl_lastPos_->to<mrs_string>() == "lowest")
00616 {
00617 tmpReal = costMatrix_(0, (mrs_natural)matrixPos_(0));
00618 j=0;
00619 for(i=1; i<nObs; ++i)
00620 {
00621 if(costMatrix_(i,(mrs_natural)matrixPos_(0)) < tmpReal)
00622 {
00623 tmpReal = costMatrix_(i, (mrs_natural)matrixPos_(0));
00624 j = i;
00625 }
00626 }
00627 i = (mrs_natural)nSmp-1;
00628 totalDis_ = tmpReal;
00629 ctrl_totalDis_->setValue(totalDis_);
00630 }
00631 k = (mrs_natural)(3*nSmp - 1);
00632 while(alignment_(j,i) != 0 && k>=0)
00633 {
00634 if(alignment_(j,i) == 1)
00635 {
00636 out(k,0) = i;
00637 out(k,1) = j;
00638 j--;
00639 k--;
00640 }
00641 else if(alignment_(j,i) == 2)
00642 {
00643 out(k,0) = i;
00644 out(k,1) = j;
00645 k--;
00646 if(weight)
00647 {
00648 out(k,0) = i;
00649 out(k,1) = j;
00650 k--;
00651 }
00652 i--;
00653 j--;
00654 }
00655 else if(alignment_(j,i) == 3)
00656 {
00657 out(k,0) = i;
00658 out(k,1) = j;
00659 k--;
00660 i--;
00661 }
00662 else if(alignment_(j,i) < 0)
00663 {
00664 out(k,0) = i;
00665 out(k,1) = j;
00666 k--;
00667 if(weight)
00668 {
00669 out(k,0) = i;
00670 out(k,1) = j;
00671 k--;
00672 }
00673 j = -1*(mrs_natural)alignment_(j,i);
00674 i--;
00675 }
00676 }
00677 out(k,0) = i;
00678 out(k,1) = j;
00679 }
00680 else if(ctrl_localPath_->to<mrs_string>() == "diagonal")
00681 {
00682 for(i=0; i<3; ++i)
00683 {
00684 matrixPos_(i) = i;
00685 }
00686
00687
00688 if(ctrl_startPos_->to<mrs_string>() == "zero")
00689 {
00690
00691 for(l=0; l<nTemplates; l++)
00692 {
00693 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(0)) = in((mrs_natural)beginPos_(l),0);
00694 alignment_((mrs_natural)beginPos_(l),0) = 0;
00695 }
00696
00697 for(l=0; l<nTemplates; l++)
00698 {
00699 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(1)) = costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(0)) + in((mrs_natural)beginPos_(l)+1,1);
00700 if(weight)
00701 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(1)) += in((mrs_natural)beginPos_(l)+1,1);
00702 costMatrix_((mrs_natural)beginPos_(l)+2,(mrs_natural)matrixPos_(1)) = costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(0)) + in((mrs_natural)beginPos_(l)+1,1) + in((mrs_natural)beginPos_(l)+2,1);
00703 if(weight)
00704 costMatrix_((mrs_natural)beginPos_(l)+2,(mrs_natural)matrixPos_(1)) += in((mrs_natural)beginPos_(l)+1,1);
00705 alignment_((mrs_natural)beginPos_(l)+1,1) = 2;
00706 alignment_((mrs_natural)beginPos_(l)+2,1) = 1;
00707 }
00708
00709 for(l=0; l<nTemplates; l++)
00710 {
00711 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)) = costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(0)) + in((mrs_natural)beginPos_(l)+1,1) + in((mrs_natural)beginPos_(l)+1,2);
00712 if(weight)
00713 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)) += in((mrs_natural)beginPos_(l)+1,1);
00714 alignment_((mrs_natural)beginPos_(l)+1,2) = 3;
00715 costMatrix_((mrs_natural)beginPos_(l)+2,(mrs_natural)matrixPos_(2)) = costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(1)) + in((mrs_natural)beginPos_(l)+2,2);
00716 if(weight)
00717 costMatrix_((mrs_natural)beginPos_(l)+2,(mrs_natural)matrixPos_(2)) += in((mrs_natural)beginPos_(l)+2,2);
00718 alignment_((mrs_natural)beginPos_(l)+2,2) = 2;
00719 costMatrix_((mrs_natural)beginPos_(l)+3,(mrs_natural)matrixPos_(2)) = costMatrix_((mrs_natural)beginPos_(l)+2,(mrs_natural)matrixPos_(1)) + in((mrs_natural)beginPos_(l)+3,2);
00720 if(weight)
00721 costMatrix_((mrs_natural)beginPos_(l)+3,(mrs_natural)matrixPos_(2)) += in((mrs_natural)beginPos_(l)+3,2);
00722 alignment_((mrs_natural)beginPos_(l)+3,2) = 2;
00723 tmpReal = costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(1)) + in((mrs_natural)beginPos_(l)+2,2) + in((mrs_natural)beginPos_(l)+3,2);
00724 if(weight)
00725 tmpReal += in((mrs_natural)beginPos_(l)+2,2);
00726 if(tmpReal < costMatrix_((mrs_natural)beginPos_(l)+3,(mrs_natural)matrixPos_(2)))
00727 {
00728 costMatrix_((mrs_natural)beginPos_(l)+3,(mrs_natural)matrixPos_(2)) = tmpReal;
00729 alignment_((mrs_natural)beginPos_(l)+3,2) = 1;
00730 }
00731 }
00732 }
00733 else if(ctrl_startPos_->to<mrs_string>() == "lowest")
00734 {
00735
00736 for(j=0; j<nObs; j++)
00737 {
00738 costMatrix_(j, (mrs_natural)matrixPos_(0)) = in(j,0);
00739 alignment_(j,0) = 0;
00740 }
00741
00742 tmpReal = costMatrix_((mrs_natural)endPos_(0)-1,(mrs_natural)matrixPos_(0));
00743 j=(mrs_natural)endPos_(0)-1;
00744 for(l=1; l<nTemplates; l++)
00745 {
00746 if(costMatrix_((mrs_natural)endPos_(l)-1,(mrs_natural)matrixPos_(0)) < tmpReal)
00747 {
00748 tmpReal = costMatrix_((mrs_natural)endPos_(l)-1,(mrs_natural)matrixPos_(0));
00749 j=(mrs_natural)endPos_(l)-1;
00750 }
00751 }
00752 for(l=0; l<nTemplates; l++)
00753 {
00754 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(1)) = costMatrix_(j,(mrs_natural)matrixPos_(0)) + in((mrs_natural)beginPos_(l),1);
00755 if(weight)
00756 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(1)) += in((mrs_natural)beginPos_(l),1);
00757 alignment_((mrs_natural)beginPos_(l),1) = -1*j;
00758 }
00759 for(l=0; l<nTemplates; l++)
00760 {
00761 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(1)) = costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(0)) + in((mrs_natural)beginPos_(l)+1,1);
00762 if(weight)
00763 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(1)) += in((mrs_natural)beginPos_(l)+1,1);
00764 alignment_((mrs_natural)beginPos_(l)+1,1) = 2;
00765 for(j=(mrs_natural)beginPos_(l)+2; j<(mrs_natural)endPos_(l); j++)
00766 {
00767 costMatrix_(j,(mrs_natural)matrixPos_(1)) = costMatrix_(j-1,(mrs_natural)matrixPos_(0)) + in(j,1);
00768 if(weight)
00769 costMatrix_(j,(mrs_natural)matrixPos_(1)) += in(j,1);
00770 alignment_(j,1) = 2;
00771 tmpReal = costMatrix_(j-2,(mrs_natural)matrixPos_(0)) + in(j-1,1) + in(j,1);
00772 if(weight)
00773 tmpReal += in(j-1,1);
00774 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(1)))
00775 {
00776 costMatrix_(j,(mrs_natural)matrixPos_(1)) = tmpReal;
00777 alignment_(j,1) = 1;
00778 }
00779 }
00780 }
00781
00782 tmpReal = costMatrix_((mrs_natural)endPos_(0)-1,(mrs_natural)matrixPos_(1));
00783 j=(mrs_natural)endPos_(0)-1;
00784 for(l=1; l<nTemplates; l++)
00785 {
00786 if(costMatrix_((mrs_natural)endPos_(l)-1,(mrs_natural)matrixPos_(1)) < tmpReal)
00787 {
00788 tmpReal = costMatrix_((mrs_natural)endPos_(l)-1, (mrs_natural)matrixPos_(1));
00789 j=(mrs_natural)endPos_(l)-1;
00790 }
00791 }
00792 for(l=0; l<nTemplates; l++)
00793 {
00794 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(2)) = costMatrix_(j,(mrs_natural)matrixPos_(1)) + in((mrs_natural)beginPos_(l),2);
00795 if(weight)
00796 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(2)) += in((mrs_natural)beginPos_(l),2);
00797 alignment_((mrs_natural)beginPos_(l),2) = -1*j;
00798 }
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818 for(l=0; l<nTemplates; l++)
00819 {
00820 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)) = costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(1)) + in((mrs_natural)beginPos_(l)+1,2);
00821 if(weight)
00822 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)) += in((mrs_natural)beginPos_(l)+1,2);
00823 alignment_((mrs_natural)beginPos_(l)+1,2) = 2;
00824 tmpReal = costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(0)) + in((mrs_natural)beginPos_(l)+1,1) + in((mrs_natural)beginPos_(l)+1,2);
00825 if(weight)
00826 tmpReal += in((mrs_natural)beginPos_(l)+1,1);
00827 if(tmpReal < costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)))
00828 {
00829 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)) = tmpReal;
00830 alignment_((mrs_natural)beginPos_(l)+1,2) = 3;
00831 }
00832 for(j=(mrs_natural)beginPos_(l)+2; j<(mrs_natural)endPos_(l); j++)
00833 {
00834 costMatrix_(j,(mrs_natural)matrixPos_(2)) = costMatrix_(j-1,(mrs_natural)matrixPos_(0)) + in(j,1) + in(j,2);
00835 if(weight)
00836 costMatrix_(j,(mrs_natural)matrixPos_(2)) += in(j,1);
00837 alignment_(j,2) = 3;
00838 tmpReal = costMatrix_(j-1,(mrs_natural)matrixPos_(1)) + in(j,2);
00839 if(weight)
00840 tmpReal += in(j,2);
00841 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(2)))
00842 {
00843 costMatrix_(j,(mrs_natural)matrixPos_(2)) = tmpReal;
00844 alignment_(j,2) = 2;
00845 }
00846 tmpReal = costMatrix_(j-2,(mrs_natural)matrixPos_(1)) + in(j-1,2) + in(j,2);
00847 if(weight)
00848 tmpReal += in(j-1,2);
00849 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(2)))
00850 {
00851 costMatrix_(j,(mrs_natural)matrixPos_(2)) = tmpReal;
00852 alignment_(j,2) = 1;
00853 }
00854 }
00855 }
00856 }
00857 for(i=0; i<3; ++i)
00858 {
00859 matrixPos_(i)++;
00860 if(matrixPos_(i)>=3)
00861 matrixPos_(i) = 0;
00862 }
00863
00864 for(i=3; i<nSmp; ++i)
00865 {
00866 j = -1;
00867 for(l=0; l<nTemplates; l++)
00868 {
00869 if(alignment_((mrs_natural)endPos_(l)-1,i-1) != 0)
00870 {
00871 if(j<0 || (j>=0&&costMatrix_((mrs_natural)endPos_(l)-1,(mrs_natural)matrixPos_(1))<tmpReal))
00872 {
00873 tmpReal = costMatrix_((mrs_natural)endPos_(l)-1,(mrs_natural)matrixPos_(1));
00874 j = (mrs_natural)endPos_(l)-1;
00875 }
00876 }
00877 }
00878 if(j>=0)
00879 {
00880 for(l=0; l<nTemplates; l++)
00881 {
00882 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(2)) = costMatrix_(j,(mrs_natural)matrixPos_(1)) + in((mrs_natural)beginPos_(l),i);
00883 if(weight)
00884 costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(2)) += in((mrs_natural)beginPos_(l),i);
00885 alignment_((mrs_natural)beginPos_(l),i) = -1*j;
00886 }
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911 }
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935 for(l=0; l<nTemplates; l++)
00936 {
00937 if(alignment_((mrs_natural)beginPos_(l),i-1) != 0)
00938 {
00939 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)) = costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(1)) + in((mrs_natural)beginPos_(l)+1,i);
00940 if(weight)
00941 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)) += in((mrs_natural)beginPos_(l)+1,i);
00942 alignment_((mrs_natural)beginPos_(l)+1,i) = 2;
00943 if(alignment_((mrs_natural)beginPos_(l),i-2) != 0)
00944 {
00945 tmpReal = costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(0)) + in((mrs_natural)beginPos_(l)+1,i-1) + in((mrs_natural)beginPos_(l)+1,i);
00946 if(weight)
00947 tmpReal += in((mrs_natural)beginPos_(l)+1,i-1);
00948 if(tmpReal < costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)))
00949 {
00950 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)) = tmpReal;
00951 alignment_((mrs_natural)beginPos_(l)+1,i) = 3;
00952 }
00953 }
00954 }
00955 else if(alignment_((mrs_natural)beginPos_(l),i-2) != 0)
00956 {
00957 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)) = costMatrix_((mrs_natural)beginPos_(l),(mrs_natural)matrixPos_(0)) + in((mrs_natural)beginPos_(l)+1,i-1) + in((mrs_natural)beginPos_(l)+1,i);
00958 if(weight)
00959 costMatrix_((mrs_natural)beginPos_(l)+1,(mrs_natural)matrixPos_(2)) += in((mrs_natural)beginPos_(l)+1,i-1);
00960 alignment_((mrs_natural)beginPos_(l)+1,i) = 3;
00961 }
00962 for(j=(mrs_natural)beginPos_(l)+2; j<(mrs_natural)endPos_(l); j++)
00963 {
00964 if(alignment_(j-1,i-2) != 0)
00965 {
00966 costMatrix_(j,(mrs_natural)matrixPos_(2)) = costMatrix_(j-1,(mrs_natural)matrixPos_(0)) + in(j,i-1) + in(j,i);
00967 if(weight)
00968 costMatrix_(j,(mrs_natural)matrixPos_(2)) += in(j,i-1);
00969 alignment_(j,i) = 3;
00970 if(alignment_(j-1,i-1) != 0)
00971 {
00972 tmpReal = costMatrix_(j-1,(mrs_natural)matrixPos_(1)) + in(j,i);
00973 if(weight)
00974 tmpReal += in(j,i);
00975 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(2)))
00976 {
00977 costMatrix_(j,(mrs_natural)matrixPos_(2)) = tmpReal;
00978 alignment_(j,i) = 2;
00979 }
00980 }
00981 if(alignment_(j-2,i-1) != 0)
00982 {
00983 tmpReal = costMatrix_(j-2,(mrs_natural)matrixPos_(1)) + in(j-1,i) + in(j,i);
00984 if(weight)
00985 tmpReal += in(j-1,i);
00986 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(2)))
00987 {
00988 costMatrix_(j,(mrs_natural)matrixPos_(2)) = tmpReal;
00989 alignment_(j,i) = 1;
00990 }
00991 }
00992 }
00993 else if(alignment_(j-1,i-1) != 0)
00994 {
00995 costMatrix_(j,(mrs_natural)matrixPos_(2)) = costMatrix_(j-1,(mrs_natural)matrixPos_(1)) + in(j,i);
00996 if(weight)
00997 costMatrix_(j,(mrs_natural)matrixPos_(2)) += in(j,i);
00998 alignment_(j,i) = 2;
00999 if(alignment_(j-2,i-1) != 0)
01000 {
01001 tmpReal = costMatrix_(j-2,(mrs_natural)matrixPos_(1)) + in(j-1,i) + in(j,i);
01002 if(weight)
01003 tmpReal += in(j-1,i);
01004 if(tmpReal < costMatrix_(j,(mrs_natural)matrixPos_(2)))
01005 {
01006 costMatrix_(j,(mrs_natural)matrixPos_(2)) = tmpReal;
01007 alignment_(j,i) = 1;
01008 }
01009
01010 }
01011 }
01012 else if(alignment_(j-2,i-1) != 0)
01013 {
01014 costMatrix_(j,(mrs_natural)matrixPos_(2)) = costMatrix_(j-2,(mrs_natural)matrixPos_(1)) + in(j-1,i) + in(j,i);
01015 if(weight)
01016 costMatrix_(j,(mrs_natural)matrixPos_(2)) += in(j-1,i);
01017 alignment_(j,i) = 1;
01018 }
01019 }
01020 }
01021 for(j=0; j<3; j++)
01022 {
01023 matrixPos_(j)++;
01024 if(matrixPos_(j) >= 3)
01025 matrixPos_(j) = 0;
01026 }
01027 }
01028
01029
01030 for(i=0; i<out.getRows(); ++i)
01031 {
01032 for(j=0; j<out.getCols(); j++)
01033 {
01034 out(i,j) = -1;
01035 }
01036 }
01037 if(ctrl_lastPos_->to<mrs_string>() == "end")
01038 {
01039 tmpReal = costMatrix_((mrs_natural)endPos_(0)-1,(mrs_natural)matrixPos_(1));
01040 j = (mrs_natural)endPos_(0)-1;
01041 for(l=1; l<nTemplates; l++)
01042 {
01043 if(costMatrix_((mrs_natural)endPos_(l)-1,(mrs_natural)matrixPos_(1)) < tmpReal)
01044 {
01045 tmpReal = costMatrix_((mrs_natural)endPos_(l)-1,(mrs_natural)matrixPos_(1));
01046 j = (mrs_natural)endPos_(l)-1;
01047 }
01048 }
01049 totalDis_ = tmpReal;
01050 ctrl_totalDis_->setValue(totalDis_);
01051 i = (mrs_natural)nSmp-1;
01052 }
01053 else if(ctrl_lastPos_->to<mrs_string>() == "lowest")
01054 {
01055 tmpReal = costMatrix_(0,(mrs_natural)matrixPos_(1));
01056 j=0;
01057 for(i=1; i<nObs; ++i)
01058 {
01059 if(costMatrix_(i,(mrs_natural)matrixPos_(1)) < tmpReal)
01060 {
01061 tmpReal = costMatrix_(i,(mrs_natural)matrixPos_(1));
01062 j = i;
01063 }
01064 }
01065 i = (mrs_natural)nSmp-1;
01066 totalDis_ = tmpReal;
01067 ctrl_totalDis_->setValue(totalDis_);
01068 }
01069 k = (mrs_natural)(3*nSmp -1);
01070 while(alignment_(j,i) != 0 && k>=0)
01071 {
01072 if(alignment_(j,i) == 1)
01073 {
01074 out(k,0) = i;
01075 out(k,1) = j;
01076 j--;
01077 k--;
01078 out(k,0) = i;
01079 out(k,1) = j;
01080 k--;
01081 if(weight)
01082 {
01083 out(k,0) = i;
01084 out(k,1) = j;
01085 k--;
01086 }
01087 j--;
01088 i--;
01089 }
01090 else if(alignment_(j,i) == 2)
01091 {
01092 out(k,0) = i;
01093 out(k,1) = j;
01094 k--;
01095 if(weight)
01096 {
01097 out(k,0) = i;
01098 out(k,1) = j;
01099 k--;
01100 }
01101 i--;
01102 j--;
01103 }
01104 else if(alignment_(j,i) == 3)
01105 {
01106 out(k,0) = i;
01107 out(k,1) = j;
01108 k--;
01109 i--;
01110 out(k,0) = i;
01111 out(k,1) = j;
01112 k--;
01113 if(weight)
01114 {
01115 out(k,0) = i;
01116 out(k,1) = j;
01117 k--;
01118 }
01119 i--;
01120 j--;
01121 }
01122 else if(alignment_(j,i) < 0)
01123 {
01124 out(k,0) = i;
01125 out(k,1) = j;
01126 k--;
01127 if(weight)
01128 {
01129 out(k,0) = i;
01130 out(k,1) = j;
01131 k--;
01132 }
01133 j = (mrs_natural)(-1*alignment_(j,i));
01134 i--;
01135 }
01136 }
01137 out(k,0) = i;
01138 out(k,1) = j;
01139 }
01140 }
01141 else
01142 {
01143 MRSWARN("DTW::myProcess - invalid sizes vector (does not output a real value)!");
01144 }
01145 }
01146 }
01147 }
01148
01149
01150
01151
01152