• Home
  • Introduction
  • Software
  • About me

Looking At Nothing

A SA(X)S Weblog

Category:

  • Clear Presentation Initiative
  • LookingAtNothing Weblog
  • Matlab
  • misc.
  • Movies
  • Paper review
  • Papers
  • Particle size distribution
  • Posters
  • Pushbutton machines
  • sampleholder design
  • SAXSGUI software
  • software
  • Uncategorized

Archives:

  • August 2010
  • July 2010
  • June 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • February 2009
  • November 2008
  • October 2008
  • July 2008
  • May 2008
  • February 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007

Blogroll:

  • Nico Adams
  • Presentation zen

Meta:

  • RSS
  • Comments RSS
  • Valid XHTML
  • XFN

The bessel function approximation, compiled

February 16th, 2010 by Brian

With the help of Michael Croucher of the walkingrandomly weblog, who graciously spent some time optimising one of the slowest components of the Matlab code, we were able to come up with an approximation to the Bessel function which was about two times faster than Matlab’s internal function. However, then I had to smoothen out the crossover point using error functions, and now it has lost some of the speed it had gained in favour of smoothness. It is now about 40% faster than Matlab’s Bessel function, when approximated using only 5 polynomial terms.

It looks like this, with the crossover gradient centre at 4.5:

bessel_vs_approx

So there remains a small discrepancy for such low polynomial numbers, but it should be possible to obtain a good speed increase with this in cylinder and disk scattering functions. Please grab yourself a copy of the code, and I’ll be happy (albeit perhaps slow in the coming two weeks) to include more improvements!

bessel_li_gross

p.s.: I forgot to mention how to compile the code for your computer. At this point, there’s a compiled version available for intel Macs. If you do not have that one, but you do have the matlab (”mex”) compiler, I suggest you follow the following steps:

1. make sure your mex compiler can find the following include files: mex.h, math.h, omp.h (in my case, I copied a suitable version of omp.h into the bessel_li_gross directory

2. go to the bessel_li_gross directory and type “mex blg_component.c”, or if your compiler complains about not being able to find the omp.h file that you just put in the directory: “mex -I./ blg_component.c” (adds the current path to the search path for files under unix)

3. Play. You can also send me your .mex file so I can add it to the package.

Posted in Matlab, software | No Comments

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

 
Wordpress Themes by and Website Templates by Blogcut