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

Home » Public Forums » archive » Re: MAKE_ARRAY question
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: MAKE_ARRAY question [message #24728 is a reply to message #24727] Fri, 13 April 2001 10:26 Go to previous messageGo to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Paul van Delst wrote:
>
> Hi there,
>
> I want to create an array that by default should be FLOAT but can be specified as DOUBLE
> by the user as a keyword input to a function. Instead of the following:
>
> FUNCTION my_func, n_pts, double = double
>
> IF ( KEYWORD_SET( double ) ) THEN $
> x = MAKE_ARRAY( n_pts, /DOUBLE, /NOZERO ) $
> ELSE $
> x = MAKE_ARRAY( n_pts, /FLOAT, /NOZERO )
>
> .....
>
> END
>
> can I rely on the fact that NO type keywords to MAKE_ARRAY means default FLOAT? I.e. :
>
> FUNCTION my_func, n_pts, double = double
>
> x = MAKE_ARRAY( n_pts, DOUBLE = double, /NOZERO )
>
> .....
>
> END
>
> The MAKE_ARRAY documentation does not specifically state that the default array created is
> a FLOAT. Does anyone know if this *is* documented anywhere so I'm not setting my function
> up (which I use *a lot*) to fall in a heap when IDL 5.5+ is released and RSI happened to
> decide a default LONG would be better?
>
> Or is there some other natty way to do this?

One could also do:

x = MAKE_ARRAY( n_pts, VALUE = 0.0, DOUBLE = double )

i.e value = float if double is not set, but I want to avoid the value assignation. The
array can be quite large (many millions of points x 2) hence the /NOZERO. The performance
hit of using the VALUE keyword is noticeable (the /NOZERO has no effect if VALUE is used).

paulv

--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
paul.vandelst@noaa.gov Alexander Pope.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Postscript font usage
Next Topic: Re: FOR statement

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

Current Time: Sun Oct 12 12:14:24 PDT 2025

Total time taken to generate the page: 1.26344 seconds