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

Home » Public Forums » archive » Re: confused multiplying arrays
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: confused multiplying arrays [message #73469] Thu, 11 November 2010 16:49
MC is currently offline  MC
Messages: 50
Registered: September 1996
Member
On Nov 12, 10:11 am, Paula <paulartcoe...@gmail.com> wrote:
> hello,
>
> i've got two arrays:
>
> IDL> help,area,fluxes
> AREA            FLOAT     = Array[2000]
> FLUXES          FLOAT     = Array[2000, 112864]
>
> I want the i-th element in area AREA[i] to multiply all elements in
> the corresponding 2nd dimension in fluxes FLUXES[i,*] and then sum up
> all the 2000 resulting fluxes, i.e., using loop:
>
> for i = 0,1999 do begin
>      TOTAL_FLUX = TOTAL_FLUX + AREA[i]*reform(FLUXES[i,*])
> endfor
>
> i've been trying to figure out (without success) how to compute
> TOTAL_FLUX without the loop using TOTAL(). ideas?
>
> thx
> p.

Perhaps I've missed something, but isn't it just Area#Fluxes ?

Cheers
Re: confused multiplying arrays [message #73477 is a reply to message #73469] Thu, 11 November 2010 13:47 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Nov 11, 7:41 pm, Paula <paulartcoe...@gmail.com> wrote:

>> total_flux=total(rebin(area,100,112864)*fluxes,1)
>
> hmmm...
> why the '100' in rebin(area,100,112864) ?
>
> p.

Because i wrote it wrong. I meant

total_flux=total(rebin(area,2000,112864)*fluxes,1)
Re: confused multiplying arrays [message #73478 is a reply to message #73477] Thu, 11 November 2010 13:46 Go to previous message
paulartcoelho is currently offline  paulartcoelho
Messages: 30
Registered: March 2007
Member
On Nov 11, 7:41 pm, Paula <paulartcoe...@gmail.com> wrote:
>> total_flux=total(rebin(area,100,112864)*fluxes,1)
>
> hmmm...
> why the '100' in rebin(area,100,112864) ?

thinking about it... it would be then

total_flux=total(rebin(area,2000,112864)*fluxes,1)

right?
Re: confused multiplying arrays [message #73479 is a reply to message #73478] Thu, 11 November 2010 13:41 Go to previous message
paulartcoelho is currently offline  paulartcoelho
Messages: 30
Registered: March 2007
Member
On Nov 11, 7:33 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
>
> If I understand it right, you want total_flux to be a 112864-element
> array, where each is the sum of all 2000 elements in the corresponding
> line of fluxes, weighted by area.

absolutely right.

> total_flux=total(rebin(area,100,112864)*fluxes,1)

hmmm...
why the '100' in rebin(area,100,112864) ?

p.
Re: confused multiplying arrays [message #73480 is a reply to message #73479] Thu, 11 November 2010 13:33 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Nov 11, 7:11 pm, Paula <paulartcoe...@gmail.com> wrote:
> IDL> help,area,fluxes
> AREA            FLOAT     = Array[2000]
> FLUXES          FLOAT     = Array[2000, 112864]
>
> I want the i-th element in area AREA[i] to multiply all elements in
> the corresponding 2nd dimension in fluxes FLUXES[i,*] and then sum up
> all the 2000 resulting fluxes, i.e., using loop:
>
> for i = 0,1999 do begin
>      TOTAL_FLUX = TOTAL_FLUX + AREA[i]*reform(FLUXES[i,*])
> endfor
>
> i've been trying to figure out (without success) how to compute
> TOTAL_FLUX without the loop using TOTAL(). ideas?

If I understand it right, you want total_flux to be a 112864-element
array, where each is the sum of all 2000 elements in the corresponding
line of fluxes, weighted by area. So, if there is enough memory, it
could be done with

total_flux=total(rebin(area,100,112864)*fluxes,1)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Another issue with the garbage collector?
Next Topic: Re: Write a vector into a file

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

Current Time: Sat Oct 11 03:54:54 PDT 2025

Total time taken to generate the page: 0.88026 seconds