VecInt dynpro(const VecInt &nstate, Doub cost(Int jj, Int kk, Int ii)) { const Doub BIG = 1.e99; static const Doub EPS=numeric_limits::epsilon(); Int i, j ,k, nstage = nstate.size() - 1; Doub a,b; VecInt answer(nstage+1); if (nstate[0] != 1 || nstate[nstage] != 1) throw("One state allowed in first and last stages."); Doub **best = new Doub*[nstage+1]; best[0] = new Doub[nstate[0]]; best[0][0] = 0.; for (i=1; i<=nstage; i++) { best[i] = new Doub[nstate[i]]; for (k=0; k0; i--) { k = answer[i+1]; b = best[i+1][k]; for (j=0; j=0; i--) delete [] best[i]; delete [] best; return answer; }