Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:00:57

0001 /* gsl_minmax.h
0002  * 
0003  * Copyright (C) 2008 Gerard Jungman, Brian Gough
0004  * 
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 3 of the License, or (at
0008  * your option) any later version.
0009  * 
0010  * This program is distributed in the hope that it will be useful, but
0011  * WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * General Public License for more details.
0014  * 
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef __GSL_MINMAX_H__
0021 #define __GSL_MINMAX_H__
0022 #include <gsl/gsl_inline.h>
0023 
0024 #undef __BEGIN_DECLS
0025 #undef __END_DECLS
0026 #ifdef __cplusplus
0027 # define __BEGIN_DECLS extern "C" {
0028 # define __END_DECLS }
0029 #else
0030 # define __BEGIN_DECLS /* empty */
0031 # define __END_DECLS /* empty */
0032 #endif
0033 
0034 __BEGIN_DECLS
0035 
0036 /* Define MAX and MIN macros/functions if they don't exist. */
0037 
0038 /* plain old macros for general use */
0039 #define GSL_MAX(a,b) ((a) > (b) ? (a) : (b))
0040 #define GSL_MIN(a,b) ((a) < (b) ? (a) : (b))
0041 
0042 /* function versions of the above, in case they are needed */
0043 double gsl_max (double a, double b);
0044 double gsl_min (double a, double b);
0045 
0046 /* inline-friendly strongly typed versions */
0047 #ifdef HAVE_INLINE
0048 
0049 INLINE_FUN int GSL_MAX_INT (int a, int b);
0050 INLINE_FUN int GSL_MIN_INT (int a, int b);
0051 INLINE_FUN double GSL_MAX_DBL (double a, double b);
0052 INLINE_FUN double GSL_MIN_DBL (double a, double b);
0053 INLINE_FUN long double GSL_MAX_LDBL (long double a, long double b);
0054 INLINE_FUN long double GSL_MIN_LDBL (long double a, long double b);
0055 
0056 INLINE_FUN int
0057 GSL_MAX_INT (int a, int b)
0058 {
0059   return GSL_MAX (a, b);
0060 }
0061 
0062 INLINE_FUN int
0063 GSL_MIN_INT (int a, int b)
0064 {
0065   return GSL_MIN (a, b);
0066 }
0067 
0068 INLINE_FUN double
0069 GSL_MAX_DBL (double a, double b)
0070 {
0071   return GSL_MAX (a, b);
0072 }
0073 
0074 INLINE_FUN double
0075 GSL_MIN_DBL (double a, double b)
0076 {
0077   return GSL_MIN (a, b);
0078 }
0079 
0080 INLINE_FUN long double
0081 GSL_MAX_LDBL (long double a, long double b)
0082 {
0083   return GSL_MAX (a, b);
0084 }
0085 
0086 INLINE_FUN long double
0087 GSL_MIN_LDBL (long double a, long double b)
0088 {
0089   return GSL_MIN (a, b);
0090 }
0091 #else
0092 #define GSL_MAX_INT(a,b)   GSL_MAX(a,b)
0093 #define GSL_MIN_INT(a,b)   GSL_MIN(a,b)
0094 #define GSL_MAX_DBL(a,b)   GSL_MAX(a,b)
0095 #define GSL_MIN_DBL(a,b)   GSL_MIN(a,b)
0096 #define GSL_MAX_LDBL(a,b)  GSL_MAX(a,b)
0097 #define GSL_MIN_LDBL(a,b)  GSL_MIN(a,b)
0098 #endif /* HAVE_INLINE */
0099 
0100 __END_DECLS
0101 
0102 #endif /* __GSL_POW_INT_H__ */