Changeset 45b1fd8 in tol


Ignore:
Timestamp:
Sep 19, 2012, 8:47:26 AM (14 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
04e6eaf
Parents:
76571c9
Message:

Refs #1136
Now, RandStationary can draw inverse of roots in an specified interval inside (0,1)

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

Location:
tol/btol/polynomial_type
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/polynomial_type/polgra.cpp

    r76571c9 r45b1fd8  
    502502  BInt degree,
    503503  BInt period,
     504  BDat minInvRootModule,
    504505  BDat maxInvRootModule)
    505506//--------------------------------------------------------------------
    … …  
    515516  BPol factor;
    516517  if(maxInvRootModule>1-2*DEpsilon()) { maxInvRootModule = 1-2*DEpsilon(); }
    517   else if(maxInvRootModule<0) { maxInvRootModule = 0; }
     518  if(maxInvRootModule<  2*DEpsilon()) { maxInvRootModule =   2*DEpsilon(); }
     519  if(minInvRootModule<  2*DEpsilon()) { minInvRootModule =   2*DEpsilon(); }
     520  if(minInvRootModule>maxInvRootModule)
     521  {
     522    Error("[RandStationary] Cannot draw in empty interval ["+minInvRootModule+","+maxInvRootModule+"]");
     523    return(factor);
     524  }
    518525  if(n1)
    519526  {
    520     a = maxInvRootModule*u.Random();
     527    BDat ur = u.Random();
     528    a = maxInvRootModule*ur + minInvRootModule*(1-ur);
    521529    factor = B0-a*BP;
    522530  //Std(BText("\nRandStationary(")+degree+","+period+","+maxInvRootModule+") monome a="+a+"; factor="+factor.Name());
    … …  
    544552      ok = (a<1-b) &&
    545553           (a<1+b) &&
    546            (m1<maxInvRootModule) &&
    547            (m2<maxInvRootModule);
     554           (m1>=minInvRootModule) &&
     555           (m2>=minInvRootModule) &&
     556           (m1<=maxInvRootModule) &&
     557           (m2<=maxInvRootModule);
    548558      if(ok)
    549559      {
    … …  
    559569//--------------------------------------------------------------------
    560570DeclareContensClass(BPol, BPolTemporary, BPolRandStationary);
    561 DefExtOpr(1, BPolRandStationary, "RandStationary", 1, 3,
    562   "Real Real Real",
    563   "(Real d [, Real p = 1, Real maxInvRootModule = 0.999999])",
     571DefExtOpr(1, BPolRandStationary, "RandStationary", 1, 4,
     572  "Real Real Real Real",
     573  "(Real d [, Real p = 1, "
     574    "Real minInvRootModule = 0.000001, "
     575    "Real maxInvRootModule = 0.999999])",
    564576  I2("Returns a random stationary polinomial as \n",
    565577     "Devuelve un polinomio estacionario aleatorio de la forma \n") +
    … …  
    572584  BInt degree = (BInt)Real(Arg(1));
    573585  BInt period = 1;
     586  BDat minInvRootModule = .000001;
    574587  BDat maxInvRootModule = .999999;
    575588  if(Arg(2)) { period = (BInt)Real(Arg(2)); }
    576   if(Arg(3)) { maxInvRootModule = Dat(Arg(3)); }
    577   contens_ = RandStationary(degree, period, maxInvRootModule);
     589  if(Arg(3)) { minInvRootModule = Dat(Arg(3)); }
     590  if(Arg(4)) { maxInvRootModule = Dat(Arg(4)); }
     591  contens_ = RandStationary(degree, period, minInvRootModule, maxInvRootModule);
    578592}
    579593
  • tol/btol/polynomial_type/tol_bpolgra.h

    r76571c9 r45b1fd8  
    4444  BInt degree,
    4545  BInt period,
     46  BDat minInvRootModule=.000001,
    4647  BDat maxInvRootModule=.999999);
    4748
Note: See TracChangeset for help on using the changeset viewer.