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

Home » Public Forums » archive » Re: function of two variables
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: function of two variables [message #1888 is a reply to message #1885] Fri, 18 March 1994 10:48 Go to previous message
andy is currently offline  andy
Messages: 31
Registered: November 1993
Member
In article <CMtu54.5o@ireq.hydro.qc.ca>, brooker@toka.ireq-ccfm.hydro.qc.ca writes:
> Hello from Canada!!
>
> I have the following IDL question:
>
> Assume I have the functions Y=2.*X + 3. and I want to plot Y vs X over the
> range [0,10]
>
> I could code this as
>
> X=findgen(101)/100.*10.
> Y=2.*X + 3.
> plot,x,y
>
> Very nice!! Only array operations. NO LOOPING!!!!!! Very FAST!!!!!
>
> But what if now I had Z=2.*X + 3.*Y and I want to plot Z as X and Y both
> range from 0 to 10. A way to code this is
>
> X=findgen(101)/100.*10.
> Y=X
> num_y=n_elements(Y)
> num_x=n_elements(X)
> z=fltarr(num_x,num_y)
> for j=0,num_y-1 do begin
> z(*,j)=2.*X + 3.*Y(j)
> endfor
> surface,Z,X,Y
>
> Very inefficient because of the loop!! Very slow!!
>
> Is there anyway to do this more efficiently?
>
> Thanks,
> Peter Brooker
> brooker@toka.ireq-ccfm.hydro.qc.ca


Peter,

I would recommend trying...

z = fltarr(num_x,num_y)+replicate(1,num_y)#(3.*y)+(2.*X)#replica te(1,num_x)

I didn't find your example slow on a SUN Sparc 2, but hopefully this
suggestion will be faster on your system.

Andy

--

,__o Andrew F. Loughe (Code 971)
-\_<, NASA Goddard Space Flight Center phone: (301) 286-5899
(*)/'(*) Greenbelt, MD 20771 email: andy@toto.gsfc.nasa.gov
[Message index]
 
Read Message
Read Message
Previous Topic: Structures and Call_External
Next Topic: Question about shade_surf and Postscript output

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

Current Time: Sun Oct 12 00:09:20 PDT 2025

Total time taken to generate the page: 1.43952 seconds