Last change
on this file since 633 was 220, checked in by ansari, 26 years ago |
Creation module DPC/NTools Reza 09/04/99
|
File size:
1.1 KB
|
Rev | Line | |
---|
[220] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | #include <math.h>
|
---|
| 3 | #include "peida.h"
|
---|
| 4 | #include "nbconst.h"
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | ///////////////////////////////
|
---|
| 8 | // Exponentielles tabulees //
|
---|
| 9 | ///////////////////////////////
|
---|
| 10 |
|
---|
| 11 | class TabFExp EXC_AWARE {
|
---|
| 12 | public:
|
---|
| 13 | TabFExp();
|
---|
| 14 | ~TabFExp();
|
---|
| 15 | inline double operator()(double x)
|
---|
| 16 | { if (x > 0) return exp(x);
|
---|
| 17 | if (x <= -10) return 0;
|
---|
| 18 | return tab[int(-x*1000)];
|
---|
| 19 | }
|
---|
| 20 | private:
|
---|
| 21 | double* tab;
|
---|
| 22 | };
|
---|
| 23 |
|
---|
| 24 | extern TabFExp* ptabFExp;
|
---|
| 25 | #define tabFExp(_x_) ((*ptabFExp)(_x_))
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | ////////////////////////////////////
|
---|
| 29 | // Sinus tabules (et Cosinus) //
|
---|
| 30 | ////////////////////////////////////
|
---|
| 31 |
|
---|
| 32 | class TabFSin EXC_AWARE {
|
---|
| 33 | public:
|
---|
| 34 | TabFSin(int ntab = 0);
|
---|
| 35 | ~TabFSin();
|
---|
| 36 | inline double operator()(double x)
|
---|
| 37 | {
|
---|
| 38 | double s = 1.;
|
---|
| 39 | if(x<0.) {x *=-1.; s = -1.;}
|
---|
| 40 | x -= DeuxPi * int(x/DeuxPi);
|
---|
| 41 | if(x>Pi) {x -= Pi; s *= -1.;}
|
---|
| 42 | if(x>Pi/2.) x = Pi-x;
|
---|
| 43 | return s * tab[int(x/delta)];
|
---|
| 44 | }
|
---|
| 45 | private:
|
---|
| 46 | int ntab;
|
---|
| 47 | double delta;
|
---|
| 48 | double* tab;
|
---|
| 49 | };
|
---|
| 50 |
|
---|
| 51 | extern TabFSin* ptabFSin;
|
---|
| 52 | #define tabFSin(_x_) ((*ptabFSin)(_x_))
|
---|
| 53 | #define tabFCos(_x_) ((*ptabFSin)(_x_+Pis2))
|
---|
Note:
See
TracBrowser
for help on using the repository browser.