Changeset bfdfb23 in sasmodels
- Timestamp:
- Apr 26, 2016 6:10:01 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:
- e07b470
- Parents:
- fa227d3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gen_so.py
re1454ab rbfdfb23 9 9 10 10 # Convert ../sasmodels/models/name.py to name 11 model_loc = os.path.join(sasmodels, "sasmodels", "models") 12 for i in os.listdir(model_loc): 11 for model_name in core.list_models(): 13 12 # Choose only relevant python files 14 if i.endswith(".py") and not i.startswith("_"): 15 model_name = os.path.basename(i)[:-3] 16 model_info = core.load_model_info(model_name) 13 # model_info = core.load_model_info(model_name) 17 14 # Run the conversion but don't delete the .so 18 model = core. build_model(model_info)15 model = core.precompile_dll(model_name) 19 16 20 17 if __name__ == "__main__": -
sasmodels/models/lib/sas_gamma.c
rad9af31 rbfdfb23 7 7 */ 8 8 9 #ifdef tgamma 10 inline double sas_gamma( double x) { return tgamma(x+1)/x; } 11 #else 12 double _isnan(double x, double y) { return x != y; } 13 #undef isnan 14 #define isnan(x) _isnan(x, x) 9 15 10 inline double sas_gamma( double x) { return tgamma(x+1)/x; } 16 static double cephes_stirf(double x) 17 { 18 #define MAXSTIR 143.01608 19 static double SQTPI = 2.50662827463100050242E0; 20 double y, w, v; 21 22 w = 1.0 / x; 23 24 w = (((( 25 7.87311395793093628397E-4*w 26 - 2.29549961613378126380E-4)*w 27 - 2.68132617805781232825E-3)*w 28 + 3.47222221605458667310E-3)*w 29 + 8.33333333333482257126E-2)*w 30 + 1.0; 31 y = exp(x); 32 if (x > MAXSTIR) 33 { /* Avoid overflow in pow() */ 34 v = pow(x, 0.5 * x - 0.25); 35 y = v * (v / y); 36 } 37 else 38 { 39 y = pow(x, x - 0.5) / y; 40 } 41 y = SQTPI * y * w; 42 return(y); 43 } 44 45 double sas_gamma(double x) { 46 #define MAXGAM 171.624376956302725 47 static double LOGPI = 1.14472988584940017414; 48 double p, q, z; 49 int sgngam; 50 int i; 51 52 sgngam = 1; 53 if (isnan(x)) 54 return(x); 55 q = fabs(x); 56 57 if (q > 33.0) 58 { 59 if (x < 0.0) 60 { 61 p = floor(q); 62 if (p == q) 63 { 64 return (NAN); 65 } 66 i = p; 67 if ((i & 1) == 0) 68 sgngam = -1; 69 z = q - p; 70 if (z > 0.5) 71 { 72 p += 1.0; 73 z = q - p; 74 } 75 z = q * sin(M_PI * z); 76 if (z == 0.0) 77 { 78 return(NAN); 79 } 80 z = fabs(z); 81 z = M_PI / (z * cephes_stirf(q)); 82 } 83 else 84 { 85 z = cephes_stirf(x); 86 } 87 return(sgngam * z); 88 } 89 90 z = 1.0; 91 while (x >= 3.0) 92 { 93 x -= 1.0; 94 z *= x; 95 } 96 97 while (x < 0.0) 98 { 99 if (x > -1.E-9) 100 goto small; 101 z /= x; 102 x += 1.0; 103 } 104 105 while (x < 2.0) 106 { 107 if (x < 1.e-9) 108 goto small; 109 z /= x; 110 x += 1.0; 111 } 112 113 if (x == 2.0) 114 return(z); 115 116 x -= 2.0; 117 p = ((((( 118 +1.60119522476751861407E-4*x 119 + 1.19135147006586384913E-3)*x 120 + 1.04213797561761569935E-2)*x 121 + 4.76367800457137231464E-2)*x 122 + 2.07448227648435975150E-1)*x 123 + 4.94214826801497100753E-1)*x 124 + 9.99999999999999996796E-1; 125 q = (((((( 126 -2.31581873324120129819E-5*x 127 + 5.39605580493303397842E-4)*x 128 - 4.45641913851797240494E-3)*x 129 + 1.18139785222060435552E-2)*x 130 + 3.58236398605498653373E-2)*x 131 - 2.34591795718243348568E-1)*x 132 + 7.14304917030273074085E-2)*x 133 + 1.00000000000000000320E0; 134 return(z * p / q); 135 136 small: 137 if (x == 0.0) 138 { 139 return (NAN); 140 } 141 else 142 return(z / ((1.0 + 0.5772156649015329 * x) * x)); 143 } 144 #endif
Note: See TracChangeset
for help on using the changeset viewer.