binary_sleeve_subdivision< K > Struct Template Reference

#include <solver_uv_sleeve.hpp>

List of all members.

Public Types

Public Member Functions

Static Public Member Functions


Detailed Description

template<class K>
struct mmx::binary_sleeve_subdivision< K >

Solver class using sleeve approximation with coefficients of type C.

Definition at line 268 of file solver_uv_sleeve.hpp.


Member Typedef Documentation

Definition at line 277 of file solver_uv_sleeve.hpp.

typedef double creal_t

Definition at line 275 of file solver_uv_sleeve.hpp.

typedef res_t Domain_t

Definition at line 279 of file solver_uv_sleeve.hpp.

typedef K::integer integer

Definition at line 270 of file solver_uv_sleeve.hpp.

typedef K::rational rational

Definition at line 271 of file solver_uv_sleeve.hpp.

typedef unsigned sz_t

Definition at line 276 of file solver_uv_sleeve.hpp.

Definition at line 278 of file solver_uv_sleeve.hpp.


Member Function Documentation

static void alloc ( sz_t  s,
sz_t  deep 
) [inline, static]

Definition at line 284 of file solver_uv_sleeve.hpp.

Referenced by binary_sleeve_subdivision< K >::run(), and binary_sleeve_subdivision< K >::run_loop().

00285     {
00286       K::data.alloc(s,2*s,deep); 
00287     };

static void barre ( char  c,
unsigned  n 
) [inline, static]

Definition at line 289 of file solver_uv_sleeve.hpp.

References mmx::vct::fill().

00290     {
00291       char  _bar[ n+1 ];
00292       std::fill(_bar,_bar+n, c);
00293       _bar[n] = 0;
00294       std::cout << _bar << std::endl;
00295     };

static void dwsplit ( creal_t r,
creal_t l,
sz_t  s 
) [inline, static]

Definition at line 332 of file solver_uv_sleeve.hpp.

References mmx::numerics::rnd_dw(), and binary_subdivision< K >::split().

Referenced by binary_sleeve_subdivision< K >::Loop().

00333     {
00334       numerics::rounding<creal_t> rnd( numerics::rnd_dw() );
00335       Base_t::split(r,l,s);
00336     };

static bool glue ( sz_t  cup,
sz_t  cdw,
int  d 
) [inline, static]

Definition at line 304 of file solver_uv_sleeve.hpp.

Referenced by binary_sleeve_subdivision< K >::mstore().

00305     {
00306       if ( K::data.bckb() == K::data.m_dmn[d] )
00307         {
00308           K::data.bckb() = K::data.m_dmn[d];
00309           K::data.bckb().m += 1;
00310           if ( cup ) K::data.m_cup = cup;
00311           if ( cdw ) K::data.m_cdw = cdw;
00312           return true;
00313         };
00314       return false;
00315     };

void init_pol ( VECT &  ubp,
VECT &  dbp,
const POL &  r,
unsigned  sz,
const Q &  u,
const Q &  v 
) [inline, static]

Definition at line 501 of file solver_uv_sleeve.hpp.

References mmx::assign(), mmx::let::assign(), mmx::tensor::convertm2b(), mmx::div(), mmx::array::max_abs(), mmx::numerics::rnd_dw(), mmx::numerics::rnd_up(), mmx::sparse::swap(), and V.

Referenced by binary_sleeve_subdivision< K >::solve().

