#include class CP { public: static const int levels=4; // the number of levels int maxIter; // maximal iteration int aL[levels]; // allowed per level int uL[levels]; // used per level int iL[levels]; // current iteration per level int changedLevel; // level changed due to increment or decrement int topLevel; // the top Level int cpLevel; // current checkpoint level int tapeLevel; // current taping level int adjointLevel; // current adjoint level CP() { maxIter=0; for (int i=0;i=levels) { std::cerr << "insufficient checkpoints" << std::endl; } for(int i=0;i=0;i--) { uL[i]=aL[i]; } // determine final uses: ufL[topLevel]=uL[topLevel]; steps=maxIter%steps; for(int i=topLevel-1;i>=0;i--) { // determine top level for the rest int rTopLevel=0; int rsteps=1; for(int j=0;j<=i;j++) { rsteps*=aL[j]; if (rsteps> cp.maxIter; cp.aL[0]=3; cp.aL[1]=4; cp.aL[2]=5; cp.aL[3]=6; cp.init(); for (int i=0;i