Optimizing computing double integrals by elementwise matrix operations
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I wrote my own function to calculate the double integral of a function, here referred to as 'fun(x,y)' between the boundaries x=[a,b] and y=[c,d]:
--------
function [ I ] = mydblquad( fun,a, b, c, d )
%MYDBLQUAD Summary of this function goes here
% Detailed explanation goes here
myquad = @(fun_int,a,b,tol,trace,varargin)quadgk(@(x)fun_int(x,varargin{:}),a,b,'AbsTol',tol);
I=dblquad(fun,a,b,c,d,1e-5,myquad);
end
---------
However, as the function I have to integrate is also function of two parameters 'n' and 'm', and as I have to compute this integral over a big set of values for 'n' and 'm', it becomes computationally ineffecient to compute all the integrals in two for-loops over 'n' and 'm'. Is there another possibility, such as computing dblquad not on one function, but on a set of functions arranged in a matrix depeding on 'n' and 'm'? A first try-out did not work.
What I would like to get is something like: I( n x m ) = mydblquad ( F( n x m) ), whereby you integrate over x and y
Thanks,
Bart
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Bart Boesman
am 16 Aug. 2012
1 Kommentar
Mike Hosea
am 21 Aug. 2012
Bearbeitet: Mike Hosea
am 21 Aug. 2012
What you are trying to do requires a lot of work, and it is going to take some time. The computational efficiency of loops is NOT the problem. The problem is the problem. You can't speed this sort of thing up by vectorizing it. You can, however speed it up by parallelizing it, and it sounds to me like your problem is what we call "embarrassingly parallel".
Siehe auch
Kategorien
Mehr zu Mathematics and Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!