00502   {
00503     using let::assign;
00504   
00505 #if 1
00506     //    PRINT_DEBUG("Conversion using exact arithmetic");
00507     rational U,V;
00508     assign(U,u);
00509     assign(V,v);
00510     //    std::vector<interval> bp( sz );
00511     std::vector<rational> bp(sz);
00512     univariate::convertm2b(bp,r,sz,U,V);
00513     rational mx = array::max_abs(bp);
00514     array::div(bp,mx);
00515     // unsigned i;
00516     //    for (i = 0; i < sz && bp[i].upper()-bp[i].lower()<as<floating>(1.e-16); i ++ );
00517     //    if(i<sz) std::cout<<"refine: "<<i<<" " <<(bp[i].upper()-bp[i].lower())<<std::endl;
00518     //    double l; assign(l, rational(V-U));
00519     //    std::cout<<"\t init: "<<sign_variation(bp)<<" "<<l<<std::endl;
00520     {
00521       numerics::rounding<creal_t> rnd( numerics::rnd_up() );
00522       for ( unsigned i = 0; i < sz; i ++ ) ubp[i]=as<creal_t>(bp[i]);
00523     }
00524     {
00525       numerics::rounding<creal_t> rnd( numerics::rnd_dw() );
00526       for ( unsigned i = 0; i < sz; i ++ ) dbp[i]=as<creal_t>(bp[i]);
00527     };
00528    
00529 #else
00530     //    PRINT_DEBUG("Using rounding arithmetic");
00531     O ud, vd;
00532     {
00533       numerics::rounding<creal_t> rnd( numerics::rnd_dw() );
00534       ud=as<creal_t>(u);
00535     };
00536     {
00537       numerics::rounding<creal_t> rnd( numerics::rnd_up() );
00538       vd=as<creal_t>(v);
00539       BEZIER::monomial_to_bezier(ubp,r,r.size(),ud,vd);
00540     };
00541     {
00542       numerics::rounding<creal_t> rnd( numerics::rnd_dw() );
00543       BEZIER::monomial_to_bezier(dbp,r,r.size(),ud,vd);
00544     };
00545 
00546     for ( unsigned i= 0; i < ubp.size(); i ++ )
00547       if ( dbp[i] > ubp[i] ) { 
00548         std::swap(dbp[i], ubp[i]);
00549       };
00550 #endif
00551 
00552   }

static void Loop ( bool  isole = true  )  [inline, static]

Definition at line 345 of file solver_uv_sleeve.hpp.

References binary_sleeve_subdivision< K >::dwsplit(), binary_sleeve_subdivision< K >::mstore(), mmx::numerics::rnd_dw(), binary_subdivision< K >::sgncnt(), binary_subdivision< K >::split(), and binary_sleeve_subdivision< K >::upsplit().

Referenced by binary_sleeve_subdivision< K >::run(), and binary_sleeve_subdivision< K >::run_loop().

00345                                           {
00346       //      std::cout << "LOOP\n";
00347       numerics::rounding<creal_t> rnd(numerics::rnd_dw());
00348       creal_t * pup, * pdw;
00349       int d;
00350       sz_t a,s,cup,cdw;
00351       //      unsigned_t v;
00352       s = K::data.m_s;
00353       pup = K::data.m_data;
00354       pdw = K::data.m_data + s;
00355       K::data.m_dmn[0].m = 0;
00356       K::data.m_dmn[0].e = 0;
00357       for( a = 0, d = 0; d >= 0; d--, a -= 2*s   ) 
00358         {
00359           cup = Base_t::sgncnt(pup+a,s);
00360           cdw = Base_t::sgncnt(pdw+a,s);
00361           if ( cup || cdw )
00362             {
00363               if ( isole && cup == cdw && cup == 1 ){ 
00364                 //std::cout << " (b) \n";
00365                 K::data.sstore(d);
00366                 continue; 
00367               };
00368               if ( K::data.m_dmn[d].e == K::data.m_limit-1 ) { 
00369                 // std::cout << " (c) "<<cup<<" "<<cdw<<"\n";
00370                 if ( cup == cdw && cup == 1 )
00371                   K::data.sstore(d);
00372                 else
00373                   mstore(cup,cdw,d); 
00374                 continue; 
00375               };
00376               dwsplit(pdw+a,pdw+a+2*s,s);    
00377               upsplit(pup+a,pup+a+2*s,s);
00378               Base_t::split(K::data.m_dmn[d],K::data.m_dmn[d+1]);
00379               d += 2;
00380               a += 4*s;
00381               continue;
00382             } else {
00383             //std::cout<<"  (a) ";
00384             sz_t k =0, sv=0;
00385             for (  k = 0; k < K::data.m_s; k ++ ) {
00386               if ( ( pup[a+k] > 0 ) != ( pdw[a+k] > 0 ) ) {
00387                 sv++;
00388                 if(sv>1) { 
00389                   mstore(cup,cdw,d); 
00390                   break; 
00391                 };
00392               }
00393             }
00394             //std::cout<<std::endl;
00395           };
00396         };
00397       // std::cout << "END LOOP\n";
00398     };

