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

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