#include <solver_uv_bspline.hpp>
Definition at line 127 of file solver_uv_bspline.hpp.
typedef solver_bspline<typename Ring::Scalar> base_t |
Definition at line 129 of file solver_uv_bspline.hpp.
typedef double solution_t |
Definition at line 128 of file solver_uv_bspline.hpp.
solver< Ring, Bspline >::solution_t first_root | ( | const POL & | p | ) | [inline, static] |
Compute the first positive root of the polynomial p.
Definition at line 177 of file solver_uv_bspline.hpp.
References mmx::degree(), solver_bspline< Real >::first_root(), solver_bspline< Real >::m_c, solver_bspline< Real >::m_t, Real, mmx::numerics::rnd_dw(), mmx::numerics::rnd_up(), and Scalar.
00177 { 00178 00179 typedef typename Ring::Scalar Real; 00180 typedef typename POL::Ring ring_t; 00181 typedef typename solver<Ring, Bspline>::base_t base_t; 00182 typedef GMP::integer integer; 00183 typedef GMP::rational rational; 00184 00185 00186 int d= degree(p), sz=d+1; 00187 solver_bspline<Real> slv(sz,sz-1); 00188 00189 std::vector<rational> bp(sz); 00190 binomials<integer> bn; 00191 rational c; 00192 if(p[0]==0) 00193 return 0; 00194 else if(p[0]<0) { 00195 numerics::rounding<Real> rnd( numerics::rnd_up() ); 00196 for(int i=0;i<sz;i++) { 00197 c= as<rational>(p[i])/bn(d,i); 00198 slv.m_c[i]=as<Real>(c); 00199 } 00200 } else { 00201 numerics::rounding<Real> rnd( numerics::rnd_dw() ); 00202 for(int i=0;i<sz;i++) { 00203 c= as<rational>(p[i])/bn(d,i); 00204 slv.m_c[i]=as<Real>(c); 00205 } 00206 } 00207 for ( int i = 0; i < sz; i ++ ) { 00208 slv.m_t[i]=Real(0); 00209 } 00210 00211 Real x= slv.first_root(); 00212 00213 return x/(1-x); 00214 00215 }
solver< Ring, Bspline >::solution_t first_root | ( | const POL & | p, | |
const T & | u, | |||
const T & | v | |||
) | [inline, static] |
Compute the first positive root of the polynomial p in the interval [u,v].
Definition at line 145 of file solver_uv_bspline.hpp.
References mmx::assign(), mmx::tensor::convertm2b(), mmx::degree(), solver_bspline< Real >::first_root(), solver_bspline< Real >::m_c, solver_bspline< Real >::m_t, Real, and V.
00146 { 00147 00148 typedef typename Ring::scalar_t Real; 00149 typedef typename POL::Ring ring_t; 00150 typedef typename solver<Ring, Bspline>::base_t base_t; 00151 typedef GMP::rational rational; 00152 00153 rational U,V; 00154 let::assign(U,u); 00155 let::assign(V,v); 00156 int sz= degree(p)+1; 00157 00158 std::vector<rational> bp(sz); 00159 univariate::convertm2b(bp,p,sz,U,V); 00160 00161 solver_bspline<Real> slv(sz,sz-1); 00162 00163 for ( int i = 0; i < sz; i ++ ) { 00164 slv.m_c[i]=as<Real>(bp[i]); 00165 slv.m_t[i]=Real(0); 00166 } 00167 00168 return u +(v-u)*slv.first_root(); 00169 00170 }