Integrator1D.h

00001 #ifndef gridripper_math_Integrator1D
00002 #define gridripper_math_Integrator1D
00003 
00004 #include <gridripper/config.h>
00005 #include <gridripper/lang/IllegalArgumentException.h>
00006 #include <string>
00007 
00008 namespace gridripper { namespace math {
00009 
00010 using namespace std;
00011 
00012 
00020 class IntegratorIncremental1D
00021 {
00022     protected:
00023         int n;
00024         GReal_t integral;
00025         IntegratorIncremental1D() : n(0), integral(0.0) {  }
00026         IntegratorIncremental1D(const IntegratorIncremental1D& other)
00027          : n(other.n), integral(other.integral) {  }
00028     public:
00029         virtual ~IntegratorIncremental1D() {  }
00030         virtual void reset() = 0;
00031         virtual void increment(GReal_t x, GReal_t f) = 0;
00032         virtual GReal_t integrate() const throw(IllegalArgumentException&) = 0;
00033         virtual string toString() const = 0;
00034         int getN() const { return n; }
00035         virtual IntegratorIncremental1D* cloneIntegrator() const =0;
00036 };
00037 
00038 
00039 class TrapesoidalIntegratorIncremental1D : public IntegratorIncremental1D
00040 {
00041     private:
00042         GReal_t xprev;
00043         GReal_t fprev;
00044     public:
00045         TrapesoidalIntegratorIncremental1D();
00046         TrapesoidalIntegratorIncremental1D(const TrapesoidalIntegratorIncremental1D&);
00047         void reset();
00048         void increment(const GReal_t x, const GReal_t f);
00049         GReal_t integrate() const throw(IllegalArgumentException&);
00050         string toString() const { return "TrapesoidalIntegratorIncremental1D"; }
00051         virtual IntegratorIncremental1D* cloneIntegrator() const {
00052             return new TrapesoidalIntegratorIncremental1D(*this);
00053         }
00054 };
00055 
00056 
00057 class SimpsonIntegratorIncremental1D : public IntegratorIncremental1D
00058 {
00059     private:
00060         GReal_t xprevprev;
00061         GReal_t fprevprev;
00062         GReal_t xprev;
00063         GReal_t fprev;
00064     public:
00065         SimpsonIntegratorIncremental1D();
00066         SimpsonIntegratorIncremental1D(const SimpsonIntegratorIncremental1D&);
00067         void reset();
00068         void increment(GReal_t x, GReal_t f);
00069         GReal_t integrate() const throw(IllegalArgumentException&);
00070         string toString() const { return "SimpsonIntegratorIncremental1D"; }
00071         virtual IntegratorIncremental1D* cloneIntegrator() const {
00072             return new SimpsonIntegratorIncremental1D(*this);
00073         }
00074 };
00075 
00076 
00084 class Integrator1D
00085 {
00086     protected:
00088         Integrator1D() {  }
00089 
00091         Integrator1D(const Integrator1D&) {  }
00092 
00093     public:
00094 
00095         virtual ~Integrator1D() {  }
00096 
00105         virtual GReal_t integrate(const GReal_t* x, const GReal_t* f, 
00106         int start, int n) const throw(IllegalArgumentException&) = 0;
00107 
00109         virtual string toString() const = 0;
00110 };
00111 
00112 
00119 class TrapesoidalIntegrator1D: public Integrator1D
00120 {
00121     public:
00123         TrapesoidalIntegrator1D() : Integrator1D() {  }
00124 
00126         TrapesoidalIntegrator1D(const TrapesoidalIntegrator1D& other)
00127          : Integrator1D(other) {  }
00128 
00129         ~TrapesoidalIntegrator1D() {  }
00130 
00139         GReal_t integrate(const GReal_t* x, const GReal_t* f, int start, int n)
00140         const throw(IllegalArgumentException&);
00141 
00143         string toString() const { return "TrapesoidalIntegrator1D"; }
00144 };
00145 
00146 
00153 class SimpsonIntegrator1D: public Integrator1D
00154 {
00155     public:
00157         SimpsonIntegrator1D() : Integrator1D() {  }
00158 
00160         SimpsonIntegrator1D(const SimpsonIntegrator1D& other)
00161          : Integrator1D(other) {  }
00162 
00163         ~SimpsonIntegrator1D() {  }
00164 
00173         GReal_t integrate(const GReal_t* x, const GReal_t* f, int start, int n)
00174         const throw(IllegalArgumentException&);
00175 
00177         string toString() const { return "SimpsonIntegrator1D"; }
00178 };
00179 
00180 
00181 } } // namespace gridripper::math
00182 
00183 #endif /* gridripper_math_Integrator1D */

Generated on Wed Jun 17 18:46:47 2009 for GridRipper by  doxygen 1.5.6