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