Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

MathUt.hpp

00001 #ifndef _MathUt_H
00002 #define _MathUt_H
00003 
00004 
00005 
00028 #include <math.h>
00029 #include "RComplex.hpp"
00030 
00031 class MathUt
00032 {
00033 public:
00034         
00035 //  ordering
00036 static int sign(double a){ if(a==0.0) return 0.0; return (a >= 0.0 ? 1 : -1); }
00037 
00038 static int minsign(double a, double b){return (fabs(a) <= fabs(b) ? sign(a) : sign(b));}
00039 
00040 // static double min(double a, double b){ return (a < b ? a : b); } // predefined as macro
00041 // static double max(double a, double b){ return (a > b ? a : b); } // predefined as macro
00042 
00043 static double minEq(double a, double b){ return (a <= b ? a : b); }
00044 static double maxEq(double a, double b){ return (a >= b ? a : b); }
00045 
00046 static bool equal(double a, double b, double eps=1e-12){ return (a-eps < b && a+eps > b); }
00047 
00048 //  minmod for difference computation
00049 static double minmod(double a, double b)
00050         {
00051         return 0.5* (sign(a) + sign(b)) * (fabs(a) < fabs(b) ? fabs(a) : fabs(b));
00052         }
00053 
00054 static double maxmod(double a, double b)
00055         {
00056         return 0.5* (sign(a) + sign(b)) * (fabs(a) > fabs(b) ? fabs(a) : fabs(b));
00057         }
00058 
00059 static RComplex minmod(RComplex a, RComplex b)
00060         {
00061         return RComplex(minmod(a.a,b.a), minmod(a.b,b.b));
00062         }
00063 
00064 };
00065 
00066 #endif
SourceForge.net Logo
Restoreinpaint sourceforge project `C++/Java Image Processing, Restoration, Inpainting Project'.

Bernard De Cuyper: Open Project Leader: Concept, design and development.
Bernard De Cuyper & Eddy Fraiha 2002, 2003. Bernard De Cuyper 2004. Open and free, for friendly usage only.
Modifications on Belgium ground of this piece of artistic work, by governement institutions or companies, must be notified to Bernard De Cuyper.
bern_bdc@hotmail.com