Changeset d60d28c in tol


Ignore:
Timestamp:
May 22, 2013, 7:59:35 AM (13 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
c52d330
Parents:
f18e2c2
Message:

Allowing fixed values and avoiding some numerical problems in BRnRFunction::AutoScale

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@5835 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/bmath/bfunct/nrealfun.cpp

    rf18e2c2 rd60d28c  
    196196  for(k=0; k<n_; k++)
    197197  {
     198    if(xMin[k].IsFinite() && xMin[k]==xMax[k]) { continue; }
    198199    if(verbose)
    199200    {
    … …  
    212213    {
    213214      S[k] = Abs(Fk.NewtonSolve(x[k], 0));
    214     }
    215   }
     215      if(!(S[k].IsFinite()))
     216      {
     217        BPartialFunction fk(*this, x, k);
     218        BDat x0 = x[k];
     219        BDat f0 = fk[x0];
     220        BDat ha = tolerance;
     221        BDat hb = tolerance;
     222        BDat a,b,fa,fb,adf=0;
     223        int iter = 0;
     224        do
     225        {
     226          iter++;
     227          a = x0-ha;
     228          b = x0+hb;
     229          fa = fk[a];
     230          fb = fk[b];
     231          if(!(fa.IsFinite())) { a = x0; fa=f0; ha=0; }
     232          if(!(fb.IsFinite())) { b = x0; fb=f0; hb=0; }
     233          adf = Abs(fb-fa);
     234          if(adf<fDist)
     235          {
     236            ha *= 2.0;
     237            hb *= 2.0;
     238          }
     239          else
     240          {
     241            ha *= 0.75;
     242            hb *= 0.75;
     243          }
     244        }
     245        while((Abs(adf-fDist)>tolerance) && (ha>0 || hb>0) && (iter<=100));
     246        if(iter<=100) { S[k] = ha+hb; }
     247        else { S[k] = 1; }
     248      }
     249    }
     250  }
     251  if(!(S[k].IsFinite())) { S[k]=1; }
    216252  return(true);
    217253/*
Note: See TracChangeset for help on using the changeset viewer.