10 #ifndef _realroot_solve_inewton_hpp_
11 #define _realroot_solve_inewton_hpp_
68 typedef typename INT::boundary_type
BT;
85 if (mval == 0)
return INT(x);
90 status_ = -3;
return approx;
94 status_ = -1;
return approx;
114 INT
approx, BT delta_,
int& status_)
116 INT slope, testapprox, newapprox, ver;
117 BT oldw =
width(approx);
130 std::cerr <<
"approx = " << approx <<
" lval = " << lval <<
" rval = " << rval << std::endl;
132 if (lval == 0) { status_ = 0;
return INT(
mmx::lower(approx)); }
133 if (rval == 0) { status_ = 0;
return INT(
mmx::upper(approx)); }
135 status_ = -3;
return approx;
142 std::cerr <<
"slope = " << slope <<
width(slope) << std::endl;
147 if (z == 0) status_ = -1;
else status_ = -2;
152 std::cerr <<
"solving " << p << std::endl;
163 neww =
width(approx);
166 std::cerr <<
'(' << i <<
") bisect: " << approx <<
' ' << neww << std::endl;
168 if (status_ < 0)
return approx;
169 if (neww < delta_)
break;
171 if (neww == oldw)
break;
180 std::cerr <<
"mid = " << x <<
" mid_INT = " << INT(x) << std::endl;
181 std::cerr <<
"p(x) = " << p(INT(x)) << std::endl;
182 std::cerr <<
"p'(approx) = " << dp(approx) << std::endl;
183 std::cerr <<
"p/p' = " << INT(p(INT(x))/dp(approx)) << std::endl;
185 testapprox = INT(x) - INT(p(INT(x))/dp(approx));
192 std::cerr <<
"new =" << newapprox <<
" test = " << testapprox <<
" old = " << approx << std::endl;
194 neww =
width(newapprox);
199 INT ver = p(newapprox);
204 std::cerr <<
'(' << i <<
") Newton: " << newapprox <<
' ' << neww << std::endl;
207 if (neww >= oldw)
break;
209 if (neww < delta_)
break;
219 std::cerr <<
"slope = " << slope <<
width(slope) << std::endl;
223 if (
mmx::sign(dp(approx)) != 0) status_ = 1;
225 std::cerr <<
"iters = " << i << std::endl;
235 typedef typename INT::boundary_type
BT;
242 IntervalNewton(INT approx_, BT delta_ = 0): initial_approx(approx_), delta(delta_), status(0) { };
246 template<
class C,
class M>
struct solver_of;
248 template<
class C,
class IT>
255 template<
class POL,
class IT>
259 typedef typename POL::coeff_t coeff_t;
271 #endif // _realroot_solve_inewton_hpp_
Sequence of terms with reference counter.
Definition: Seq.hpp:28
TMPL Polynomial diff(const Polynomial &pol, int v)
Multivariate Polynomial Differentiation.
Definition: polynomial_fcts.hpp:99
std::vector< C > approx(polynomial< C, with< Bernstein > > poly, std::vector< C > ep1, std::vector< C > ep2, int MTH)
Definition: fatarcs_fcts.hpp:276
static INT bisection_iteration(const polynomial &p, const INT approx, int &status_)
Definition: solver_uv_interval_newton.hpp:74
ring< CT, MonomialTensor >::Polynomial polynomial
Definition: solver_uv_interval_newton.hpp:67
T upper(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:89
INT::boundary_type BT
Definition: solver_uv_interval_newton.hpp:235
IT Cell
Definition: solver_uv_interval_newton.hpp:250
static BT median(const INT &x)
Definition: solver_uv_interval_newton.hpp:71
Definition: solver_uv_interval_newton.hpp:65
bool intersect(Interval< T, r > &result, const Interval< T, r > &a, const Interval< T, r > &b)
Definition: Interval_fcts.hpp:150
Seq< typename ContFrac< NT, LB >::root_t > solve(const typename ContFrac< NT >::Poly &f, ContFrac< NT, LB >)
Definition: contfrac.hpp:164
static INT newton_iteration(const polynomial &p, const polynomial &dp, INT approx, BT delta_, int &status_)
Definition: solver_uv_interval_newton.hpp:113
static bool singleton(const INT &x)
Definition: solver_uv_interval_newton.hpp:72
INT initial_approx
Definition: solver_uv_interval_newton.hpp:238
IntervalNewton(INT approx_, BT delta_=0)
Definition: solver_uv_interval_newton.hpp:242
interval_newton< INT, C > solver_t
Definition: solver_uv_interval_newton.hpp:234
INT::boundary_type BT
Definition: solver_uv_interval_newton.hpp:68
BT delta
Definition: solver_uv_interval_newton.hpp:239
Seq< IT > Solutions
Definition: solver_uv_interval_newton.hpp:252
Definition: polynomial.hpp:37
T lower(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:87
TMPL POL
Definition: polynomial_dual.hpp:74
IntervalNewton< IT, C > Strategy
Definition: solver_uv_interval_newton.hpp:251
Seq< INT > solutions_t
Definition: solver_uv_interval_newton.hpp:236
Definition: solver.hpp:61
int status
Definition: solver_uv_interval_newton.hpp:240
double C
Definition: solver_mv_fatarcs.cpp:16
int sign(const QQ &a)
Definition: GMP.hpp:60
Definition: solver_uv_interval_newton.hpp:232
static BT width(const INT &x)
Definition: solver_uv_interval_newton.hpp:70
#define assert(expr, msg)
Definition: shared_object.hpp:57