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

Home » Public Forums » archive » make all array values equal to zero
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: make all array values equal to zero [message #89862 is a reply to message #89861] Thu, 11 December 2014 08:59 Go to previous messageGo to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
On Thursday, December 11, 2014 4:58:37 PM UTC+1, Mike Galloy wrote:
> On 12/11/14, 8:12 am, g.nacarts@gmail.com wrote:
>> Hi
>>
>> Can I use the "greater than" operator to make all array values
>> greater than 100 equal to zero?
>>
>> E.g. A = [[1,2,3],[120,4,200]] to become A = [[1,2,3],[0,4,0]]
>>
>> Many Thanks
>>
>
> In addition to the other methods mentioned:
>
> IDL> print, (A le 100) * A
> 1 2 3
> 0 4 0
>
> And, if you really want to know if there was some way to do it with
> greater than operator, yes you can:
>
> IDL> print, (1B - (A gt 100)) * A
> 1 2 3
> 0 4 0
>
> Mike
> --
> Michael Galloy
> www.michaelgalloy.com
> Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
> Research Mathematician
> Tech-X Corporation

IDL> A=randomn(rien,10000000)
IDL> tic & A *= (A gt 1) & toc
% Time elapsed: 0.078000069 seconds.
IDL> tic & A[where(A gt 1,/NULL)]=0 & toc
% Time elapsed: 0.047000170 seconds.

The "where" solution appears to be somewhat faster.

alx.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: plot positional degrees
Next Topic: Rendering method software vs hardware

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

Current Time: Wed Oct 08 19:36:41 PDT 2025

Total time taken to generate the page: 0.00432 seconds