|
Re: should max nuke the 2nd argument [message #65724 is a reply to message #65721] |
Mon, 23 March 2009 08:16   |
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   |
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  |
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
|
|
|