#include <solver_uv_sleeve.hpp>
Solver class using sleeve approximation with coefficients of type C
.
Definition at line 268 of file solver_uv_sleeve.hpp.
typedef binary_subdivision<K> Base_t |
Definition at line 277 of file solver_uv_sleeve.hpp.
typedef double creal_t |
Definition at line 275 of file solver_uv_sleeve.hpp.
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.
typedef Base_t::unsigned_t unsigned_t |
Definition at line 278 of file solver_uv_sleeve.hpp.
Definition at line 284 of file solver_uv_sleeve.hpp.
Referenced by binary_sleeve_subdivision< K >::run(), and binary_sleeve_subdivision< K >::run_loop().
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 };
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 };
Definition at line 304 of file solver_uv_sleeve.hpp.
Referenced by binary_sleeve_subdivision< K >::mstore().
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 };
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.
const Domain_t& operator[] | ( | int | i | ) | const [inline] |
Definition at line 411 of file solver_uv_sleeve.hpp.
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().
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.
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().
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().
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().
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().
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 };
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 };