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

Home » Public Forums » archive » Re: "clamping" an array to a maximum value?
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: "clamping" an array to a maximum value? [message #13943 is a reply to message #13941] Tue, 22 December 1998 00:00 Go to previous messageGo to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
David Fanning wrote:
>
> Kevin Ivory (Kevin@Ivory.de) writes:
>
>> Martin Schultz wrote:
>>> ... but be careful to use parantheses when you want to clamp min and
>>> max at the same time:
>>> twoodle_array = (twoodle_array < max_val ) > min_val
>>
>> In that case I don't use parantheses either, because I think the
>> following "looks" nicer: ;-)
>>
>> twoodle_array = min_val > twoodle_array < max_val
>
> I agree with Kevin. Having nice looking programs is as important
> as having programs that work correctly. :-)
>
> The only problem with Kevin's approach is that I am usually
> clamping from some mininum value to some maximun-minus-one
> value. And this definitely does NOT do what you want:
>
> twoodle_array = min_val > twoodle_array < max_val - 1
>
> I've been bit so many times with this that I've given up
> all aesthetics and wrap those damn parentheses around anything
> that moves. :-(
>
> Happy Holidays,
>
> David
> --

Yup,

that's what I really intended to say/write. BTW: How about a "last
element" operator? I very often need something like
subdata = data[*,0:n_elements(data[0,*])-1]
which is not very aesthetic ;-) is it? It would just be great if one
could write something like
subdata = data[*,0:(*)-1] or anything with a similar short syntax
In this case the parantheses would serve to distinguish between "all
elements" and "last element". That's probably a little dangerous. Anyone
with a better idea?

Happy holidays,
Martin.

--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Engineering&Applied Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: segmentation
Next Topic: 3D Scatter plot

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

Current Time: Sun Oct 12 00:43:11 PDT 2025

Total time taken to generate the page: 0.97937 seconds