OpendTect  6.6
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  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "basicmod.h"
15 #include "gendefs.h"
16 #include "odcomplex.h"
17 
18 /* Functions with some extra facilities added to math.h
19 
20  Each function has a float and a double version. This may be very
21  old-fashioned, but who cares.
22 
23  At the end, there is also an all-integer x to the power y.
24 
25  */
26 
27 
28 namespace Math
29 {
30 
33 mGlobal(Basic) unsigned int SetBits( unsigned int curflags,
34  unsigned int mask, bool yn );
35 
38 mGlobal(Basic) bool AreBitsSet( unsigned int curflags,
39  unsigned int mask, bool all=true );
40 
42 mGlobal(Basic) bool IsNormalNumber(float);
43 
46 mGlobal(Basic) float PowerOf(float,float);
47 
50 mGlobal(Basic) float ASin(float);
51 
54 mGlobal(Basic) float ACos(float);
55 
58 mGlobal(Basic) float Log(float);
59 
62 mGlobal(Basic) float Log10(float);
63 
66 mGlobal(Basic) float Sqrt(float);
67 
69 mGlobal(Basic) float BesselI0(float);
70 
72 
75 mGlobal(Basic) float Exp(float);
76 
77 mGlobal(Basic) float toDB(float);
78 
79 mGlobal(Basic) inline unsigned int Abs( unsigned int i ) { return i; }
80 mGlobal(Basic) inline od_uint64 Abs( od_uint64 i ) { return i; }
81 mGlobal(Basic) unsigned int Abs(int i);
83 mGlobal(Basic) float Abs(float);
84 mGlobal(Basic) double Abs(double);
85 mGlobal(Basic) float Abs(float_complex);
86 
87 mGlobal(Basic) float Floor(float);
88 mGlobal(Basic) double Floor(double);
89 mGlobal(Basic) float Ceil(float);
90 mGlobal(Basic) double Ceil(double);
91 
92 mGlobal(Basic) float Atan2(float y, float x);
93 mGlobal(Basic) double Atan2(double y, double x);
94 mGlobal(Basic) float Atan2(float_complex timeval);
95 
96 inline float toDegrees(float r) { return (mIsUdf(r) ? r : r*mRad2DegF);}
97 inline double toDegrees(double r) { return (mIsUdf(r) ? r : r*mRad2DegD);}
98 inline float toRadians(float d) { return (mIsUdf(d) ? d : d*mDeg2RadF);}
99 inline double toRadians(double d) { return (mIsUdf(d) ? d : d*mDeg2RadD);}
100 
101 inline float degFromNorth( float azimuth )
102  {
103  const float deg = 90 - mRad2DegF * azimuth;
104  return deg < 0 ? deg + 360 : deg;
105  }
106 
107 mGlobal(Basic) int LCMOf(int,int);
108 mGlobal(Basic) int HCFOf(int,int);
109 mGlobal(Basic) bool IsNormalNumber(double);
110 mGlobal(Basic) double PowerOf(double,double);
111 mGlobal(Basic) double ASin(double);
112 mGlobal(Basic) double ACos(double);
113 mGlobal(Basic) double Log(double);
114 mGlobal(Basic) double Log10(double);
115 mGlobal(Basic) double Exp(double);
116 mGlobal(Basic) double Sqrt(double);
117 mGlobal(Basic) double toDB(double);
118 mGlobal(Basic) double BesselI0(double);
119 
120 template <class iT,class iPOW> inline
121 iT IntPowerOf( iT i, iPOW p )
122 {
123  iT ret = 1;
124  while ( p )
125  {
126  if ( p > 0 )
127  { ret *= i; p--; }
128  else
129  { ret /= i; p++; }
130  }
131  return ret;
132 }
133 
134 mGlobal(Basic) double IntPowerOf(double,int);
135 mGlobal(Basic) float IntPowerOf(float,int);
136 mGlobal(Basic) int NrSignificantDecimals(double);
137 
138 
139 } // namespace Math
140 
141 
od_uint64
#define od_uint64
Definition: plftypes.h:36
Math::PowerOf
float PowerOf(float, float)
Math::AreBitsSet
bool AreBitsSet(unsigned int curflags, unsigned int mask, bool all=true)
Math::IsNormalNumber
bool IsNormalNumber(float)
float_complex
std::complex< float > float_complex
Definition: odcomplex.h:17
Math::ASin
float ASin(float)
Math::Log10
float Log10(float)
mGlobal
#define mGlobal(module)
Definition: commondefs.h:180
mIsUdf
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:289
Math::LCMOf
int LCMOf(int, int)
od_int64
#define od_int64
Definition: plftypes.h:35
Math::Floor
float Floor(float)
Math::Abs
unsigned int Abs(unsigned int i)
Definition: math2.h:79
Math::IntPowerOf
iT IntPowerOf(iT i, iPOW p)
Definition: math2.h:121
Math::Log
float Log(float)
Math::HCFOf
int HCFOf(int, int)
Math::toDB
float toDB(float)
mRad2DegD
#define mRad2DegD
Definition: commondefs.h:130
mDeg2RadF
#define mDeg2RadF
Definition: commondefs.h:131
gendefs.h
all
@ all
Definition: i_layout.h:35
Math::Exp
float Exp(float)
Math::Atan2
float Atan2(float y, float x)
Math::Ceil
float Ceil(float)
Math::SetBits
unsigned int SetBits(unsigned int curflags, unsigned int mask, bool yn)
Math::toRadians
float toRadians(float d)
Definition: math2.h:98
odcomplex.h
Math::degFromNorth
float degFromNorth(float azimuth)
Definition: math2.h:101
mDeg2RadD
#define mDeg2RadD
Definition: commondefs.h:129
Math::Sqrt
float Sqrt(float)
Math::BesselI0
float BesselI0(float)
Math::toDegrees
float toDegrees(float r)
Definition: math2.h:96
Math
Definition: math2.h:29
Math::ACos
float ACos(float)
mRad2DegF
#define mRad2DegF
Definition: commondefs.h:132
Math::NrSignificantDecimals
int NrSignificantDecimals(double)

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