softsusy is hosted by Hepforge, IPPP Durham
SOFTSUSY  4.1
utils.h
Go to the documentation of this file.
1 
12 #ifndef UTILS_H
13 #define UTILS_H
14 
15 #include "mycomplex.h"
16 #include "def.h"
17 #include <cstdlib>
18 #include <fstream>
19 #include <iostream>
20 #include <cmath>
21 #include <stdio.h>
22 #include <string>
23 #include <exception>
25 #include <csignal>
26 #include <unistd.h>
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <iostream>
30 #include <signal.h>
31 #include <dirent.h>
32 
33 using namespace std;
34 using namespace softsusy;
35 
37 inline double zeroSqrt(double f){ if (f > 0.) return sqrt(f);
38  else return EPSTOL;
39 }
41 double frexp(const Complex & c, int * i);
43 void FPE_ExceptionHandler(int nErrType);
45 int theta(double a);
47 void outputCharacteristics(int);
49 inline double sqr(double a) { return a * a; }
51 inline double maximum(double a, double b) { return ((a > b) ? a : b); }
53 inline double minimum(double a, double b) { return ((a < b) ? a : b); }
55 inline int minimum(int a, int b) { return ((a < b) ? a : b); }
57 double toleranceCheck(double sTin, double sTout);
58 
59 inline double minimum(double a, double b, double c) {
60  if(a <= b && a <= c) return a;
61  else if(b <= a && b <= c) return b;
62  else return c;
63 }
64 
65 inline double maximum(double a, double b, double c) {
66  if(a >= b && a >= c) return a;
67  else if(b >= a && b >= c) return b;
68  else return c;
69 }
70 
71 inline double middle(double a, double b, double c) {
72  if((a >= b && a <= c) ||(a >= c && a <= b) ) return a;
73  else if((b >= a && b <= c) ||(b >= c && b <= a) ) return b;
74  else return c;
75 }
76 
77 inline int massorder(double & a, double & b, double & c) {
78  double anew, bnew, cnew;
79  anew = minimum(a,b,c);
80  cnew= maximum(a,b,c);
81  bnew = middle(a,b,c);
82 
83  a = anew;
84  b = bnew;
85  c = cnew;
86  return 0;
87 }
88 
91 bool close(double m1, double m2, double tol);
92 
94 bool close(Complex m1, Complex m2, double tol);
95 
97 inline double sign(double a, double b) { return ((b) >= 0.0 ?
98  fabs(a) : -fabs(a)); }
99 
101 inline int sgn(double x)
102 { return (x >= 0.0 ? 1 : -1); }
103 
106 void printRow(ostream & o, double x);
107 
110 bool testNan(double f);
111 
112 // For DEBUGING
113 #ifdef DEBUG
114 #define dout cout
115 #else
116 #define dout if(0)cout
117 #endif
118 
119 
120 #endif
121 
drop-in replacement for the original home-grown Complex class
Definition: mycomplex.h:17
double m1
decay global variable declarations
Definition: decays.cpp:14
switches (options) and parameters such as default fermion masses, required accuracy etc
complex numbers and operators between them
global variable declaration
Definition: def.cpp:13
const double EPSTOL
underflow accuracy
Definition: def.h:37
double zeroSqrt(double f)
returns either sqrt(f) for f>0 or 0 otherwise
Definition: utils.h:37
int sgn(double x)
gives the sign (+-1) of x
Definition: utils.h:101
void outputCharacteristics(int)
Sets number of decimal places to display in scientific output.
Definition: utils.cpp:32
double minimum(double a, double b)
minimum of a and b
Definition: utils.h:53
bool testNan(double f)
Definition: utils.cpp:64
double maximum(double a, double b)
maximum of two numbers
Definition: utils.h:51
double sqr(double a)
square of a number
Definition: utils.h:49
double toleranceCheck(double sTin, double sTout)
Finds fractional difference between |a| and |b|.
Definition: utils.cpp:42
double sign(double a, double b)
Returns |a| with sign of b in front.
Definition: utils.h:97
bool close(double m1, double m2, double tol)
Definition: utils.cpp:68
void FPE_ExceptionHandler(int nErrType)
Exception handler - will even trap errors in the fortran portion.
Definition: utils.cpp:21
void printRow(ostream &o, double x)
Definition: utils.cpp:54
int theta(double a)
Standard theta function: 1 is a>0, 0 otherwise.
Definition: utils.cpp:25
double frexp(const Complex &c, int *i)
Gives exponent of the largest number: either imaginary or real part.
Definition: utils.cpp:12