Changeset 98cb4d7 in sasmodels
- Timestamp:
- Apr 26, 2016 11:00:14 AM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 3a45c2c, 2a55a6f
- Parents:
- e9dc7df
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernel_template.c
r0278e3f r98cb4d7 24 24 inline double isnan(double x) { return _isnan(x); } 25 25 #define NAN (std::numeric_limits<double>::quiet_NaN()) // non-signalling NaN 26 static double cephes_expm1(double x) { 27 // Adapted from the cephes math library. 28 // Copyright 1984 - 1992 by Stephen L. Moshier 29 if (x != x || x == 0.0) { 30 return x; // NaN and +/- 0 31 } else if (x < -0.5 || x > 0.5) { 32 return exp(x) - 1.0; 33 } else { 34 const double xsq = x*x; 35 const double p = ((( 36 +1.2617719307481059087798E-4)*xsq 37 +3.0299440770744196129956E-2)*xsq 38 +9.9999999999999999991025E-1); 39 const double q = (((( 40 +3.0019850513866445504159E-6)*xsq 41 +2.5244834034968410419224E-3)*xsq 42 +2.2726554820815502876593E-1)*xsq 43 +2.0000000000000000000897E0); 44 double r = x * p; 45 r = r / (q - r); 46 return r+r; 47 } 48 } 49 #define expm1 cephes_expm1 26 #define NEED_EXPM1 27 #define NEED_TGAMMA 50 28 #else 51 29 #define kernel extern "C" … … 74 52 #endif 75 53 54 #if defined(NEED_EXPM1) 55 static double expm1(double x) { 56 // Adapted from the cephes math library. 57 // Copyright 1984 - 1992 by Stephen L. Moshier 58 if (x != x || x == 0.0) { 59 return x; // NaN and +/- 0 60 } else if (x < -0.5 || x > 0.5) { 61 return exp(x) - 1.0; 62 } else { 63 const double xsq = x*x; 64 const double p = ((( 65 +1.2617719307481059087798E-4)*xsq 66 +3.0299440770744196129956E-2)*xsq 67 +9.9999999999999999991025E-1); 68 const double q = (((( 69 +3.0019850513866445504159E-6)*xsq 70 +2.5244834034968410419224E-3)*xsq 71 +2.2726554820815502876593E-1)*xsq 72 +2.0000000000000000000897E0); 73 double r = x * p; 74 r = r / (q - r); 75 return r+r; 76 } 77 } 78 #endif 79 76 80 // Standard mathematical constants: 77 81 // M_E, M_LOG2E, M_LOG10E, M_LN2, M_LN10, M_PI, M_PI_2=pi/2, M_PI_4=pi/4, -
sasmodels/models/lib/sas_gamma.c
re9dc7df r98cb4d7 1 1 /* 2 2 The wrapper for gamma function from OpenCL and standard libraries 3 The OpenCL gamma function fails mis serably on values lower than 1.03 The OpenCL gamma function fails miserably on values lower than 1.0 4 4 while works fine on larger values. 5 5 We use gamma definition Gamma(t + 1) = t * Gamma(t) to compute … … 7 7 */ 8 8 9 #ifdef tgamma 10 inline double sas_gamma( double x) { return tgamma(x+1)/x; } 11 #else 9 #if defined(NEED_TGAMMA) 12 10 static double cephes_stirf(double x) 13 11 { … … 39 37 } 40 38 41 double sas_gamma(double x) {39 static double tgamma(double x) { 42 40 double p, q, z; 43 41 int sgngam; … … 137 135 } 138 136 #endif 137 138 139 inline double sas_gamma( double x) { return tgamma(x+1)/x; }
Note: See TracChangeset
for help on using the changeset viewer.