Point Cloud Library (PCL)  1.9.1-dev
polynomial.h
1 /*
2 Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7 
8 Redistributions of source code must retain the above copyright notice, this list of
9 conditions and the following disclaimer. Redistributions in binary form must reproduce
10 the above copyright notice, this list of conditions and the following disclaimer
11 in the documentation and/or other materials provided with the distribution.
12 
13 Neither the name of the Johns Hopkins University nor the names of its contributors
14 may be used to endorse or promote products derived from this software without specific
15 prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
19 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
20 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 DAMAGE.
27 */
28 
29 #ifndef POLYNOMIAL_INCLUDED
30 #define POLYNOMIAL_INCLUDED
31 
32 #include <vector>
33 
34 namespace pcl
35 {
36  namespace poisson
37  {
38 
39  template< int Degree >
40  class Polynomial{
41  public:
42  double coefficients[Degree+1];
43 
44  Polynomial(void);
45  template<int Degree2>
47  double operator()( double t ) const;
48  double integral( double tMin , double tMax ) const;
49 
50  int operator == (const Polynomial& p) const;
51  int operator != (const Polynomial& p) const;
52  int isZero(void) const;
53  void setZero(void);
54 
55  template<int Degree2>
59  Polynomial operator - (void) const;
60  Polynomial operator + (const Polynomial& p) const;
61  Polynomial operator - (const Polynomial& p) const;
62  template<int Degree2>
64 
65  Polynomial& operator += ( double s );
66  Polynomial& operator -= ( double s );
67  Polynomial& operator *= ( double s );
68  Polynomial& operator /= ( double s );
69  Polynomial operator + ( double s ) const;
70  Polynomial operator - ( double s ) const;
71  Polynomial operator * ( double s ) const;
72  Polynomial operator / ( double s ) const;
73 
74  Polynomial scale( double s ) const;
75  Polynomial shift( double t ) const;
76 
77  Polynomial<Degree-1> derivative(void) const;
78  Polynomial<Degree+1> integral(void) const;
79 
80  void printnl(void) const;
81 
82  Polynomial& addScaled(const Polynomial& p,double scale);
83 
84  static void Negate(const Polynomial& in,Polynomial& out);
85  static void Subtract(const Polynomial& p1,const Polynomial& p2,Polynomial& q);
86  static void Scale(const Polynomial& p,double w,Polynomial& q);
87  static void AddScaled(const Polynomial& p1,double w1,const Polynomial& p2,double w2,Polynomial& q);
88  static void AddScaled(const Polynomial& p1,const Polynomial& p2,double w2,Polynomial& q);
89  static void AddScaled(const Polynomial& p1,double w1,const Polynomial& p2,Polynomial& q);
90 
91  void getSolutions(double c,std::vector<double>& roots,double EPS) const;
92 
93  static Polynomial BSplineComponent( int i );
94  };
95 
96 
97  }
98 }
99 
100 
101 #include "polynomial.hpp"
102 #endif // POLYNOMIAL_INCLUDED
Polynomial< Degree+Degree2 > operator*(const Polynomial< Degree2 > &p) const
Definition: polynomial.hpp:180
Polynomial & operator/=(double s)
Definition: polynomial.hpp:205
double coefficients[Degree+1]
Definition: polynomial.h:42
double operator()(double t) const
Definition: polynomial.hpp:81
Polynomial & operator*=(double s)
Definition: polynomial.hpp:199
Polynomial operator/(double s) const
Definition: polynomial.hpp:232
void printnl(void) const
Definition: polynomial.hpp:264
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
void getSolutions(double c, std::vector< double > &roots, double EPS) const
Definition: polynomial.hpp:272
Polynomial operator+(const Polynomial &p) const
Definition: polynomial.hpp:134
Polynomial & operator+=(const Polynomial &p)
Definition: polynomial.hpp:124
static void Negate(const Polynomial &in, Polynomial &out)
Definition: polynomial.hpp:167
static void Scale(const Polynomial &p, double w, Polynomial &q)
Definition: polynomial.hpp:146
int operator!=(const Polynomial &p) const
Definition: polynomial.hpp:106
Polynomial & operator=(const Polynomial< Degree2 > &p)
int isZero(void) const
Definition: polynomial.hpp:111
static void Subtract(const Polynomial &p1, const Polynomial &p2, Polynomial &q)
Definition: polynomial.hpp:163
int operator==(const Polynomial &p) const
Definition: polynomial.hpp:101
Polynomial scale(double s) const
Definition: polynomial.hpp:239
static void AddScaled(const Polynomial &p1, double w1, const Polynomial &p2, double w2, Polynomial &q)
Definition: polynomial.hpp:150
Polynomial< Degree+1 > integral(void) const
Definition: polynomial.hpp:71
Polynomial & addScaled(const Polynomial &p, double scale)
Definition: polynomial.hpp:119
Polynomial operator-(void) const
Definition: polynomial.hpp:173
Polynomial & operator-=(const Polynomial &p)
Definition: polynomial.hpp:129
Polynomial< Degree-1 > derivative(void) const
Definition: polynomial.hpp:64
Polynomial shift(double t) const
Definition: polynomial.hpp:250
static Polynomial BSplineComponent(int i)
Definition: polynomial.hpp:307