52 memset(coefficients,0,
sizeof(
double)*(Degree+1));
53 for(
int i=0;i<=Degree && i<=Degree2;i++){coefficients[i]=P.
coefficients[i];}
60 int d=Degree<Degree2?Degree:Degree2;
61 memset(coefficients,0,
sizeof(
double)*(Degree+1));
62 memcpy(coefficients,p.
coefficients,
sizeof(
double)*(d+1));
69 for(
int i=0;i<Degree;i++){p.
coefficients[i]=coefficients[i+1]*(i+1);}
77 for(
int i=0;i<=Degree;i++){p.
coefficients[i+1]=coefficients[i]/(i+1);}
85 double v=coefficients[Degree];
86 for(
int d=Degree-1 ; d>=0 ; d-- ) v = v*t + coefficients[d];
96 for(
int i=0;i<=Degree;i++){
97 v+=coefficients[i]*(t2-t1)/(i+1);
98 if(t1!=-DBL_MAX && t1!=DBL_MAX){t1*=tMin;}
99 if(t2!=-DBL_MAX && t2!=DBL_MAX){t2*=tMax;}
105 for(
int i=0;i<=Degree;i++){
if(coefficients[i]!=p.
coefficients[i]){
return 0;}}
110 for(
int i=0;i<=Degree;i++){
if(coefficients[i]==p.
coefficients[i]){
return 0;}}
115 for(
int i=0;i<=Degree;i++){
if(coefficients[i]!=0){
return 0;}}
123 for(
int i=0;i<=Degree;i++){coefficients[i]+=p.
coefficients[i]*s;}
128 for(
int i=0;i<=Degree;i++){coefficients[i]+=p.
coefficients[i];}
133 for(
int i=0;i<=Degree;i++){coefficients[i]-=p.
coefficients[i];}
182 template<
int Degree2>
204 for(
int i=0;i<=Degree;i++){coefficients[i]*=s;}
210 for(
int i=0;i<=Degree;i++){coefficients[i]/=s;}
231 for(
int i=0;i<=Degree;i++){q.
coefficients[i]=coefficients[i]*s;}
238 for(
int i=0 ; i<=Degree ; i++ ) q.
coefficients[i] = coefficients[i]/s;
246 for(
int i=0;i<=Degree;i++){
256 for(
int i=0;i<=Degree;i++){
258 for(
int j=i;j>=0;j--){
268 for(
int j=0;j<=Degree;j++){
269 printf(
"%6.4f x^%d ",coefficients[j],j);
270 if(j<Degree && coefficients[j+1]>=0){printf(
"+");}
282 rCount=
Factor(coefficients[1],coefficients[0]-c,r,EPS);
285 rCount=
Factor(coefficients[2],coefficients[1],coefficients[0]-c,r,EPS);
288 rCount=
Factor(coefficients[3],coefficients[2],coefficients[1],coefficients[0]-c,r,EPS);
294 printf(
"Can't solve polynomial of degree: %d\n",Degree);
296 for(
int i=0;i<rCount;i++){
297 if(fabs(r[i][1])<=EPS){
298 roots.push_back(r[i][0]);
309 template<
int Degree >
inline
Polynomial & operator+=(const Polynomial &p)
static void Negate(const Polynomial &in, Polynomial &out)
Polynomial scale(double s) const
Polynomial< Degree+1 > integral(void) const
Polynomial shift(double t) const
void getSolutions(double c, std::vector< double > &roots, double EPS) const
double operator()(double t) const
int operator!=(const Polynomial &p) const
static void AddScaled(const Polynomial &p1, double w1, const Polynomial &p2, double w2, Polynomial &q)
static void Scale(const Polynomial &p, double w, Polynomial &q)
Polynomial operator-(void) const
Polynomial< Degree-1 > derivative(void) const
Polynomial & operator/=(double s)
Polynomial & operator=(const Polynomial< Degree2 > &p)
Polynomial & operator*=(double s)
Polynomial & operator-=(const Polynomial &p)
Polynomial operator/(double s) const
double coefficients[Degree+1]
int operator==(const Polynomial &p) const
static void Subtract(const Polynomial &p1, const Polynomial &p2, Polynomial &q)
static Polynomial BSplineComponent(int i)
Polynomial & addScaled(const Polynomial &p, double scale)
double integral(double tMin, double tMax) const
Polynomial operator+(const Polynomial &p) const
Polynomial< Degree+Degree2 > operator*(const Polynomial< Degree2 > &p) const
PCL_EXPORTS int Factor(double a1, double a0, double roots[1][2], double EPS)