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

Home » Public Forums » archive » A case where FOR loops are unavoidable?
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
A case where FOR loops are unavoidable? [message #51577] Mon, 27 November 2006 14:19
gknoke is currently offline  gknoke
Messages: 9
Registered: September 2006
Junior Member
Hi all, I'm trying to setup an array for the computation of a rather
tricky multidimensional function, but I'm seeing no way around using
FOR loops in its creation. I've been trying to figure out an
appropriate vector solution, but so far I'm drawing a blank.

The equation goes as follows:

f(x, b1, b2, p) = alog((1/b1)*(1-p)*exp(-x/b1) + (1/b2)*p*exp(-x/b2))

Here x is a vector roughly of length 2^20, b1 and b2 are roughly
100-1000 elements, and p is roughly 10-50 elements. I realize that
this is a larger array than is likely to fit in memory, but what I'm
really after is the sum of this function in the x dimension, i.e. the
final output should be something like:

f_out(b1,b2,p) = total(f(x,b1,b2,p), 1)

My approach to this is to loop over b1, b2, and p to take advantage of
being able to use the total function to keep the array size manageable,
like so:

for k=1,np
for i=1,nb1
for j=1,nb2
f_out(i,j,k) = total(f(x, b1[i], b2[j], p[k]), 1)
etc. etc.

This works, but I'm wondering if there are any better approaches?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: GUI size on different screens
Next Topic: Re: A case where FOR loops are unavoidable?

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

Current Time: Wed Oct 08 15:52:55 PDT 2025

Total time taken to generate the page: 0.00526 seconds