|
realroot_doc 0.1.1
|
#include <solver_uv_sleeve.hpp>
Solver class using sleeve approximation with coefficients of type C.
Definition at line 267 of file solver_uv_sleeve.hpp.
| typedef binary_subdivision<K> Base_t |
Definition at line 276 of file solver_uv_sleeve.hpp.
| typedef double creal_t |
Definition at line 274 of file solver_uv_sleeve.hpp.
Definition at line 278 of file solver_uv_sleeve.hpp.
| typedef K::integer integer |
Definition at line 269 of file solver_uv_sleeve.hpp.
| typedef K::rational rational |
Definition at line 270 of file solver_uv_sleeve.hpp.
| typedef unsigned sz_t |
Definition at line 275 of file solver_uv_sleeve.hpp.
| typedef Base_t::unsigned_t unsigned_t |
Definition at line 277 of file solver_uv_sleeve.hpp.
Definition at line 283 of file solver_uv_sleeve.hpp.
Referenced by binary_sleeve_subdivision< K >::run(), and binary_sleeve_subdivision< K >::run_loop().
{
K::data.alloc(s,2*s,deep);
};
| static void barre | ( | char | c, |
| unsigned | n | ||
| ) | [inline, static] |
Definition at line 288 of file solver_uv_sleeve.hpp.
References mmx::vct::fill().
{
char _bar[ n+1 ];
std::fill(_bar,_bar+n, c);
_bar[n] = 0;
std::cout << _bar << std::endl;
};
Definition at line 331 of file solver_uv_sleeve.hpp.
References mmx::numerics::rnd_dw(), and binary_subdivision< K >::split().
Referenced by binary_sleeve_subdivision< K >::Loop().
{
numerics::rounding<creal_t> rnd( numerics::rnd_dw() );
Base_t::split(r,l,s);
};
Definition at line 303 of file solver_uv_sleeve.hpp.
Referenced by binary_sleeve_subdivision< K >::mstore().
{
if ( K::data.bckb() == K::data.m_dmn[d] )
{
K::data.bckb() = K::data.m_dmn[d];
K::data.bckb().m += 1;
if ( cup ) K::data.m_cup = cup;
if ( cdw ) K::data.m_cdw = cdw;
return true;
};
return false;
};
| void init_pol | ( | VECT & | ubp, |
| VECT & | dbp, | ||
| const POL & | r, | ||
| unsigned | sz, | ||
| const Q & | u, | ||
| const Q & | v | ||
| ) | [inline, static] |
Definition at line 500 of file solver_uv_sleeve.hpp.
References mmx::assign(), mmx::let::assign(), mmx::univariate::convertm2b(), mmx::array::div(), mmx::array::max_abs(), mmx::numerics::rnd_dw(), mmx::numerics::rnd_up(), and mmx::sparse::swap().
{
using let::assign;
#if 1
// PRINT_DEBUG("Conversion using exact arithmetic");
rational U,V;
assign(U,u);
assign(V,v);
// std::vector<interval> bp( sz );
std::vector<rational> bp(sz);
univariate::convertm2b(bp,r,sz,U,V);
rational mx = array::max_abs(bp);
array::div(bp,mx);
// unsigned i;
// for (i = 0; i < sz && bp[i].upper()-bp[i].lower()<as<floating>(1.e-16); i ++ );
// if(i<sz) std::cout<<"refine: "<<i<<" " <<(bp[i].upper()-bp[i].lower())<<std::endl;
// double l; assign(l, rational(V-U));
// std::cout<<"\t init: "<<sign_variation(bp)<<" "<<l<<std::endl;
{
numerics::rounding<creal_t> rnd( numerics::rnd_up() );
for ( unsigned i = 0; i < sz; i ++ ) ubp[i]=as<creal_t>(bp[i]);
}
{
numerics::rounding<creal_t> rnd( numerics::rnd_dw() );
for ( unsigned i = 0; i < sz; i ++ ) dbp[i]=as<creal_t>(bp[i]);
};
#else
// PRINT_DEBUG("Using rounding arithmetic");
O ud, vd;
{
numerics::rounding<creal_t> rnd( numerics::rnd_dw() );
ud=as<creal_t>(u);
};
{
numerics::rounding<creal_t> rnd( numerics::rnd_up() );
vd=as<creal_t>(v);
BEZIER::monomial_to_bezier(ubp,r,r.size(),ud,vd);
};
{
numerics::rounding<creal_t> rnd( numerics::rnd_dw() );
BEZIER::monomial_to_bezier(dbp,r,r.size(),ud,vd);
};
for ( unsigned i= 0; i < ubp.size(); i ++ )
if ( dbp[i] > ubp[i] ) {
std::swap(dbp[i], ubp[i]);
};
#endif
}
| static void Loop | ( | bool | isole = true | ) | [inline, static] |
Definition at line 344 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().
{
// std::cout << "LOOP\n";
numerics::rounding<creal_t> rnd(numerics::rnd_dw());
creal_t * pup, * pdw;
int d;
sz_t a,s,cup,cdw;
// unsigned_t v;
s = K::data.m_s;
pup = K::data.m_data;
pdw = K::data.m_data + s;
K::data.m_dmn[0].m = 0;
K::data.m_dmn[0].e = 0;
for( a = 0, d = 0; d >= 0; d--, a -= 2*s )
{
cup = Base_t::sgncnt(pup+a,s);
cdw = Base_t::sgncnt(pdw+a,s);
if ( cup || cdw )
{
if ( isole && cup == cdw && cup == 1 ){
//std::cout << " (b) \n";
K::data.sstore(d);
continue;
};
if ( K::data.m_dmn[d].e == K::data.m_limit-1 ) {
// std::cout << " (c) "<<cup<<" "<<cdw<<"\n";
if ( cup == cdw && cup == 1 )
K::data.sstore(d);
else
mstore(cup,cdw,d);
continue;
};
dwsplit(pdw+a,pdw+a+2*s,s);
upsplit(pup+a,pup+a+2*s,s);
Base_t::split(K::data.m_dmn[d],K::data.m_dmn[d+1]);
d += 2;
a += 4*s;
continue;
} else {
//std::cout<<" (a) ";
sz_t k =0, sv=0;
for ( k = 0; k < K::data.m_s; k ++ ) {
if ( ( pup[a+k] > 0 ) != ( pdw[a+k] > 0 ) ) {
sv++;
if(sv>1) {
mstore(cup,cdw,d);
break;
};
}
}
//std::cout<<std::endl;
};
};
// std::cout << "END LOOP\n";
};
Definition at line 317 of file solver_uv_sleeve.hpp.
References binary_sleeve_subdivision< K >::glue().
Referenced by binary_sleeve_subdivision< K >::Loop().
{
if ( K::data.m_res.size() == 0 || !glue(cup,cdw,d) )
{
K::data.mstore(d);
K::data.m_cup = cup;
K::data.m_cdw = cdw;
//std::cout << "Push ";
};
// writebck();
};
| const Domain_t& operator[] | ( | int | i | ) | const [inline] |
Definition at line 410 of file solver_uv_sleeve.hpp.
{ return K::data.m_res[i]; };
| Domain_t& operator[] | ( | int | i | ) | [inline] |
Definition at line 411 of file solver_uv_sleeve.hpp.
{ return K::data.m_res[i]; };
| static void run | ( | const input & | up, |
| const input & | dw | ||
| ) | [inline, static] |
Definition at line 440 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 input & | in, |
| const creal_t & | eps | ||
| ) | [inline, static] |
Definition at line 424 of file solver_uv_sleeve.hpp.
References binary_sleeve_subdivision< K >::run_loop().
Referenced by binary_sleeve_subdivision< K >::solve_bernstein().
| static void run | ( | const sleeve_rep< C > & | p | ) | [inline, static] |
Definition at line 431 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_loop | ( | const input & | in, |
| const creal_t & | eps, | ||
| const texp::true_t & | |||
| ) | [inline, static] |
Definition at line 401 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 | ||
| ) | [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 555 of file solver_uv_sleeve.hpp.
| 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 476 of file solver_uv_sleeve.hpp.
References mmx::assign(), mmx::numerics::rnd_dw(), mmx::numerics::rnd_up(), and binary_sleeve_subdivision< K >::run().
{
typedef typename output::value_type root_t;
using let::assign;
unsigned sz= r.size();
std::vector<creal_t> ubp( sz ), dbp( sz );
{
numerics::rounding<creal_t> rnd( numerics::rnd_up() );
for(unsigned i=0;i<sz;i++) ubp[i] =as<creal_t>(r[i]);
}
{
numerics::rounding<creal_t> rnd( numerics::rnd_dw() );
for(unsigned i=0;i<sz;i++) dbp[i] =as<creal_t>(r[i]);
}
K::data.isole=mth.isole;
run(ubp,dbp);
get(sol,u,v);
// solutions<typename output::value_type>::get(this, sol, u,v);
}
| static void solve_bernstein | ( | output & | out, |
| const input & | in | ||
| ) | [inline, static] |
Definition at line 415 of file solver_uv_sleeve.hpp.
References binary_sleeve_subdivision< K >::run().
| 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 459 of file solver_uv_sleeve.hpp.
References binary_sleeve_subdivision< K >::run().
{
K::data.isole=mth.isole;
run(up,dw);
get(sol,u,v);
// solutions<typename output::value_type>::get(this,out,u,v);
}
Definition at line 338 of file solver_uv_sleeve.hpp.
References mmx::numerics::rnd_up(), and binary_subdivision< K >::split().
Referenced by binary_sleeve_subdivision< K >::Loop().
{
numerics::rounding<creal_t> rnd( numerics::rnd_up() );
Base_t::split(r,l,s);
};
Definition at line 296 of file solver_uv_sleeve.hpp.
References binary_subdivision< K >::print().
{
Base_t::print(pup,s); std::cout << std::endl;
Base_t::print(pdw,s); std::cout << std::endl;
};