예제 #1
0
  void multiRootSolver<scalarT,dim>::backTrack(value_type farPoint, value_type farValue){
    real_type stepSize=(this->z-farPoint).norm();
#if DEBUG>=STATUS
    cout << __FILE__ << " : back tracking"<<endl;
#endif

    real_type farAbsF = farValue.norm();
    real_type change = this->absF - farAbsF;

    if(change!=change){//nan
      throw runtime_error(string(__FILE__) + string(" :  Error in function evaluation!"));
    }

#if DEBUG>=DETAIL
    cout << __FILE__ << " : step size " << stepSize << " leads to absF improvement: " <<change <<endl;
#endif

    this->state = this->checkStatus(farAbsF, this->absF, stepSize);

    // simple backtracking
    if(this->state==REJECT){
      value_type newFarPoint = 0.5 * (farPoint + this->z);
      this->calc->changePoint(newFarPoint);
      backTrack(newFarPoint, this->calc->calcF());
    }else{
      lastAbsValueChange=change;
      this->f=farValue;
      this->absF=farAbsF;
      absLastStep=stepSize;
      this->z=farPoint;
      calculatedJ=false;
    }
  }