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

Home » Public Forums » archive » Re: Sum of elements in an 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: Sum of elements in an array [message #2324 is a reply to message #2305] Thu, 09 June 1994 05:17 Go to previous message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <2t6tb9$ftb@due.uninett.no>, ragnar@kvark.fi.uib.no (Ragnar Aas) writes:
|> I'm working on a project where I need to sum the result of many IF-statements.
|> In order to make this operation faster, I want to vectorize it. The way I
|> want it is :
|>
|> sum=(array_1.element EQ 1)
|>
|> with sum a scalar, and array_1 an array. (BIG surprise!)
|> In other words : If array_1.element equals 1, then add 1 to sum.
|> How do I go about to solve this?
|>

I think sum = total(array_1 eq 1) does the trick.
In general, a logical operation on an array results in an array of
(BYTE) logical values, with 0 for false, and 1 for true.
TOTAL() adds up to a float, so no overflow.

|> Thanx in advance.
|>
|> Ragnar Aas

Stein Vidar
[Message index]
 
Read Message
Read Message
Previous Topic: How to I get IDL postscript files from Sun to Mac?
Next Topic: How to contact Visual Numerics?

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

Current Time: Fri Oct 10 11:29:08 PDT 2025

Total time taken to generate the page: 0.32362 seconds