Ignore:
Timestamp:
Jul 25, 2011 3:43:34 PM (13 years ago)
Author:
Jae Cho <jhjcho@…>
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:
bc7bc839
Parents:
38155f7
Message:

implementation of pearlneckclace model: need utest and doc

Location:
sansmodels/src/sans/models/c_extensions/libmultifunc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_extensions/libmultifunc/libfunc.c

    r8c8cb05 r463eb76e  
     1// by jcho 
    12#include <math.h> 
    23#include "libmultifunc/libfunc.h" 
     
    1920 
    2021// Used in pearl nec model 
    21 //integral of sin(x)/x up to namx term nmax>10 looks fine. 
    22 double Si(double x, int nmax ) 
     22// Sine integral function: approximated within 1%!!! 
     23// integral of sin(x)/x up to namx term nmax=6 looks the best. 
     24double Si(double x) 
    2325{ 
    2426        int i; 
     27        int nmax=6; 
    2528        double out; 
    2629        long double power; 
    27         if (x > 5.0){ 
    28                 double pi = 4.0*atan(1.0); 
    29                 return pi/2.0; 
     30        double pi = 4.0*atan(1.0); 
     31        if (x >= pi*6.2/4.0){ 
     32 
     33                double out_sin = 0.0; 
     34                double out_cos = 0.0; 
     35                out = pi/2.0; 
     36                for (i=0; i<nmax-2; i+=1){ 
     37                        out_cos += pow(-1.0, i) * (double)factorial(2*i) / pow(x, 2*i+1); 
     38                        out_sin += pow(-1.0, i) * (double)factorial(2*i+1) / pow(x, 2*i+2); 
     39                } 
     40                out -= cos(x) * out_cos; 
     41                out -= sin(x) * out_sin; 
     42                return out; 
    3043        } 
    3144        out = 0.0; 
     
    4356} 
    4457 
    45 double sin_x(double x) 
     58double sinc(double x) 
    4659{ 
    4760        if (x==0){ 
  • sansmodels/src/sans/models/c_extensions/libmultifunc/libfunc.h

    r8c8cb05 r463eb76e  
    44int factorial(int i); 
    55 
    6 double Si(double x, int nmax ); 
     6double Si(double x); 
    77 
    8 double sin_x(double x); 
     8double sinc(double x); 
    99 
    1010#endif 
Note: See TracChangeset for help on using the changeset viewer.