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

Home » Public Forums » archive » Re: array indexing question
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: array indexing question [message #31433] Fri, 12 July 2002 06:35
mmiller3 is currently offline  mmiller3
Messages: 81
Registered: January 2002
Member
>>>> > "Marshall" == Marshall Perrin <mperrin> writes:

> How about just

> total( pab * alog(pag) / rebin(pa,N,N) /
> rebin(transpose(pb),N,N))

That's it!

> See the ever-popular
> http://www.dfanning.com/tips/rebin_magic.html for more
> tricks along these lines.

It has now become even more popular! Thanks :)
Re: array indexing question [message #31438 is a reply to message #31433] Thu, 11 July 2002 18:20 Go to previous message
mperrin+news is currently offline  mperrin+news
Messages: 81
Registered: May 2001
Member
Michael A. Miller <mmiller3@iupui.edu> wrote:
> I have three arrays, pa, pb and pab. pa and pb are both 1D
> arrays of length N and pab is a 2D NxN array. I want to
> calculate the sum of pab[i,j]*alog(pab[i,j])/pa[i]/pb[j]. I know
> that I can do things like total( pa * alog(pa) ) when I'm dealing
> with a single array. Any suggestions for how to do my first sum
> most efficiently?

How about just

total( pab * alog(pag) / rebin(pa,N,N) / rebin(transpose(pb),N,N))

The reform() calls turn your 1D arrays into 2D arrays, so they can
then easily be combined with the pab array. The transpose call is
needed to get the latter vector changed into a column rather than
row vector so the indices work properly.

See the ever-popular
http://www.dfanning.com/tips/rebin_magic.html
for more tricks along these lines.

- Marshall
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: changing editors?
Next Topic: Videosequence reader/writer for Weinberg speedcams

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

Current Time: Fri Nov 28 09:50:18 PST 2025

Total time taken to generate the page: 0.00791 seconds