1 //////////////////////////////////////////////////////////////////////
\r
3 //////////////////////////////////////////////////////////////////////////////
\r
4 // COPYRIGHT NOTICE FOR GENOME CODE
\r
6 // Copyright (C) 2006 - 2009, Liming Liang and Goncalo Abecasis,
\r
7 // All rights reserved.
\r
9 // Redistribution and use in source and binary forms, with or without
\r
10 // modification, are permitted provided that the following conditions
\r
13 // 1. Redistributions of source code must retain the above copyright
\r
14 // notice, this list of conditions and the following disclaimer.
\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
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
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
36 ///////////////////////////////////////////////////////////////////////////////
\r
40 #ifndef __MATHCONSTANT_H__
\r
41 #define __MATHCONSTANT_H__
\r
44 #define _USE_MATH_DEFINES
\r
50 // Constants for numerical routines
\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
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
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