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

Home » Public Forums » archive » Shortcut needed
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Shortcut needed [message #10367] Sat, 15 November 1997 00:00
williams is currently offline  williams
Messages: 7
Registered: March 1997
Junior Member
Hi fellow IDL-users,

I have a program which runs slower than I like, and wonder if someone
could help me speed it up a bit.

My data is an array of structures, call it 'a'. One element of the
structure, call it 'n' is an integer, another is a quantity which I
want to add up, call it 'x'.

There are about 100000 elements in this array. The integer n, marks
data as being of a certain type. I want to make a new array, call it
'y', which has as its nth element the sum of all the x's which have a
n-value of n. I currently do this as follows,

for n=0, n_max do begin
y[n] = total( a[where(a.n eq n)].x )
endfor

The trouble is that the loop is slow, as for loops always are. Does
anyone out there know a better way to do this kind of sorting?


Thanks,
Daniel Williams
--
+---------------------------------------------------------+
| Daniel L. Williams | Email: williams@srl.caltech.edu |
| Space Radiation Lab | Tel: 626/395-6634 |
| Caltech 220-47 | Fax: 626/449-8676 |
| Pasadena, Ca 91125 | |
| WWW: www.srl.caltech.edu/personnel/williams.html |
+---------------------------------------------------------+
[Message index]
 
Read Message
Previous Topic: complex, non-symmetric matrices
Next Topic: Re: multi-line axis titles

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

Current Time: Mon Apr 27 12:30:06 PDT 2026

Total time taken to generate the page: 0.64079 seconds