comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Integrator taking vectors as input?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Integrator taking vectors as input? [message #71085] Thu, 27 May 2010 12:47
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On May 27, 2:07 pm, Elias <elias.rous...@gmail.com> wrote:

> Anyway, I did manage in the end to include a vectorized integration
> scheme in my code that uses Simpson's rule and gives an almost
> identical result as QSIMP (less than 1% difference in the worst case).
> I still havent applied it to the big dataset to see how much time I
> gain, but I am optimistic.
>

This might be the time for me to bring up again a complaint I first
made in 1997 ( http://tinyurl.com/3xyp3vp ) -- why does QSIMP require
the user supplied function to return a *scalar* result. The QSIMP
algorithm typically requires thousands of function evaluations on each
iteration, and allowing the function to compute these in a single
call can give a tremendous speedup. (My *procedure*
http://idlastro.gsfc.nasa.gov/ftp/pro/math/qsimp.pro allows the
function to return a vector result.) --Wayne
Re: Integrator taking vectors as input? [message #71086 is a reply to message #71085] Thu, 27 May 2010 11:07 Go to previous message
elias is currently offline  elias
Messages: 13
Registered: April 2005
Junior Member
On May 27, 4:35 pm, Craig Markwardt <craig.markwa...@gmail.com> wrote:
> On May 27, 2:31 am, Elias <elias.rous...@gmail.com> wrote:
>
>
>
>
>
>> On May 26, 5:18 pm, "jsch...@gmail.com" <jsch...@gmail.com> wrote:
>
>>>> I was wondering if an IDL integrator exists where it can accept
>>>> vectors instead of scalars as inputs for upper and lower limits of the
>>>> integral. I want to apply it to big datasets and I want to avoid using
>>>> loops, which tend to be much slower.
>
>>> The IDL routines like QROMB accept vector inputs as the limits.
>
>>> See the documenation (e.g.http://star.pst.qub.ac.uk/idl/QROMB.html)
>>> for details.
>
>>> Josiah
>
>> Thanks a lot,
>
>> I tried QROMB and QSIMP, the problem is that they use internally loops
>> when vectors are provided for the limits. In that case, since my
>> integrals have constants that they are dependent from the values of
>> the limits, it doesn't work, since the constants are also vectors
>> (that I pass in the function I integrate through a COMMON block).
>
>> Eg. at a single step of the internal QROMB loop, the limits are
>> scalars while the constants are vectors. Therefore the code crashes...
>
> It's really up to you.  You are really demanding a lot of an
> integrator: *no* loops and also presumably you want the result to be
> accurate.  I suspect you will need to write your own if it's that
> important to you.  Since most integrators need to subdivide the
> interval in some way - and hence use a loop - you are presumably
> limiting your accuracy that can be achieved with a single step of the
> trapezoidal rule.
>
> Craig

Craig, thanks for the answer

I understand that what I am asking is not easy, I was just wondering
if something ready existed. I was not requiring a code without loops.
I was simply considering a routine that when I give limits of eg.
lower=[a1, b1], upper =[a2, b2] and constants=[c1, c2], that these,
the discrete steps in between and the constants are passed to the
function that is to be integrated as a vector. QROMB has an internal
loop that passes first a1,a2 and then b1, b2 separately. Apart from
being more time consuming (I have to apply this to datasets of 100-200
million points (or more since the dataset grows continuously), it also
creates problems with my common block - so time is not the only issue.

Anyway, I did manage in the end to include a vectorized integration
scheme in my code that uses Simpson's rule and gives an almost
identical result as QSIMP (less than 1% difference in the worst case).
I still havent applied it to the big dataset to see how much time I
gain, but I am optimistic.

Elias
Re: Integrator taking vectors as input? [message #71089 is a reply to message #71086] Thu, 27 May 2010 07:35 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On May 27, 2:31 am, Elias <elias.rous...@gmail.com> wrote:
> On May 26, 5:18 pm, "jsch...@gmail.com" <jsch...@gmail.com> wrote:
>
>>> I was wondering if an IDL integrator exists where it can accept
>>> vectors instead of scalars as inputs for upper and lower limits of the
>>> integral. I want to apply it to big datasets and I want to avoid using
>>> loops, which tend to be much slower.
>
>> The IDL routines like QROMB accept vector inputs as the limits.
>
>> See the documenation (e.g.http://star.pst.qub.ac.uk/idl/QROMB.html)
>> for details.
>
>> Josiah
>
> Thanks a lot,
>
> I tried QROMB and QSIMP, the problem is that they use internally loops
> when vectors are provided for the limits. In that case, since my
> integrals have constants that they are dependent from the values of
> the limits, it doesn't work, since the constants are also vectors
> (that I pass in the function I integrate through a COMMON block).
>
> Eg. at a single step of the internal QROMB loop, the limits are
> scalars while the constants are vectors. Therefore the code crashes...

It's really up to you. You are really demanding a lot of an
integrator: *no* loops and also presumably you want the result to be
accurate. I suspect you will need to write your own if it's that
important to you. Since most integrators need to subdivide the
interval in some way - and hence use a loop - you are presumably
limiting your accuracy that can be achieved with a single step of the
trapezoidal rule.

Craig
Re: Integrator taking vectors as input? [message #71099 is a reply to message #71089] Wed, 26 May 2010 23:31 Go to previous message
elias is currently offline  elias
Messages: 13
Registered: April 2005
Junior Member
On May 26, 5:18 pm, "jsch...@gmail.com" <jsch...@gmail.com> wrote:
>> I was wondering if an IDL integrator exists where it can accept
>> vectors instead of scalars as inputs for upper and lower limits of the
>> integral. I want to apply it to big datasets and I want to avoid using
>> loops, which tend to be much slower.
>
> The IDL routines like QROMB accept vector inputs as the limits.
>
> See the documenation (e.g.http://star.pst.qub.ac.uk/idl/QROMB.html)
> for details.
>
> Josiah

Thanks a lot,

I tried QROMB and QSIMP, the problem is that they use internally loops
when vectors are provided for the limits. In that case, since my
integrals have constants that they are dependent from the values of
the limits, it doesn't work, since the constants are also vectors
(that I pass in the function I integrate through a COMMON block).

Eg. at a single step of the internal QROMB loop, the limits are
scalars while the constants are vectors. Therefore the code crashes...
Re: Integrator taking vectors as input? [message #71109 is a reply to message #71099] Wed, 26 May 2010 08:18 Go to previous message
jschwab@gmail.com is currently offline  jschwab@gmail.com
Messages: 30
Registered: December 2006
Member
> I was wondering if an IDL integrator exists where it can accept
> vectors instead of scalars as inputs for upper and lower limits of the
> integral. I want to apply it to big datasets and I want to avoid using
> loops, which tend to be much slower.

The IDL routines like QROMB accept vector inputs as the limits.

See the documenation (e.g. http://star.pst.qub.ac.uk/idl/QROMB.html )
for details.

Josiah
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: hieghlighting pixel
Next Topic: Confusing Error Message

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:39:43 PDT 2025

Total time taken to generate the page: 0.00554 seconds