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

Home » Public Forums » archive » Re: should max nuke the 2nd argument
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: should max nuke the 2nd argument [message #65721] Mon, 23 March 2009 10:25 Go to next message
Greg Hennessy is currently offline  Greg Hennessy
Messages: 45
Registered: November 2005
Member
On 2009-03-23, Jean H. <jghasban@DELTHIS.ucalgary.ANDTHIS.ca> wrote:
> did you intent to do min([n,nel]) maybe?

Yes. You would think by now that I wouldn't code till *after* I had my
cup of tea in the morning.
Re: should max nuke the 2nd argument [message #65724 is a reply to message #65721] Mon, 23 March 2009 08:16 Go to previous messageGo to next message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Greg Hennessy wrote:
> The following weird thing is happening to me. Does it happen to
> others?
>
> IDL> n=2l^15
> IDL> id=indgen(30000)
> IDL> nel=size(id,/n_elements)
> IDL> help,n,nel
> N LONG = 32768
> NEL LONG = 30000
> IDL> n=min(n,nel)
> IDL> help,n,nel
> N LONG = 32768
> NEL LONG = 0
> IDL>
>
> I don't think that the nel variable should be reset
> to zero after the call to min, but its early enough
> in the morning I'd like a 2nd opinon before I try
> to report this as a bug.
>
> IDL Version 6.4 (linux x86_64 m64).

this is normal.

Read the help file for "min". First argument is the array, 2nd contains
the location of the min value in the array... and location 0 is
perfectly valid when the "array" contains only one element!

did you intent to do min([n,nel]) maybe?

Jean
Re: should max nuke the 2nd argument [message #65726 is a reply to message #65724] Mon, 23 March 2009 07:54 Go to previous messageGo to next message
liamgumley is currently offline  liamgumley
Messages: 74
Registered: June 2005
Member
On Mar 23, 9:41 am, Greg Hennessy <greg.henne...@cox.net> wrote:
> The following weird thing is happening to me. Does it happen to
> others?
>
> IDL> n=2l^15
> IDL> id=indgen(30000)
> IDL> nel=size(id,/n_elements)
> IDL> help,n,nel  
> N               LONG      =        32768
> NEL             LONG      =        30000
> IDL> n=min(n,nel)
> IDL> help,n,nel  
> N               LONG      =        32768
> NEL             LONG      =            0
> IDL>
>
> I don't think that the nel variable should be reset
> to zero after the call to min, but its early enough
> in the morning I'd like a 2nd opinon before I try
> to report this as a bug.

MIN is doing exactly what it is supposed to do.

From the online help:

"The MIN function returns the value of the smallest element of Array.
The type of the result is the same as that of Array.

Syntax
Result = MIN( Array [, Min_Subscript] [, /ABSOLUTE] [,
DIMENSION=value] [, MAX=variable] [, /NAN] [,
SUBSCRIPT_MAX=variable])

Return Value: Returns the smallest array element value.

Arguments
Array: The array to be searched.
Min_Subscript: A named variable that, if supplied, is converted to a
long integer containing the one-dimensional subscript of the minimum
element. Otherwise, the system variable !C is set to the one-
dimensional subscript of the minimum element."

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
Re: should max nuke the 2nd argument [message #65862 is a reply to message #65721] Tue, 24 March 2009 06:33 Go to previous message
edward.s.meinel@aero. is currently offline  edward.s.meinel@aero.
Messages: 52
Registered: February 2005
Member
On Mar 23, 1:25 pm, Greg Hennessy <greg.henne...@cox.net> wrote:
> On 2009-03-23, Jean H. <jghas...@DELTHIS.ucalgary.ANDTHIS.ca> wrote:
>
>> did you intent to do min([n,nel]) maybe?
>
> Yes. You would think by now that I wouldn't code till *after* I had my
> cup of tea in the morning.

And in this case the simplest solution is:

IDL> n = n < nel

Ed M
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: starting point of dashed lines
Next Topic: Google Groups and ENVI 4.6.1

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

Current Time: Wed Oct 08 15:37:26 PDT 2025

Total time taken to generate the page: 0.00641 seconds