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

Last change on this file since 1474 was 1371, checked in by ansari, 25 years ago

MAJ documentation, Makefile, ... - Reza 5/1/2001

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