static void mstore ( sz_t  cup,
sz_t  cdw,
int  d 
) [inline, static]

Definition at line 318 of file solver_uv_sleeve.hpp.

References binary_sleeve_subdivision< K >::glue().

Referenced by binary_sleeve_subdivision< K >::Loop().

00319     {
00320       if ( K::data.m_res.size() == 0 || !glue(cup,cdw,d)  )
00321         {
00322           K::data.mstore(d);
00323           K::data.m_cup = cup;
00324           K::data.m_cdw = cdw;
00325           //std::cout << "Push ";
00326         };
00327       //      writebck();
00328     };

Domain_t& operator[] ( int  i  )  [inline]

Definition at line 412 of file solver_uv_sleeve.hpp.

00412 { return K::data.m_res[i]; };

const Domain_t& operator[] ( int  i  )  const [inline]

Definition at line 411 of file solver_uv_sleeve.hpp.

00411 { return K::data.m_res[i]; };

static void run ( const input &  up,
const input &  dw 
) [inline, static]

Definition at line 441 of file solver_uv_sleeve.hpp.

References binary_sleeve_subdivision< K >::alloc(), assert, mmx::numerics::bitprec(), mmx::sparse::copy(), and binary_sleeve_subdivision< K >::Loop().

00441                                                 {
00442       assert(up.size()==dw.size());
00443       sz_t prec = numerics::bitprec(K::data.eps);
00444       alloc(up.size(),prec);
00445       std::copy(up.begin(),up.end(),K::data.m_data);
00446       std::copy(dw.begin(),dw.end(),K::data.m_data+K::data.m_s);
00447       Loop(K::data.isole);
00448     }

static void run ( const sleeve_rep< C > &  p  )  [inline, static]

Definition at line 432 of file solver_uv_sleeve.hpp.

References binary_sleeve_subdivision< K >::alloc(), mmx::numerics::bitprec(), mmx::sparse::copy(), sleeve_rep< C >::dw, binary_sleeve_subdivision< K >::Loop(), sleeve_rep< C >::size(), and sleeve_rep< C >::up.

00432                                  {
00433       sz_t prec = numerics::bitprec(K::data.eps);
00434       alloc(p.size(),prec);
00435       std::copy(p.up,p.up+p.size(),K::data.m_data);
00436       std::copy(p.dw,p.dw+p.size(),K::data.m_data+K::data.m_s);
00437       Loop(K::data.isole);
00438     }

static void run ( const input &  in,
const creal_t eps 
) [inline, static]

Definition at line 425 of file solver_uv_sleeve.hpp.

References binary_sleeve_subdivision< K >::run_loop().

Referenced by binary_sleeve_subdivision< K >::solve(), and binary_sleeve_subdivision< K >::solve_bernstein().

00426     { 
00427       typedef typename numerics::is_rounded<creal_t>::result_t round_t;
00428       run_loop(in,eps,round_t()); 
00429     }

static void run_loop ( const input &  in,
const creal_t eps,
const texp::true_t  
) [inline, static]

Definition at line 402 of file solver_uv_sleeve.hpp.

References binary_sleeve_subdivision< K >::alloc(), mmx::numerics::bitprec(), mmx::sparse::copy(), and binary_sleeve_subdivision< K >::Loop().

Referenced by binary_sleeve_subdivision< K >::run().

00402                                                                               {
00403       //      binary_subdivision<K> slv(eps);
00404       sz_t prec = numerics::bitprec(eps);
00405       alloc(in.size(),prec);
00406       std::copy(in.begin(),in.end(),K::data.m_data);
00407       std::copy(in.begin(),in.end(),K::data.m_data+K::data.m_s);
00408       Loop(K::data.isole);
00409     };

