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

Home » Public Forums » archive » Re: Max value vector
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: Max value vector [message #15528 is a reply to message #15496] Sun, 23 May 1999 00:00 Go to previous messageGo to previous message
Evan Fishbein is currently offline  Evan Fishbein
Messages: 4
Registered: May 1999
Junior Member
Tom,

I have a routine that finds the max and min over the first index of a
multidimension array
using a for loop as you described. You need to make sure that the for loop
variable is a long by initializing it to long

The code below takes x1(n1,n2...nn) and returns lu(n2..nn,2) where lu(...,0)
are the lowerbounds and (lu(...1) are the upperbounds

function lubound, x1, ignore=ignore, all=all
;
; calculates the lubounds of elements of x1 have the same 2nd, 3rd...nth
; indices. i.e. bounds by contracting over the first index.
;
if n_elements(all) ne 1 then all=0
if all eq 0 then begin
x=reform(x1)
end else begin
x=reform(x1, n_elements(x1))
end
sx=size(x)

if n_elements(ignore) eq 0 then begin
if sx(0) le 1 then begin
lub= [min(x), max(x)]
end else begin
nx=sx(2+sx(0))/sx(1)
lub=make_array(nx, 2, type=sx(sx(0)+1) )
x=reform(x, sx(1), nx)
for i=0l, nx-1 do begin
lub(i,*)=[min(x(*,i)), max(x(*,i)) ]
end
lub=reform(lub, [sx(2:sx(0)),2] )
end
end else begin
if sx(0) le 1 then begin
ips=where(x ne ignore)
if ips(0) ge 0 then begin
lub= [min(x(ips)), max(x(ips))]
end else begin
lub=replicate(ignore,2)
end
end else begin
nx=sx(2+sx(0))/sx(1)
lub=make_array(nx, 2, type=sx(sx(0)+1) )
x=reform(x, sx(1), nx)
for i=0l, nx-1 do begin
ips=where(x(*,i) ne ignore)
if ips(0) ge 0 then begin
lub(i,*)= [min(x(ips,i)), max(x(ips,i))]
end else begin
lub(i,*)=replicate(ignore,2)
end
end
lub=reform(lub, [sx(2:sx(0)), 2] )
end
end
return, lub
end


"Thomas C. Stubbings" wrote:

> What I would need is something like the MATLAB command max(i) where i is an
> array(n,m) and max(i) returns a vector containing the maximum value of each
> column. The IDL max command only returns a scalar containing the absolute
> maximum of the array.
>
> I even tried a big loop running through each column to find the max of each,
> but IDL doesnt accept loops with 64000 iterations
>
> What alternatives do I have?
>
> Thomas
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: coord ?
Next Topic: Re: window title in tvimage

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

Current Time: Sat Oct 11 11:51:33 PDT 2025

Total time taken to generate the page: 0.07963 seconds