Changeset 8ff5cb3 in sasview for sansmodels/src/sans/models
- Timestamp:
- Dec 14, 2011 3:26:29 PM (13 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:
- 96814e1
- Parents:
- 5d75d65a
- Location:
- sansmodels/src/sans/models/c_extensions
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/c_extensions/libmultifunc/librefl.c
rb9765ad r8ff5cb3 21 21 22 22 23 complex c add(x,y)23 complex cplx_add(x,y) 24 24 complex x,y; 25 25 { … … 40 40 } 41 41 42 complex c sub(x,y)42 complex cplx_sub(x,y) 43 43 complex x,y; 44 44 { … … 50 50 51 51 52 complex c mult(x,y)52 complex cplx_mult(x,y) 53 53 complex x,y; 54 54 { … … 59 59 } 60 60 61 complex c div(x,y)61 complex cplx_div(x,y) 62 62 complex x,y; 63 63 { … … 68 68 } 69 69 70 complex c exp(b)70 complex cplx_exp(b) 71 71 complex b; 72 72 { … … 81 81 82 82 83 complex c sqrt(z) //see Schaum`s Math Handbook p. 22, 6.6 and 6.1083 complex cplx_sqrt(z) //see Schaum`s Math Handbook p. 22, 6.6 and 6.10 84 84 complex z; 85 85 { … … 124 124 } 125 125 126 complex c cos(b)126 complex cplx_cos(b) 127 127 complex b; 128 128 { … … 131 131 two = cassign(2.0,0.0); 132 132 i = cassign(0.0,1.0); 133 bi = c mult(b,i);134 negbi = c sub(zero,bi);135 z = c div(cadd(cexp(bi),cexp(negbi)),two);133 bi = cplx_mult(b,i); 134 negbi = cplx_sub(zero,bi); 135 z = cplx_div(cplx_add(cplx_exp(bi),cplx_exp(negbi)),two); 136 136 return z; 137 137 } -
sansmodels/src/sans/models/c_extensions/libmultifunc/librefl.h
ra24f530 r8ff5cb3 16 16 complex cassign(double real, double imag); 17 17 18 complex c add(complex x,complex y);18 complex cplx_add(complex x,complex y); 19 19 20 20 complex rcmult(double x,complex y); 21 21 22 complex c sub(complex x,complex y);22 complex cplx_sub(complex x,complex y); 23 23 24 complex c mult(complex x,complex y);24 complex cplx_mult(complex x,complex y); 25 25 26 complex c div(complex x,complex y);26 complex cplx_div(complex x,complex y); 27 27 28 complex c exp(complex b);28 complex cplx_exp(complex b); 29 29 30 complex c sqrt(complex z);30 complex cplx_sqrt(complex z); 31 31 32 complex c cos(complex b);32 complex cplx_cos(complex b); 33 33 34 34 double intersldfunc(int fun_type, double n_sub, double i, double nu, double sld_l, double sld_r); -
sansmodels/src/sans/models/c_extensions/refl.c
r33aea7f r8ff5cb3 69 69 70 70 phi = asin(lamda*q/(4.0*pi)); 71 phi1 = c div(rcmult(phi,one),n_sup);72 alpha = c mult(n_sup,ccos(phi1));73 alpha2 = c mult(alpha,alpha);71 phi1 = cplx_div(rcmult(phi,one),n_sup); 72 alpha = cplx_mult(n_sup,cplx_cos(phi1)); 73 alpha2 = cplx_mult(alpha,alpha); 74 74 75 75 nnp1=n_sub; 76 knp1=c sqrt(rcmult(ko2,csub(cmult(nnp1,nnp1),alpha2))); //nnp1*ko*sin(phinp1)76 knp1=cplx_sqrt(rcmult(ko2,cplx_sub(cplx_mult(nnp1,nnp1),alpha2))); //nnp1*ko*sin(phinp1) 77 77 Xnp1=cassign(0.0,0.0); 78 78 dz = 0.0; … … 102 102 } 103 103 nn = cassign(1.0-sld_i*pow(lamda,2.0)/(2.0*pi),0.0); 104 nn2=c mult(nn,nn);105 106 kn=c sqrt(rcmult(ko2,csub(nn2,alpha2))); //nn*ko*sin(phin)107 an=c exp(rcmult(dz,cmult(two,kn)));108 109 fnm=c sub(kn,knp1);110 fnp=c add(kn,knp1);111 rn=c div(fnm,fnp);112 Xn=c mult(an,cdiv(cadd(rn,Xnp1),cadd(one,cmult(rn,Xnp1)))); //Xn=an*((rn+Xnp1*anp1)/(1+rn*Xnp1*anp1))104 nn2=cplx_mult(nn,nn); 105 106 kn=cplx_sqrt(rcmult(ko2,cplx_sub(nn2,alpha2))); //nn*ko*sin(phin) 107 an=cplx_exp(rcmult(dz,cplx_mult(two,kn))); 108 109 fnm=cplx_sub(kn,knp1); 110 fnp=cplx_add(kn,knp1); 111 rn=cplx_div(fnm,fnp); 112 Xn=cplx_mult(an,cplx_div(cplx_add(rn,Xnp1),cplx_add(one,cplx_mult(rn,Xnp1)))); //Xn=an*((rn+Xnp1*anp1)/(1+rn*Xnp1*anp1)) 113 113 114 114 Xnp1=Xn; -
sansmodels/src/sans/models/c_extensions/refl_adv.c
ra24f530 r8ff5cb3 83 83 84 84 phi = asin(lamda*q/(4.0*pi)); 85 phi1 = c div(rcmult(phi,one),n_sup);86 alpha = c mult(n_sup,ccos(phi1));87 alpha2 = c mult(alpha,alpha);85 phi1 = cplx_div(rcmult(phi,one),n_sup); 86 alpha = cplx_mult(n_sup,cplx_cos(phi1)); 87 alpha2 = cplx_mult(alpha,alpha); 88 88 89 89 nnp1=n_sub; 90 knp1=c sqrt(rcmult(ko2,csub(cmult(nnp1,nnp1),alpha2))); //nnp1*ko*sin(phinp1)90 knp1=cplx_sqrt(rcmult(ko2,cplx_sub(cplx_mult(nnp1,nnp1),alpha2))); //nnp1*ko*sin(phinp1) 91 91 Xnp1=cassign(0.0,0.0); 92 92 dz = 0.0; … … 124 124 } 125 125 nn = cassign(1.0-sld_i*pow(lamda,2.0)/(2.0*pi),pow(lamda,2.0)/(2.0*pi)*sldim_i); 126 nn2=c mult(nn,nn);127 128 kn=c sqrt(rcmult(ko2,csub(nn2,alpha2))); //nn*ko*sin(phin)129 an=c exp(rcmult(dz,cmult(two,kn)));130 131 fnm=c sub(kn,knp1);132 fnp=c add(kn,knp1);133 rn=c div(fnm,fnp);134 Xn=c mult(an,cdiv(cadd(rn,Xnp1),cadd(one,cmult(rn,Xnp1)))); //Xn=an*((rn+Xnp1*anp1)/(1+rn*Xnp1*anp1))126 nn2=cplx_mult(nn,nn); 127 128 kn=cplx_sqrt(rcmult(ko2,cplx_sub(nn2,alpha2))); //nn*ko*sin(phin) 129 an=cplx_exp(rcmult(dz,cplx_mult(two,kn))); 130 131 fnm=cplx_sub(kn,knp1); 132 fnp=cplx_add(kn,knp1); 133 rn=cplx_div(fnm,fnp); 134 Xn=cplx_mult(an,cplx_div(cplx_add(rn,Xnp1),cplx_add(one,cplx_mult(rn,Xnp1)))); //Xn=an*((rn+Xnp1*anp1)/(1+rn*Xnp1*anp1)) 135 135 136 136 Xnp1=Xn;
Note: See TracChangeset
for help on using the changeset viewer.