Developer documentation

bernstein_univariate.hpp
Go to the documentation of this file.
1 
2 /********************************************************************
3  * This file is part of the source code of the realroot library.
4  * Author(s): Bernard Mourrain, GALAAD, INRIA
5  ********************************************************************/
6 #ifndef realroot_bernstein_univariate_hpp
7 #define realroot_bernstein_univariate_hpp
8 
9 namespace mmx { namespace bernstein {
10 
11 
12  template<class VECTOR1, class VECTOR2>
13  void diff(VECTOR1& res, const VECTOR2& pol) {
14  res.resize(pol.size()-1);
15  for(int i=0; i< pol.size()-1;i++)
16  res[i] = pol[i+1]-pol[i];
17  }
18 
19  template<class VECTOR, class C>
20  C eval(const VECTOR& pol, const C& U, const C& V, const C& x) {
21 
22  unsigned sz= pol.size();
23  if(sz==0) return (C)0;
24 
25  C t = (x-U)/(V-U);
26  C p[sz];
27  for ( unsigned i=0; i < sz; i++ ) p[i]=pol[i];
28 
29  for ( unsigned r = (sz-1); r != 0; r--)
30  for ( unsigned i=0; i < r; i++ )
31  p[i] = (1.0-t)*p[i]+t*(p[i+1]);
32  return p[0];
33  }
34 
35 } /* namespace mmx */ } /* namespace bernstein */
36 #endif //realroot_bernstein_univariate_hpp
C eval(const VECTOR &pol, const C &U, const C &V, const C &x)
Definition: bernstein_univariate.hpp:20
void diff(VECTOR1 &res, const VECTOR2 &pol)
Definition: bernstein_univariate.hpp:13
double C
Definition: solver_mv_fatarcs.cpp:16
Definition: array.hpp:12
Home