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

Home » Public Forums » archive » Re: findgen([variable])
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: findgen([variable]) [message #22895 is a reply to message #22894] Tue, 12 December 2000 10:33 Go to previous messageGo to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
"Pavel A. Romashkin" wrote:
>
> I am afraid FINDGEN can not take a vector for dimensions. What I would
> try is either using a vector
>
> x = [5, 7]
> r = findgen(total(x))
>
> which still would allow transparent indexing of R. If I really needed
> multi D arrays, I'd use EXECUTE and build a command string using
> dimensions of X:
>
> x = [5, 7]
> com = 'r = findgen('
> for i =0, n_elements(x)-1 do com = com +'x['+string(i)+']'+ $
> string(44b*byte(i ne n_elements(x)-1) > 41b)
> i=execute(com)
>
> EXECUTE is not cute, but I can't come up with anything nicer. I need
> another cup of coffe :-(

Oof!

What about

IDL> x=[5,7]
IDL> ndim=n_elements(x)
IDL> n=1L
IDL> for i=0,ndim-1 do n=n*x[i]
IDL> help, reform(findgen(n),x)
<Expression> FLOAT = Array[5, 7]
IDL> print, reform(findgen(n),x)
0.00000 1.00000 2.00000 3.00000 4.00000
5.00000 6.00000 7.00000 8.00000 9.00000
10.0000 11.0000 12.0000 13.0000 14.0000
15.0000 16.0000 17.0000 18.0000 19.0000
20.0000 21.0000 22.0000 23.0000 24.0000
25.0000 26.0000 27.0000 28.0000 29.0000
30.0000 31.0000 32.0000 33.0000 34.0000

Seems that determining "n" is the hard part...is there a "PRODUCT" type of function in IDL? Like
TOTAL but with * rather than + as the operator.

Why doesn't MAKE_ARRAY allow for a dimension vector input?

paulv

--
Paul van Delst Ph: (301) 763-8000 x7274
CIMSS @ NOAA/NCEP Fax: (301) 763-8545
Rm.207, 5200 Auth Rd. Email: pvandelst@ncep.noaa.gov
Camp Springs MD 20746
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL and external app in concurrent mode
Next Topic: Background colors in PNG files?

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

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

Total time taken to generate the page: 1.20062 seconds