Changeset f8644dd in sasview for sansmodels
- Timestamp:
- Jul 9, 2012 9:57:01 AM (12 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 14e4804
- Parents:
- a269378
- Location:
- sansmodels/src/c_models
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/c_models/dabmodel.cpp
rfa6db8b rf8644dd 47 47 48 48 double DABModel::calculate_ER() { 49 // not implemented yet 49 50 return 0.0; 50 51 } 51 52 52 53 double DABModel::calculate_VR() { 53 return 0.0;54 return 1.0; 54 55 } 55 56 56 57 double DABModel::evaluate_rphi(double q,double phi) { 57 return 1.0; 58 double qx = q * cos(phi); 59 double qy = q * sin(phi); 60 return this->operator()(qx,qy); 58 61 } -
sansmodels/src/c_models/libfunc.c
r08648c0 rf8644dd 1 1 // by jcho 2 2 3 #include <math.h> 4 3 5 #include "libmultifunc/libfunc.h" 6 4 7 #include <stdio.h> 5 8 9 10 6 11 //used in Si func 12 7 13 int factorial(int i) 14 8 15 { 16 9 17 int k, j; 18 10 19 if (i<2){ 20 11 21 return 1; 22 12 23 } 24 13 25 k=1; 26 14 27 for(j=1;j<i;j++) 28 15 29 { 30 16 31 k=k*(j+1); 32 17 33 } 34 18 35 return k; 36 19 37 } 20 38 39 40 21 41 // Used in pearl nec model 42 22 43 // Sine integral function: approximated within 1%!!! 44 23 45 // integral of sin(x)/x up to namx term nmax=6 looks the best. 46 24 47 double Si(double x) 48 25 49 { 50 26 51 int i; 52 27 53 int nmax=6; 54 28 55 double out; 56 29 57 long double power; 58 30 59 double pi = 4.0*atan(1.0); 60 31 61 if (x >= pi*6.2/4.0){ 32 62 63 64 33 65 double out_sin = 0.0; 66 34 67 double out_cos = 0.0; 68 35 69 out = pi/2.0; 70 36 71 for (i=0; i<nmax-2; i+=1){ 72 37 73 out_cos += pow(-1.0, i) * (double)factorial(2*i) / pow(x, 2*i+1); 74 38 75 out_sin += pow(-1.0, i) * (double)factorial(2*i+1) / pow(x, 2*i+2); 76 39 77 } 78 40 79 out -= cos(x) * out_cos; 80 41 81 out -= sin(x) * out_sin; 82 42 83 return out; 84 43 85 } 86 44 87 out = 0.0; 88 45 89 for (i=0; i<nmax; i+=1) 90 46 91 { 92 47 93 if (i==0){ 94 48 95 out += x; 96 49 97 continue; 98 50 99 } 100 51 101 power = pow(x,(2 * i + 1)); 102 52 103 out += (double)pow(-1, i) * power / ((2.0 * (double)i + 1.0) * (double)factorial(2 * i + 1)); 104 53 105 //printf ("Si=%g %g %d\n", x, out, i); 106 54 107 } 108 55 109 return out; 110 56 111 } 112 113 57 114 58 115 double sinc(double x) 59 116 { 60 61 62 63 117 if (x==0.0){ 118 return 1.0; 119 } 120 return sin(x)/x; 64 121 } 122 65 123 66 124 double gamln(double xx) { … … 79 137 return -tmp+log(2.5066282746310005*ser/x); 80 138 } 139 -
sansmodels/src/c_models/teubner_strey.cpp
ra269378 rf8644dd 38 38 39 39 double TeubnerStreyModel::calculate_ER() { 40 // not implemented yet 40 41 return 0.0; 41 42 } 42 43 43 44 double TeubnerStreyModel::calculate_VR() { 44 return 0.0;45 return 1.0; 45 46 } 46 47 47 48 double TeubnerStreyModel::evaluate_rphi(double q,double phi) { 48 return 1.0; 49 double qx = q*cos(phi); 50 double qy = q*sin(phi); 51 return this->operator()(qx, qy); 49 52 } 53 50 54 51 55
Note: See TracChangeset
for help on using the changeset viewer.