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.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/mathd (Version 11.3.0) and /externals/g4tools/include/tools/mathd (Version 11.0.p2)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef tools_mathd                                 4 #ifndef tools_mathd
  5 #define tools_mathd                                 5 #define tools_mathd
  6                                                     6 
  7 namespace tools {                                   7 namespace tools {
  8                                                     8 
  9 //have : static const pi = 3.14159265358979311      9 //have : static const pi = 3.1415926535897931160E0; ???
 10                                                    10 
 11 //HEALPix lsconstants.h. Quite not the same as     11 //HEALPix lsconstants.h. Quite not the same as us.
 12 //const double pi=3.14159265358979323846264338     12 //const double pi=3.141592653589793238462643383279502884197;
 13 //const double twopi=6.28318530717958647692528     13 //const double twopi=6.283185307179586476925286766559005768394;
 14 //const double fourpi=12.566370614359172953850     14 //const double fourpi=12.56637061435917295385057353311801153679;
 15 //const double halfpi=1.5707963267948966192313     15 //const double halfpi=1.570796326794896619231321691639751442099;
 16                                                    16 
 17 inline double pi()      {return 3.141592653589     17 inline double pi()      {return 3.1415926535897931160E0;}
 18 inline double two_pi()  {return 6.283185307179     18 inline double two_pi()  {return 6.2831853071795862320E0;}
 19 inline double half_pi() {return 1.570796326794     19 inline double half_pi() {return 1.5707963267948965580E0;}
 20                                                    20 
 21 inline double deg2rad() {                          21 inline double deg2rad() {
 22   static const double s_v = pi()/180.0;            22   static const double s_v = pi()/180.0;
 23   return s_v;                                      23   return s_v;
 24 }                                                  24 }
 25 inline double rad2deg() {                          25 inline double rad2deg() {
 26   static const double s_v = 180.0/pi();            26   static const double s_v = 180.0/pi();
 27   return s_v;                                      27   return s_v;
 28 }                                                  28 }
 29                                                    29 
 30 // for Lib/ExpFunc.                                30 // for Lib/ExpFunc.
 31 inline bool in_domain_all(double){return true;     31 inline bool in_domain_all(double){return true;}
 32 inline bool in_domain_log(double a_x){return (     32 inline bool in_domain_log(double a_x){return (a_x>0?true:false);}
 33 inline bool in_domain_tan(double a_x){             33 inline bool in_domain_tan(double a_x){
 34   int n = int(a_x/half_pi());                      34   int n = int(a_x/half_pi());
 35   if(a_x!=n*half_pi()) return true;                35   if(a_x!=n*half_pi()) return true;
 36   return (2*int(n/2)==n?true:false);               36   return (2*int(n/2)==n?true:false);
 37 }                                                  37 }
 38 inline bool in_domain_acos(double a_x){            38 inline bool in_domain_acos(double a_x){
 39   if((a_x<-1)||(1<a_x)) return false;              39   if((a_x<-1)||(1<a_x)) return false;
 40   return true;                                     40   return true;
 41 }                                                  41 }
 42                                                    42 
 43 /*                                                 43 /*
 44 inline double angle_modulo(double a_angle) {       44 inline double angle_modulo(double a_angle) {
 45   int64 div = a_angle/two_pi();                    45   int64 div = a_angle/two_pi();
 46   double rest = a_angle - div*two_pi();            46   double rest = a_angle - div*two_pi();
 47   if(rest<0) rest += two_pi();                     47   if(rest<0) rest += two_pi();
 48   return rest;                                     48   return rest;
 49 }                                                  49 }
 50 */                                                 50 */
 51                                                    51 
 52 }                                                  52 }
 53                                                    53 
 54 //#include "power"                                 54 //#include "power"
 55                                                    55 
 56 #include <cmath>                                   56 #include <cmath>
 57                                                    57 
 58 namespace tools {                                  58 namespace tools {
 59                                                    59 
 60 inline double dcos(const double& a_x) {return      60 inline double dcos(const double& a_x) {return ::cos(a_x);}
 61 inline double dsin(const double& a_x) {return      61 inline double dsin(const double& a_x) {return ::sin(a_x);}
 62 inline double dpow(const double& a_x,const dou     62 inline double dpow(const double& a_x,const double& a_y) {return ::pow(a_x,a_y);}
 63 inline double dcosh(const double& a_x) {return     63 inline double dcosh(const double& a_x) {return ::cosh(a_x);}
 64 inline double dsinh(const double& a_x) {return     64 inline double dsinh(const double& a_x) {return ::sinh(a_x);}
 65                                                    65 
 66 inline double dconj(const double& a_x) {return     66 inline double dconj(const double& a_x) {return a_x;}
 67 inline double dfabs(const double& a_x) {return     67 inline double dfabs(const double& a_x) {return ::fabs(a_x);} //if passing a_fabs(const T&).
 68 inline double dsqrt(const double& a_x) {return     68 inline double dsqrt(const double& a_x) {return ::sqrt(a_x);}
 69                                                    69 
 70 //long double                                      70 //long double
 71 #ifndef ANDROID                                    71 #ifndef ANDROID
 72 inline long double ldfabs(const long double& a     72 inline long double ldfabs(const long double& a_x) {return ::fabsl(a_x);}
 73 #endif                                             73 #endif
 74                                                    74 
 75 inline bool dpow(const double& a_x,const doubl     75 inline bool dpow(const double& a_x,const double& a_y,double& a_v) {
 76   if((a_x==0)&&(a_y<0)) {                          76   if((a_x==0)&&(a_y<0)) {
 77     a_v = 0;                                       77     a_v = 0;
 78     return false;                                  78     return false;
 79   }                                                79   }
 80   a_v = dpow(a_x,a_y);                             80   a_v = dpow(a_x,a_y);
 81   return true;                                     81   return true;
 82 }                                                  82 }
 83                                                    83 
 84 inline double dgaussian(const double& a_x,cons     84 inline double dgaussian(const double& a_x,const double& a_mean,const double& a_sigma) {
 85   double _tmp = (a_x-a_mean)/a_sigma;              85   double _tmp = (a_x-a_mean)/a_sigma;
 86   return ::exp(-_tmp*_tmp/2.0)/(a_sigma*::sqrt     86   return ::exp(-_tmp*_tmp/2.0)/(a_sigma*::sqrt(2*pi()));
 87 }                                                  87 }
 88                                                    88 
 89 }                                                  89 }
 90                                                    90 
 91 #endif                                             91 #endif