Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/mathf 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_mathf
0005 #define tools_mathf
0006 
0007 namespace tools {
0008 
0009 //have : static const fpi = (float)3.1415926535897931160E0; ???
0010 
0011 inline float fpi()      {return (float)3.1415926535897931160E0;}
0012 inline float ftwo_pi()  {return (float)6.2831853071795862320E0;}
0013 inline float fhalf_pi() {return (float)1.5707963267948965580E0;}
0014 
0015 //inline float fdeg2rad() {return fpi()/180.0f;} //0.0174f
0016 //inline float frad2deg() {return 180.0f/fpi();}
0017 
0018 inline float fdeg2rad() {
0019   static const float s_v = fpi()/180.0f; //0.0174f
0020   return s_v;
0021 }
0022 inline float frad2deg() {
0023   static const float s_v = 180.0f/fpi();
0024   return s_v;
0025 }
0026 
0027 inline int fround(const float& a_x) {
0028   // From CoinGL/src/base/SbViewportRegion.cpp.
0029   if (a_x == (float) (int(a_x))) return int(a_x);
0030   else return (a_x>0.0f) ? int(a_x+0.5f) : -int(0.5f-a_x);
0031 }
0032 
0033 inline float fstep(const float& a_x) {return a_x<0.0f?0.0f:1.0f;}
0034 
0035 }
0036 
0037 
0038 #include <cmath>
0039 
0040 namespace tools {
0041 
0042 inline float fcos(const float& x) {return (float)::cos(double(x));}
0043 inline float fsin(const float& x) {return (float)::sin(double(x));}
0044 inline float facos(const float& x) {return (float)::acos(double(x));}
0045 inline float fasin(const float& x) {return (float)::asin(double(x));}
0046 inline float ftan(const float& x) {return (float)::tan(double(x));}
0047 inline float fatan(const float& x) {return (float)::atan(double(x));}
0048 inline float fatan2(const float& x,const float& y) {return (float)::atan2(double(x),double(y));}
0049 inline float fsqrt(const float& x) {return (float)::sqrt(double(x));}
0050 inline float fpow(const float& x,const float& y) {return (float)::pow(double(x),(double)(y));}
0051 inline float fexp(const float& x) {return (float)::exp(double(x));}
0052 inline float flog(const float& x) {return (float)::log(double(x));}
0053 inline float flog10(const float& x) {return (float)::log10(double(x));}
0054 inline float ffloor(const float& x) {return (float)::floor(double(x));}
0055 inline float fceil(const float& x) {return (float)::ceil(double(x));}
0056 inline float fcosh(const float& x) {return (float)::cosh(double(x));}
0057 inline float fsinh(const float& x) {return (float)::sinh(double(x));}
0058 inline float ffabs(const float& x) {return (float)::fabs(double(x));}
0059 
0060 }
0061 
0062 #endif