]> git.donarmstrong.com Git - genome.git/blob - MathConstant.h
add cxflags and debugging flags
[genome.git] / MathConstant.h
1 ////////////////////////////////////////////////////////////////////// \r
2 // MathConstant.h \r
3 //////////////////////////////////////////////////////////////////////////////\r
4 //              COPYRIGHT NOTICE FOR GENOME CODE\r
5 //\r
6 // Copyright (C) 2006 - 2009, Liming Liang and Goncalo Abecasis,\r
7 // All rights reserved.\r
8 //\r
9 //   Redistribution and use in source and binary forms, with or without\r
10 //   modification, are permitted provided that the following conditions\r
11 //   are met:\r
12 //\r
13 //     1. Redistributions of source code must retain the above copyright\r
14 //        notice, this list of conditions and the following disclaimer.\r
15 //\r
16 //     2. Redistributions in binary form must reproduce the above copyright\r
17 //        notice, this list of conditions and the following disclaimer in the\r
18 //        documentation and/or other materials provided with the distribution.\r
19 //\r
20 //     3. The names of its contributors may not be used to endorse or promote\r
21 //        products derived from this software without specific prior written\r
22 //        permission.\r
23 //\r
24 //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
25 //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
26 //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
27 //   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
28 //   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
29 //   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
30 //   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
31 //   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
32 //   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
33 //   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
34 //   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
35 //\r
36 ///////////////////////////////////////////////////////////////////////////////\r
37 \r
38 \r
39 \r
40 #ifndef __MATHCONSTANT_H__\r
41 #define __MATHCONSTANT_H__\r
42 \r
43 #ifdef  _MSC_VER\r
44 #define _USE_MATH_DEFINES \r
45 #endif\r
46 \r
47 #include "math.h"\r
48 #include "stdlib.h"\r
49 \r
50 // Constants for numerical routines\r
51 //\r
52 \r
53 #define TINY    1.0e-30        // A small number\r
54 #define ITMAX   200            // Maximum number of iterations\r
55 #define EPS     3.0e-7         // Relative accuracy\r
56 #define ZEPS    3.0e-10        // Precision around zero\r
57 #define FPMIN   1.0e-30        // Number near the smallest representable number\r
58 #define FPMAX   1.0e+100       // Number near the largest representable number\r
59 #define TOL     1.0e-6         // Zero SVD values below this\r
60 #define GOLD    0.61803399     // Golden ratio\r
61 #define CGOLD   0.38196601     // Complement of golden ratio\r
62 \r
63 inline double square(double a)         { return a * a; }\r
64 inline double sign(double a, double b) { return b >= 0 ? fabs(a) : -fabs(a); }\r
65 inline double min(double a, double b)  { return a < b ? a : b; }\r
66 inline double max(double a, double b)  { return a > b ? a : b; }\r
67 \r
68 inline int square(int a)      { return a * a; }\r
69 inline int sign(int a, int b) { return b >= 0 ? abs(a) : -abs(a); }\r
70 inline int min(int a, int b)  { return a < b ? a : b; }\r
71 inline int max(int a, int b)  { return a > b ? a : b; }\r
72 \r
73 #endif\r