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

Home » Public Forums » archive » Re: row calculation in a 2D array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: row calculation in a 2D array [message #12587] Wed, 26 August 1998 00:00 Go to previous message
Alex Schuster is currently offline  Alex Schuster
Messages: 124
Registered: February 1997
Senior Member
Jonas wrote:

> This was kind of a special example since total could do all the work. What
> if I would like to do another calculation where total is not applicable...
> in other words:
> is there generally an easy way to perform the same calculation over all the
> (sub-)rows in a in a 2D array?

Calculating the average of each row could be done by matrix
multiplication:

a = findgen( 10, 10 )
b = reform( fltarr( 10 ) + 1, 1, 10 )
average = reform( b # a / 10 )
print, average

4.50000 14.5000 24.5000 34.5000 44.5000
54.5000
64.5000 74.5000 84.5000 94.5000

Other things would be more difficult, though, and sometimes you just
cannot avoid loops.


Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: What is going on with the minor ticks on log plots?????
Next Topic: Boundary Chain Code

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

Current Time: Sun Oct 12 12:14:51 PDT 2025

Total time taken to generate the page: 1.20147 seconds