source: Sophya/trunk/SophyaLib/NTools/integ.h@ 220

Last change on this file since 220 was 220, checked in by ansari, 26 years ago

Creation module DPC/NTools Reza 09/04/99

File size: 2.3 KB
Line 
1// This may look like C code, but it is really -*- C++ -*-
2//
3// integ.h
4//
5// $Id: integ.h,v 1.1.1.1 1999-04-09 17:57:55 ansari Exp $
6//
7
8#ifndef INTEG_H_SEEN
9#define INTEG_H_SEEN
10
11#include "defs.h"
12#include "exceptions.h"
13#include <set>
14#if defined(__KCC__)
15#include <set.h>
16#endif
17
18class GeneralFunction;
19
20class Integrator EXC_AWARE {
21public:
22 typedef double(*FUNC)(double);
23
24 Integrator();
25 Integrator(FUNC, double xmin, double xmax);
26 Integrator(FUNC);
27 Integrator(GeneralFunction*, double* par, double xmin, double xmax);
28 Integrator(GeneralFunction*, double* par);
29 virtual ~Integrator();
30
31 virtual double Value() = 0;
32 virtual double ValueBetween(double xmin, double xmax);
33 virtual operator double() {return Value();}
34
35 virtual Integrator& NStep(int);
36 virtual Integrator& DX(double);
37 virtual Integrator& ReqPrec(double); // NOT YET !
38 virtual Integrator& Limits(double xmin, double xmax);
39 virtual Integrator& Func(FUNC);
40 virtual Integrator& Func(GeneralFunction*, double* par);
41
42protected:
43 FUNC mFunc;
44 GeneralFunction* mGFF;
45 double* mGFFParm;
46
47 int mNStep; // -1 si pas fixe
48 double mDX;
49 double mReqPrec;
50 double mXMin, mXMax;
51
52 double FVal(double x) const;
53 virtual void LimitsChanged() {}
54 virtual void StepsChanged() {}
55 virtual void FuncChanged() {}
56};
57
58
59
60class TrpzInteg : public Integrator {
61public:
62 TrpzInteg();
63 TrpzInteg(FUNC, double xmin, double xmax);
64 TrpzInteg(FUNC);
65 TrpzInteg(GeneralFunction*, double* par, double xmin, double xmax);
66 TrpzInteg(GeneralFunction*, double* par);
67
68 ~TrpzInteg();
69
70 virtual double Value();
71};
72
73class GLInteg : public Integrator {
74public:
75 GLInteg();
76 GLInteg(FUNC, double xmin, double xmax);
77 GLInteg(FUNC);
78 GLInteg(GeneralFunction*, double* par, double xmin, double xmax);
79 GLInteg(GeneralFunction*, double* par);
80
81 ~GLInteg();
82
83 virtual double Value();
84 virtual GLInteg& AddBound(double x);
85 virtual GLInteg& SetOrder(int order);
86protected:
87
88 double* mXPos; // integration entre 0 et 1
89 double* mWeights; // integration entre 0 et 1
90 int mOrder; // ordre GL
91 set<double> mBounds; // limites des intervalles d'integration
92
93 void ComputeWeights();
94 void LimitsChanged();
95 void StepsChanged();
96 void InvalWeights();
97 void ComputeBounds();
98};
99
100
101
102#endif
Note: See TracBrowser for help on using the repository browser.