Changeset 98cb4d7 in sasmodels for sasmodels/kernel_template.c


Ignore:
Timestamp:
Apr 26, 2016 11:00:14 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
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
Message:

only define tgamma when compiling for MSVC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernel_template.c

    r0278e3f r98cb4d7  
    2424         inline double isnan(double x) { return _isnan(x); } 
    2525         #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 
    5028     #else 
    5129         #define kernel extern "C" 
     
    7452#endif 
    7553 
     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 
    7680// Standard mathematical constants: 
    7781//   M_E, M_LOG2E, M_LOG10E, M_LN2, M_LN10, M_PI, M_PI_2=pi/2, M_PI_4=pi/4, 
Note: See TracChangeset for help on using the changeset viewer.