Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /* gsl_math.h
0002  * 
0003  * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004, 2007 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_MATH_H__
0021 #define __GSL_MATH_H__
0022 #include <math.h>
0023 #include <gsl/gsl_sys.h>
0024 #include <gsl/gsl_inline.h>
0025 #include <gsl/gsl_machine.h>
0026 #include <gsl/gsl_precision.h>
0027 #include <gsl/gsl_nan.h>
0028 #include <gsl/gsl_pow_int.h>
0029 #include <gsl/gsl_minmax.h>
0030 
0031 #ifndef M_E
0032 #define M_E        2.71828182845904523536028747135      /* e */
0033 #endif
0034 
0035 #ifndef M_LOG2E
0036 #define M_LOG2E    1.44269504088896340735992468100      /* log_2 (e) */
0037 #endif
0038 
0039 #ifndef M_LOG10E
0040 #define M_LOG10E   0.43429448190325182765112891892      /* log_10 (e) */
0041 #endif
0042 
0043 #ifndef M_SQRT2
0044 #define M_SQRT2    1.41421356237309504880168872421      /* sqrt(2) */
0045 #endif
0046 
0047 #ifndef M_SQRT1_2
0048 #define M_SQRT1_2  0.70710678118654752440084436210      /* sqrt(1/2) */
0049 #endif
0050 
0051 
0052 #ifndef M_SQRT3
0053 #define M_SQRT3    1.73205080756887729352744634151      /* sqrt(3) */
0054 #endif
0055 
0056 #ifndef M_PI
0057 #define M_PI       3.14159265358979323846264338328      /* pi */
0058 #endif
0059 
0060 #ifndef M_PI_2
0061 #define M_PI_2     1.57079632679489661923132169164      /* pi/2 */
0062 #endif
0063 
0064 #ifndef M_PI_4
0065 #define M_PI_4     0.78539816339744830961566084582     /* pi/4 */
0066 #endif
0067 
0068 #ifndef M_SQRTPI
0069 #define M_SQRTPI   1.77245385090551602729816748334      /* sqrt(pi) */
0070 #endif
0071 
0072 #ifndef M_2_SQRTPI
0073 #define M_2_SQRTPI 1.12837916709551257389615890312      /* 2/sqrt(pi) */
0074 #endif
0075 
0076 #ifndef M_1_PI
0077 #define M_1_PI     0.31830988618379067153776752675      /* 1/pi */
0078 #endif
0079 
0080 #ifndef M_2_PI
0081 #define M_2_PI     0.63661977236758134307553505349      /* 2/pi */
0082 #endif
0083 
0084 #ifndef M_LN10
0085 #define M_LN10     2.30258509299404568401799145468      /* ln(10) */
0086 #endif
0087 
0088 #ifndef M_LN2
0089 #define M_LN2      0.69314718055994530941723212146      /* ln(2) */
0090 #endif
0091 
0092 #ifndef M_LNPI
0093 #define M_LNPI     1.14472988584940017414342735135      /* ln(pi) */
0094 #endif
0095 
0096 #ifndef M_EULER
0097 #define M_EULER    0.57721566490153286060651209008      /* Euler constant */
0098 #endif
0099 
0100 #undef __BEGIN_DECLS
0101 #undef __END_DECLS
0102 #ifdef __cplusplus
0103 # define __BEGIN_DECLS extern "C" {
0104 # define __END_DECLS }
0105 #else
0106 # define __BEGIN_DECLS /* empty */
0107 # define __END_DECLS /* empty */
0108 #endif
0109 
0110 __BEGIN_DECLS
0111 
0112 /* other needlessly compulsive abstractions */
0113 
0114 #define GSL_IS_ODD(n)  ((n) & 1)
0115 #define GSL_IS_EVEN(n) (!(GSL_IS_ODD(n)))
0116 #define GSL_SIGN(x)    ((x) >= 0.0 ? 1 : -1)
0117 
0118 /* Return nonzero if x is a real number, i.e. non NaN or infinite. */
0119 #define GSL_IS_REAL(x) (gsl_finite(x))
0120 
0121 /* Definition of an arbitrary function with parameters */
0122 
0123 struct gsl_function_struct 
0124 {
0125   double (* function) (double x, void * params);
0126   void * params;
0127 };
0128 
0129 typedef struct gsl_function_struct gsl_function ;
0130 
0131 #define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
0132 
0133 /* Definition of an arbitrary function returning two values, r1, r2 */
0134 
0135 struct gsl_function_fdf_struct 
0136 {
0137   double (* f) (double x, void * params);
0138   double (* df) (double x, void * params);
0139   void (* fdf) (double x, void * params, double * f, double * df);
0140   void * params;
0141 };
0142 
0143 typedef struct gsl_function_fdf_struct gsl_function_fdf ;
0144 
0145 #define GSL_FN_FDF_EVAL_F(FDF,x) (*((FDF)->f))(x,(FDF)->params)
0146 #define GSL_FN_FDF_EVAL_DF(FDF,x) (*((FDF)->df))(x,(FDF)->params)
0147 #define GSL_FN_FDF_EVAL_F_DF(FDF,x,y,dy) (*((FDF)->fdf))(x,(FDF)->params,(y),(dy))
0148 
0149 
0150 /* Definition of an arbitrary vector-valued function with parameters */
0151 
0152 struct gsl_function_vec_struct 
0153 {
0154   int (* function) (double x, double y[], void * params);
0155   void * params;
0156 };
0157 
0158 typedef struct gsl_function_vec_struct gsl_function_vec ;
0159 
0160 #define GSL_FN_VEC_EVAL(F,x,y) (*((F)->function))(x,y,(F)->params)
0161 
0162 __END_DECLS
0163 
0164 #endif /* __GSL_MATH_H__ */