OpendTect-6_4  6.4
math2.h
Go to the documentation of this file.
1 #ifndef math2_h
2 #define math2_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Bril
9  Date: Aug 2005
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "basicmod.h"
16 #include "gendefs.h"
17 #include "odcomplex.h"
18 
19 /* Functions with some extra facilities added to math.h
20 
21  Each function has a float and a double version. This may be very
22  old-fashioned, but who cares.
23 
24  At the end, there is also an all-integer x to the power y.
25 
26  */
27 
28 
29 namespace Math
30 {
31 
34 mGlobal(Basic) unsigned int SetBits( unsigned int curflags,
35  unsigned int mask, bool yn );
36 
39 mGlobal(Basic) bool AreBitsSet( unsigned int curflags,
40  unsigned int mask, bool all=true );
41 
43 mGlobal(Basic) bool IsNormalNumber(float);
44 
47 mGlobal(Basic) float PowerOf(float,float);
48 
51 mGlobal(Basic) float ASin(float);
52 
55 mGlobal(Basic) float ACos(float);
56 
59 mGlobal(Basic) float Log(float);
60 
63 mGlobal(Basic) float Log10(float);
64 
67 mGlobal(Basic) float Sqrt(float);
68 
70 mGlobal(Basic) float BesselI0(float);
71 
73 
76 mGlobal(Basic) float Exp(float);
77 
78 mGlobal(Basic) float toDB(float);
79 
80 mGlobal(Basic) inline unsigned int Abs( unsigned int i ) { return i; }
81 mGlobal(Basic) inline od_uint64 Abs( od_uint64 i ) { return i; }
82 mGlobal(Basic) unsigned int Abs(int i);
83 mGlobal(Basic) od_uint64 Abs(od_int64 i);
84 mGlobal(Basic) float Abs(float);
85 mGlobal(Basic) double Abs(double);
86 mGlobal(Basic) float Abs(float_complex);
87 
88 mGlobal(Basic) float Floor(float);
89 mGlobal(Basic) double Floor(double);
90 mGlobal(Basic) float Ceil(float);
91 mGlobal(Basic) double Ceil(double);
92 
93 mGlobal(Basic) float Atan2(float y, float x);
94 mGlobal(Basic) double Atan2(double y, double x);
95 mGlobal(Basic) float Atan2(float_complex timeval);
96 
97 inline float toDegrees(float r) { return (mIsUdf(r) ? r : r*mRad2DegF);}
98 inline double toDegrees(double r) { return (mIsUdf(r) ? r : r*mRad2DegD);}
99 inline float toRadians(float d) { return (mIsUdf(d) ? d : d*mDeg2RadF);}
100 inline double toRadians(double d) { return (mIsUdf(d) ? d : d*mDeg2RadD);}
101 
102 inline float degFromNorth( float azimuth )
103  {
104  const float deg = 90 - mRad2DegF * azimuth;
105  return deg < 0 ? deg + 360 : deg;
106  }
107 
108 mGlobal(Basic) int LCMOf(int,int);
109 mGlobal(Basic) int HCFOf(int,int);
110 mGlobal(Basic) bool IsNormalNumber(double);
111 mGlobal(Basic) double PowerOf(double,double);
112 mGlobal(Basic) double ASin(double);
113 mGlobal(Basic) double ACos(double);
114 mGlobal(Basic) double Log(double);
115 mGlobal(Basic) double Log10(double);
116 mGlobal(Basic) double Exp(double);
117 mGlobal(Basic) double Sqrt(double);
118 mGlobal(Basic) double toDB(double);
119 mGlobal(Basic) double BesselI0(double);
120 
121 template <class iT,class iPOW> inline
122 iT IntPowerOf( iT i, iPOW p )
123 {
124  iT ret = 1;
125  while ( p )
126  {
127  if ( p > 0 )
128  { ret *= i; p--; }
129  else
130  { ret /= i; p++; }
131  }
132  return ret;
133 }
134 
135 mGlobal(Basic) double IntPowerOf(double,int);
136 mGlobal(Basic) float IntPowerOf(float,int);
137 
138 
139 } // namespace Math
140 
141 
142 #endif
float PowerOf(float, float)
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
int HCFOf(int, int)
float ACos(float)
#define mGlobal(module)
Definition: commondefs.h:163
float Ceil(float)
#define od_int64
Definition: plftypes.h:36
Definition: i_layout.h:35
float Atan2(float y, float x)
float ASin(float)
float toDegrees(float r)
Definition: math2.h:97
float Log10(float)
unsigned int Abs(unsigned int i)
Definition: math2.h:80
float Floor(float)
float toDB(float)
#define mRad2DegF
Definition: commondefs.h:119
float degFromNorth(float azimuth)
Definition: math2.h:102
std::complex< float > float_complex
Definition: odcomplex.h:18
float toRadians(float d)
Definition: math2.h:99
#define mDeg2RadF
Definition: commondefs.h:118
bool AreBitsSet(unsigned int curflags, unsigned int mask, bool all=true)
#define od_uint64
Definition: plftypes.h:37
float Log(float)
int LCMOf(int, int)
#define mDeg2RadD
Definition: commondefs.h:116
#define mRad2DegD
Definition: commondefs.h:117
Definition: math2.h:29
float Exp(float)
unsigned int SetBits(unsigned int curflags, unsigned int mask, bool yn)
bool IsNormalNumber(float)
float Sqrt(float)
iT IntPowerOf(iT i, iPOW p)
Definition: math2.h:122
float BesselI0(float)

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019