libStatGen Software
1
|
00001 /* 00002 * Copyright (C) 2010 Regents of the University of Michigan 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef __MATHCONSTANT_H__ 00019 #define __MATHCONSTANT_H__ 00020 00021 #ifdef _MSC_VER 00022 #define _USE_MATH_DEFINES 00023 #endif 00024 00025 #include <math.h> 00026 #include <stdlib.h> 00027 00028 // Constants for numerical routines 00029 // 00030 00031 #define TINY 1.0e-30 // A small number 00032 #define ITMAX 200 // Maximum number of iterations 00033 #define EPS 3.0e-7 // Relative accuracy 00034 #define ZEPS 3.0e-10 // Precision around zero 00035 #define FPMIN 1.0e-30 // Number near the smallest representable number 00036 #define FPMAX 1.0e+100 // Number near the largest representable number 00037 #define TOL 1.0e-6 // Zero SVD values below this 00038 #define GOLD 0.61803399 // Golden ratio 00039 #define CGOLD 0.38196601 // Complement of golden ratio 00040 00041 inline double square(double a) 00042 { 00043 return a * a; 00044 } 00045 inline double sign(double a, double b) 00046 { 00047 return b >= 0 ? fabs(a) : -fabs(a); 00048 } 00049 inline double min(double a, double b) 00050 { 00051 return a < b ? a : b; 00052 } 00053 inline double max(double a, double b) 00054 { 00055 return a > b ? a : b; 00056 } 00057 00058 inline int square(int a) 00059 { 00060 return a * a; 00061 } 00062 inline int sign(int a, int b) 00063 { 00064 return b >= 0 ? abs(a) : -abs(a); 00065 } 00066 inline int min(int a, int b) 00067 { 00068 return a < b ? a : b; 00069 } 00070 inline int max(int a, int b) 00071 { 00072 return a > b ? a : b; 00073 } 00074 00075 // Useful integer quantities 00076 // 00077 00078 #define THIRTY_BIT_MASK 0x3FFFFFFF 00079 00080 #endif