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() {
0016   static const float s_v = fpi()/180.0f; //0.0174f
0017   return s_v;
0018 }
0019 inline float frad2deg() {
0020   static const float s_v = 180.0f/fpi();
0021   return s_v;
0022 }
0023 
0024 inline int fround(const float& a_x) {
0025   // From CoinGL/src/base/SbViewportRegion.cpp.
0026   if (a_x == (float) (int(a_x))) return int(a_x);
0027   else return (a_x>0.0f) ? int(a_x+0.5f) : -int(0.5f-a_x);
0028 }
0029 
0030 }
0031 
0032 
0033 #include <cmath>
0034 
0035 namespace tools {
0036 
0037 inline float fcos(const float& x) {return (float)::cos(double(x));}
0038 inline float fsin(const float& x) {return (float)::sin(double(x));}
0039 inline float ftan(const float& x) {return (float)::tan(double(x));}
0040 inline float fpow(const float& x,const float& y) {return (float)::pow(double(x),(double)(y));}
0041 inline float flog10(const float& x) {return (float)::log10(double(x));}
0042 inline float ffloor(const float& x) {return (float)::floor(double(x));}
0043 inline float fceil(const float& x) {return (float)::ceil(double(x));}
0044 inline float ffabs(const float& x) {return (float)::fabs(double(x));}
0045 
0046 }
0047 
0048 #endif