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

Home » Public Forums » archive » Re: nearest number
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: nearest number [message #49612 is a reply to message #49611] Mon, 07 August 2006 06:13 Go to previous messageGo to previous message
Timm Weitkamp is currently offline  Timm Weitkamp
Messages: 66
Registered: August 2002
Member
kuyper@wizard.net wrote:
> bressert@gmail.com wrote:
>> I thought about the problem more and realized a simple solution:
>>
>> smallest = min(abs(array - floating_value))
>> index = where((array - floating_value) eq smallest, count)
>
> Almost: that should be "abs(array-floating_value) eq smallest".
>
> I'd be inclined to pull out the common code, and write it as
>
> diff = abs(array-floating_value)
> index = where(array eq min(array))

Or simply,
void = min(abs(array - floating_value), index)

Timm
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Writing a structure containing empty strings
Next Topic: Re: file_lines and expand path

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

Current Time: Fri Oct 10 14:13:54 PDT 2025

Total time taken to generate the page: 1.12129 seconds