Last change
on this file since 1445 was 1371, checked in by ansari, 25 years ago |
MAJ documentation, Makefile, ... - Reza 5/1/2001
|
File size:
1.3 KB
|
Line | |
---|
1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
2 | // Tabulated math functions
|
---|
3 | // E. Aubourg, C. Magneville 1996-2000
|
---|
4 | // DAPNIA/SPP (Saclay) / CEA LAL - IN2P3/CNRS (Orsay)
|
---|
5 |
|
---|
6 | #ifndef TABMATH_H_SEEN
|
---|
7 | #define TABMATH_H_SEEN
|
---|
8 |
|
---|
9 | #include <math.h>
|
---|
10 | #include "peida.h"
|
---|
11 | #include "nbconst.h"
|
---|
12 |
|
---|
13 | namespace SOPHYA {
|
---|
14 |
|
---|
15 | ///////////////////////////////
|
---|
16 | // Exponentielles tabulees //
|
---|
17 | ///////////////////////////////
|
---|
18 |
|
---|
19 | class TabFExp {
|
---|
20 | public:
|
---|
21 | TabFExp();
|
---|
22 | ~TabFExp();
|
---|
23 | inline double operator()(double x)
|
---|
24 | { if (x > 0) return exp(x);
|
---|
25 | if (x <= -10) return 0;
|
---|
26 | return tab[int(-x*1000)];
|
---|
27 | }
|
---|
28 | private:
|
---|
29 | double* tab;
|
---|
30 | };
|
---|
31 |
|
---|
32 | extern TabFExp* ptabFExp;
|
---|
33 | #define tabFExp(_x_) ((*ptabFExp)(_x_))
|
---|
34 |
|
---|
35 |
|
---|
36 | ////////////////////////////////////
|
---|
37 | // Sinus tabules (et Cosinus) //
|
---|
38 | ////////////////////////////////////
|
---|
39 |
|
---|
40 | class TabFSin {
|
---|
41 | public:
|
---|
42 | TabFSin(int ntab = 0);
|
---|
43 | ~TabFSin();
|
---|
44 | inline double operator()(double x)
|
---|
45 | {
|
---|
46 | double s = 1.;
|
---|
47 | if(x<0.) {x *=-1.; s = -1.;}
|
---|
48 | x -= DeuxPi * int(x/DeuxPi);
|
---|
49 | if(x>Pi) {x -= Pi; s *= -1.;}
|
---|
50 | if(x>Pi/2.) x = Pi-x;
|
---|
51 | return s * tab[int(x/delta)];
|
---|
52 | }
|
---|
53 | private:
|
---|
54 | int ntab;
|
---|
55 | double delta;
|
---|
56 | double* tab;
|
---|
57 | };
|
---|
58 |
|
---|
59 | extern TabFSin* ptabFSin;
|
---|
60 | #define tabFSin(_x_) ((*ptabFSin)(_x_))
|
---|
61 | #define tabFCos(_x_) ((*ptabFSin)(_x_+Pis2))
|
---|
62 |
|
---|
63 | } // namespace SOPHYA
|
---|
64 |
|
---|
65 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.