Main Page   Class Hierarchy   Compound List   File List   Compound Members  

mmath.h

00001 #ifndef __MATH_HPP__
00002 #define __MATH_HPP__
00003 
00004 #include <magic/mobject.h>
00005 #include <magic/mpackarray.h>
00006 
00007 // In SunOS/Solaris there is a fp-exception class in math.h.... SHINY BLOODY IDIOTS!
00008 //#ifdef __P
00009 //#undef __P
00010 //#endif
00011 //#ifdef SunOS
00012 //#define exception exception_kludge
00013 //#include <math.h>
00014 //#undef exception
00015 //#else
00016 #include <math.h>
00017 //#endif
00018 
00021 int     rnd         (int range);
00022 
00025 double  frnd        ();
00026 
00030 double  gaussrnd    (double stdv);
00031 
00034 inline double   sqr (double x) {return x*x;}
00035 
00036 //double quadatan (double y, double x);
00037 
00038 template <class T>
00039 inline T sqr (T x) {
00040     return x*x;
00041 }
00042 
00045 inline double sigmoid (double x) {return 1/(1+exp(-x));}
00046 
00047 // |x|
00048 //inline double abs (double a) {
00049 //  return a>=0? a:-a;
00050 //}
00051 
00054 inline void swap (double& x, double& y) {double tmp=x; x=y; y=tmp;}
00055 
00056 #define UNDEFINED_FLOAT 1.2345E30
00057 
00060 inline bool is_undef (double x) {
00061     return x>=1.2345E29;
00062 }
00063 
00067 typedef PackArray<double>   Vector;
00068 
00070 double  sum         (const Vector& x);
00072 double  min         (const Vector& x);
00074 int     minIndex    (const Vector& x);
00076 double  max         (const Vector& x);
00078 int     maxIndex    (const Vector& x);
00080 double  avg         (const Vector& x);
00082 double  stddev      (const Vector& x);
00084 double  stdmerr     (const Vector& x);
00085 
00089 Vector  histogram   (const Vector& x, int n);
00090 
00092 void    add (Vector& x, double m);
00093 
00096 void    multiply (Vector& x, double m);
00097 
00100 void    multiplyToUnity (Vector& x);
00101 
00102 #endif

Generated at Tue Dec 4 19:53:26 2001 for MagiC++ by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001