Warning, /include/Geant4/tools/mathd is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_mathd
0005 #define tools_mathd
0006
0007 namespace tools {
0008
0009 //have : static const pi = 3.1415926535897931160E0; ???
0010
0011 //HEALPix lsconstants.h. Quite not the same as us.
0012 //const double pi=3.141592653589793238462643383279502884197;
0013 //const double twopi=6.283185307179586476925286766559005768394;
0014 //const double fourpi=12.56637061435917295385057353311801153679;
0015 //const double halfpi=1.570796326794896619231321691639751442099;
0016
0017 inline double pi() {return 3.1415926535897931160E0;}
0018 inline double two_pi() {return 6.2831853071795862320E0;}
0019 inline double half_pi() {return 1.5707963267948965580E0;}
0020
0021 inline double deg2rad() {
0022 static const double s_v = pi()/180.0;
0023 return s_v;
0024 }
0025 inline double rad2deg() {
0026 static const double s_v = 180.0/pi();
0027 return s_v;
0028 }
0029
0030 // for Lib/ExpFunc.
0031 inline bool in_domain_all(double){return true;}
0032 inline bool in_domain_log(double a_x){return (a_x>0?true:false);}
0033 inline bool in_domain_tan(double a_x){
0034 int n = int(a_x/half_pi());
0035 if(a_x!=n*half_pi()) return true;
0036 return (2*int(n/2)==n?true:false);
0037 }
0038 inline bool in_domain_acos(double a_x){
0039 if((a_x<-1)||(1<a_x)) return false;
0040 return true;
0041 }
0042
0043 /*
0044 inline double angle_modulo(double a_angle) {
0045 int64 div = a_angle/two_pi();
0046 double rest = a_angle - div*two_pi();
0047 if(rest<0) rest += two_pi();
0048 return rest;
0049 }
0050 */
0051
0052 }
0053
0054 //#include "power"
0055
0056 #include <cmath>
0057
0058 namespace tools {
0059
0060 inline double dcos(const double& a_x) {return ::cos(a_x);}
0061 inline double dsin(const double& a_x) {return ::sin(a_x);}
0062 inline double dpow(const double& a_x,const double& a_y) {return ::pow(a_x,a_y);}
0063 inline double dcosh(const double& a_x) {return ::cosh(a_x);}
0064 inline double dsinh(const double& a_x) {return ::sinh(a_x);}
0065
0066 inline double dconj(const double& a_x) {return a_x;}
0067 inline double dfabs(const double& a_x) {return ::fabs(a_x);} //if passing a_fabs(const T&).
0068 inline double dsqrt(const double& a_x) {return ::sqrt(a_x);}
0069
0070 //long double
0071 #ifndef ANDROID
0072 inline long double ldfabs(const long double& a_x) {return ::fabsl(a_x);}
0073 #endif
0074
0075 inline bool dpow(const double& a_x,const double& a_y,double& a_v) {
0076 if((a_x==0)&&(a_y<0)) {
0077 a_v = 0;
0078 return false;
0079 }
0080 a_v = dpow(a_x,a_y);
0081 return true;
0082 }
0083
0084 inline double dgaussian(const double& a_x,const double& a_mean,const double& a_sigma) {
0085 double _tmp = (a_x-a_mean)/a_sigma;
0086 return ::exp(-_tmp*_tmp/2.0)/(a_sigma*::sqrt(2*pi()));
0087 }
0088
0089 }
0090
0091 #endif