void solve ( output &  sol,
const POL &  r,
const Q &  u,
const Q &  v 
) [inline, static]

Compute the roots of the polynomial r expressed in the monomial basis, in the interval [u,v]. If MTH=Isolate, the ordered sequence of isolating intervals is stored in sol. If MTH=Approx, the ordered sequence of approximation of the roots is stored in sol.

Definition at line 556 of file solver_uv_sleeve.hpp.

References binary_sleeve_subdivision< K >::init_pol(), and binary_sleeve_subdivision< K >::run().

00557   {
00558     unsigned sz= r.size();
00559     std::vector<double> ubp(sz), dbp(sz);
00560     init_pol(ubp,dbp,r,sz,u,v);
00561     run(ubp,dbp,true);
00562     //    run(ubp,dbp,this->eps,mth.isolate);
00563     //    solutions<typename output::value_type>::get(this,sol,u,v);
00564   }

static void solve_bernstein ( output &  sol,
const POL &  r,
const real &  u,
const real &  v,
const MTH &  mth 
) [inline, static]

Compute the roots of the polynomial r expressed in the bernstein basis, on the interval [u,v]. If MTH=Isolate, the ordered sequence of isolating intervals is stored in sol. If MTH=Approx, the ordered sequence of approximation of the roots is stored in sol.

Definition at line 477 of file solver_uv_sleeve.hpp.

References mmx::let::assign(), mmx::numerics::rnd_dw(), mmx::numerics::rnd_up(), and binary_sleeve_subdivision< K >::run().

00478     {
00479       typedef typename output::value_type    root_t;    
00480       using let::assign;
00481       
00482       unsigned sz= r.size();
00483       std::vector<creal_t> ubp( sz ), dbp( sz );
00484       {
00485         numerics::rounding<creal_t> rnd( numerics::rnd_up() );
00486         for(unsigned i=0;i<sz;i++) ubp[i] =as<creal_t>(r[i]);
00487       }
00488       {
00489         numerics::rounding<creal_t> rnd( numerics::rnd_dw() );
00490         for(unsigned i=0;i<sz;i++) dbp[i] =as<creal_t>(r[i]);
00491       }
00492       K::data.isole=mth.isole; 
00493       run(ubp,dbp);
00494       get(sol,u,v);
00495       //      solutions<typename output::value_type>::get(this, sol, u,v);
00496     }

static void solve_bernstein ( output &  sol,
const input &  up,
const input &  dw,
const real &  u,
const real &  v,
const MTH &  mth 
) [inline, static]

Definition at line 460 of file solver_uv_sleeve.hpp.

References binary_sleeve_subdivision< K >::run().

00463     { 
00464       K::data.isole=mth.isole;
00465       run(up,dw);
00466       get(sol,u,v);
00467       //      solutions<typename output::value_type>::get(this,out,u,v);
00468     }

static void solve_bernstein ( output &  out,
const input &  in 
) [inline, static]

Definition at line 416 of file solver_uv_sleeve.hpp.

References binary_sleeve_subdivision< K >::run().

00416                                                         {
00417       run(in,K::data.eps);
00418       //      solutions<typename output::value_type>::get(this,out);
00419     }

static void upsplit ( creal_t r,
creal_t l,
sz_t  s 
) [inline, static]

Definition at line 339 of file solver_uv_sleeve.hpp.

References mmx::numerics::rnd_up(), and binary_subdivision< K >::split().

Referenced by binary_sleeve_subdivision< K >::Loop().

00340     {
00341       numerics::rounding<creal_t> rnd( numerics::rnd_up() );
00342       Base_t::split(r,l,s);
00343     };

static void writebounds ( creal_t pup,
creal_t pdw,
unsigned  s 
) [inline, static]

Definition at line 297 of file solver_uv_sleeve.hpp.

References binary_subdivision< K >::print().

00298     {
00299       Base_t::print(pup,s); std::cout << std::endl;
00300       Base_t::print(pdw,s); std::cout << std::endl;
00301     };


The documentation for this struct was generated from the following file:

Generated on 6 Dec 2012 for realroot by  doxygen 1.6.1