6 #ifndef realroot_solver_bspline_hpp
7 #define realroot_solver_bspline_hpp
14 #define TMPL template<class Real>
24 for (
int i=2; i<=d; ++i) ret+=t[k+i];
36 solver_bspline(
unsigned n,
unsigned d,
unsigned N=100): m_n(n), maxn(
N+n), m_d(d), eps(1e-7) {
38 for(
unsigned i=0; i< 2*n+
N; i++) m_t[i]=Real(1);
40 for(
unsigned i=0; i< n+
N; i++) m_c[i]=Real(0);
56 while ( x>=m_t[mu+1]) mu++;
58 for (
int i=m_n; i>mu; i--) {
62 for (
int i=mu; i>=mu-m_d+1; i--) {
63 const Real alpha = (x-m_t[i])/(m_t[i+m_d]-m_t[i]);
64 m_c[i] = (1.0-alpha) * m_c[i-1] + alpha * m_c[i];
69 for (
int i=m_n; i>mu+1; --i)
85 for ( ; m_n < maxn; ++m_n ) {
87 while( k<m_n && (m_c[k-1]*m_c[k] > 0.0) )
100 const Real
diff = m_t[k+m_d]-m_t[k];
107 const Real av =
knotSum(m_t,k-1, m_d);
108 const Real lambda = m_c[k-1]/(m_c[k-1]-m_c[k]);
109 x = (av + lambda*
diff)/Real(m_d);
131 template<
class POL,
class T>
static solution_t
132 first_root(
const POL& p,
const T& u,
const T& v);
134 template<
class POL>
static solution_t
135 first_root(
const POL& p);
143 template<
class POL,
class T>
146 const T& u,
const T& v) {
148 typedef typename Ring::scalar_t Real;
158 std::vector<rational> bp(sz);
163 for (
int i = 0; i < sz; i ++ ) {
164 slv.
m_c[i]=as<Real>(bp[i]);
189 std::vector<rational> bp(sz);
196 for(
int i=0;i<sz;i++) {
197 c= as<rational>(p[i])/bn(d,i);
198 slv.
m_c[i]=as<Real>(
c);
202 for(
int i=0;i<sz;i++) {
203 c= as<rational>(p[i])/bn(d,i);
204 slv.
m_c[i]=as<Real>(
c);
207 for (
int i = 0; i < sz; i ++ ) {
220 #endif //realroot_solver_bspline_hpp
Real * m_t
Definition: solver_uv_bspline.hpp:31
TMPL Polynomial diff(const Polynomial &pol, int v)
Multivariate Polynomial Differentiation.
Definition: polynomial_fcts.hpp:99
dynamic_exp< E >::degree_t degree(const dynamic_exp< E > &t)
Definition: dynamicexp.hpp:191
unsigned maxn
Definition: solver_uv_bspline.hpp:32
solver_bspline(unsigned n, unsigned d, unsigned N=100)
Definition: solver_uv_bspline.hpp:36
Real eps
Definition: solver_uv_bspline.hpp:34
Definition: solver_uv_bspline.hpp:30
TMPL int N(const MONOMIAL &v)
Definition: monomial_glue.hpp:60
unsigned m_k
Definition: solver_uv_bspline.hpp:32
unsigned m_n
Definition: solver_uv_bspline.hpp:32
TMPL Real knotSum(Real *t, int k, int d)
Definition: solver_uv_bspline.hpp:21
Definition: rounding_mode.hpp:71
double solution_t
Definition: solver_uv_bspline.hpp:128
Real first_root()
Definition: solver_uv_bspline.hpp:79
Real * m_c
Definition: solver_uv_bspline.hpp:31
int m_d
Definition: solver_uv_bspline.hpp:33
#define min(a, b)
Definition: parser_def.c:475
Definition: solver.hpp:68
#define NO_ROOT
Definition: solver_uv_bspline.hpp:13
TMPL POL
Definition: polynomial_dual.hpp:74
Definition: binomials.hpp:68
#define Scalar
Definition: polynomial_operators.hpp:12
const C & c
Definition: Interval_glue.hpp:45
Definition: solver_uv_bspline.hpp:17
#define TMPL
Definition: solver_uv_bspline.hpp:14
void convertm2b(T &bz, const P &p, unsigned size, const C &a, const C &b)
Definition: univariate.hpp:847
solver_bspline< typename Ring::Scalar > base_t
Definition: solver_uv_bspline.hpp:129
void assign(A &a, const B &b)
Generic definition of the assignement function.
Definition: assign.hpp:97
int insert_knot(const Real &x, int mu)
Definition: solver_uv_bspline.hpp:53
Interval< T, r > max(const Interval< T, r > &a, const Interval< T, r > &b)
Definition: Interval_fcts.hpp:135
Definition: scalar.hpp:24