Code covered by the BSD License  

Highlights from
quadvgk

4.5

4.5 | 3 ratings Rate this file 6 Downloads (last 30 days) File Size: 2.64 KB File ID: #18801

quadvgk

by Adam Wyatt

 

18 Feb 2008 (Updated 18 Feb 2008)

G7-K15 adaptive quadrature on vector-valued functions

| Watch this File

File Information
Description

Adaptation of quadgk for use on vector valued functions (i.e. the integral of many functions).

The input function should return a matrix of size (NF, NX) where NF is the number of integrals to calculate and NX is the number of points across each function.

This routine is as efficient as quadgk on a single function, more efficient on calculating multiple functions across the same span (provided they require similar sampling).

Consider the following problem:
E(x, L) = int(z = 0..L, fft(E(kx).*exp(i*kx.^2*z/2k)));

quadvgk allows E(kx) to be evaluated once only for every z position, thus significantly improving performance.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
quad_M;quadl_M

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
04 Nov 2011 Andreas  
04 Nov 2011 Andreas

This one worked like a charm for a couple of integrals where quadv failed (and iterating over quadgk was too slow).

The file doesn't work if you follow the example though. It should be something like:

Example:
 Y = @(x,n) 1./(bsxfun(@plus,(1:n)',x));
 Qv = quadvgk(@(x) Y(x,10), [0;1], 10)

09 Nov 2011 Andreas

Sometimes it becomes really slow (and even though it only occurs on occasion, there many, many occasions in my m-files makes it an issue). Any idea anyone?

31 Jan 2012 Dezhao

Hey Andreas, this is what I am searching for.
I runned your package with 'bsxfun'. When the vector is small (or the number of n in your example) it is OK. However when the vector is huge(let's say n>>100) the program ran out of memory. Is there a way to fix it?

01 Feb 2012 Dezhao

Hey Andreas, I solved my previous problem. However, I found the quadvgk is lower than using loops.
To make it work I used bsxfun and repmat. I think it is bsxfun and repmat that spent a lot of time. What's your opinion?

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
integration Adam Wyatt 22 Oct 2008 09:48:09
apative Adam Wyatt 22 Oct 2008 09:48:09
quadrature Adam Wyatt 22 Oct 2008 09:48:09
vector Adam Wyatt 22 Oct 2008 09:48:10
valued Adam Wyatt 22 Oct 2008 09:48:10
functions Adam Wyatt 22 Oct 2008 09:48:10
quadrature Anatoly 30 Jun 2009 12:09:22
vector Anatoly 30 Jun 2009 12:09:33
valued Anatoly 30 Jun 2009 12:09:35
vector Matthias Höller 02 Oct 2009 07:39:24
valued Matthias Höller 02 Oct 2009 07:39:31
quadrature Matthias Höller 02 Oct 2009 07:39:35
integration Matthias Höller 02 Oct 2009 07:39:37

Contact us at files@mathworks.com