im writing a programm for a fitting routine and am currently optimizing the code for faster calculations. The weakes point is a part, where i have to calculate a big amount of bessel functions, which takes around 0.7 s. In my case q has 177 entries, th 100 and R 400.
Js = zeros(numel(th),numel(q)); tR=sin(th')*R;
for k = 1:numel(q)
Js(:,k) = sum(tn.*besselj(0,q(k)*tR),2);
end
I also tried to make a 3D-Matrix, but it takes slightly longer to calculate.
[Q,T,RR]=meshgrid(q,sin(th),R);
Js1 = besselj(0,Q.*T.*RR);
So, i'm wondering, is there a way to calculate these besselfunctions faster? thanks in advance, kuy