|
|
Re: Grumbling about setting double precision [message #78765 is a reply to message #78763] |
Wed, 21 December 2011 08:16   |
greg.addr
Messages: 160 Registered: May 2007
|
Senior Member |
|
|
Ok, a simple assignment would have to be converted to float (unless specified with the D) to retain the usual IDL behaviour:
a=24.5 {internally a=float(24.5d) }
but
b=[24.5d,9999.9] would then work as expected, since the assigned values (which are apparently copied into the dblarr after being read somewhere else) would already be doubles. In this case, the array type comes from the first element as usual (float unless specified otherwise), so
c=[24.5,9999.9] should likewise produce a satisfactory float array.
The other example from your page,
array = Make_Array(3, Value=9999.9, /Double)
is a tricky one. Normally you would use
array = Make_Array(3, Value=9999.9d)
to make a dblarr() with a specific value, which is fine (and /double for a zeroed array). Here, you're specifically converting the float to a double - I think there's no harm to leave that effect as it is.
Wouldn't that work?
cheers,
Greg
|
|
|
Re: Grumbling about setting double precision [message #78766 is a reply to message #78765] |
Wed, 21 December 2011 08:15   |
Russell[1]
Messages: 101 Registered: August 2011
|
Senior Member |
|
|
No new rules, PLEASE!! Imagine what that would do for backwards-
compatibility!??!?
Russell
On Dec 21, 10:21 am, David Fanning <n...@dfanning.com> wrote:
> greg.a...@googlemail.com writes:
>> ...for each number written out by hand in your code. Even IDL
>> on a 32bit Windows machine will swallow 100 million of those at a go
>> without a hiccup. How many numbers do you type into your programs? :)
>
> So, you are saying, don't make all current floats doubles,
> but make a double out of anything I define by hand: a=24.5.
>
> But, what happens when I multiply my 10000x10000 floating
> point array by my variable: array = array * a.
>
> That will *surely* double the memory, or do we need new
> rules for promoting values?
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
|
|
|
|
Re: Grumbling about setting double precision [message #78775 is a reply to message #78774] |
Wed, 21 December 2011 06:20   |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article < 31663559.520.1324400314865.JavaMail.geo-discussion-forums@yq dj19 >,
wlandsman <wlandsman@gmail.com> wrote:
> I am converting a Python program to IDL which includes several hundred double
> precision data values. In Python the data values are written as follows:
>
> a = [2721.64363164731, -1615.73035059635]
>
> As described by David Fanning in
> http://www.idlcoyote.com/math_tips/double.html to make these double precision
> in IDL, it is not enough to convert the vector to double
>
> IDL> print,double(a),f='(2f18.10)'
> 2721.6435546875 -1615.7303466797
>
> and it is not enough to put a "d" at the end of one of the values
>
> IDL> a = [2721.64363164731d, -1615.73035059635]
> IDL> print,double(a),f='(2f18.10)'
> 2721.6436316473 -1615.7303466797
>
> Instead, I must spend an hour in my editor putting a "d" at the end of every
> single data value.
>
> But it would sure be nice to be able to somehow tell the IDL compiler to
> interpret numeric values as double precision. --Wayne
You could replace "," with "D," and replace "]" with "D]".
That should only take a minute or two with find and replace.
Ken
|
|
|
|
Re: Grumbling about setting double precision [message #78841 is a reply to message #78775] |
Wed, 21 December 2011 17:34   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
On Wednesday, December 21, 2011 9:20:24 AM UTC-5, Kenneth P. Bowman wrote:
>
> You could replace "," with "D," and replace "]" with "D]".
>
> That should only take a minute or two with find and replace.
>
Thanks, but the problem in my code would be skipping the integer vectors (mixed in with the double precision vectors), which I don't want to be changed. I am sure there is a way to make my editor skip commas after integers, but I suspect that would take me more time to figure out than manually editing the file.
Both MATLAB and Python use double precision as their default data type. Because IDL has been more of an image processing language, it originally made sense for it to have floating point as a default. But with the increase in computer memory capabilities, I think it now makes sense to have a new DEFFLT64 parameter to COMPILE_OPT which, in analogy to DEFINT32, would make 64 bit floating point the default.
|
|
|
|
Re: Grumbling about setting double precision [message #78887 is a reply to message #78841] |
Tue, 03 January 2012 14:04  |
Mark Piper
Messages: 198 Registered: December 2009
|
Senior Member |
|
|
On 12/21/2011 6:34 PM, wlandsman wrote:
> I think it now makes sense to have a new DEFFLT64 parameter to COMPILE_OPT which, in analogy to DEFINT32, would make 64 bit floating point the default.
I've seen several requests for a DEFFLT64 option in recent years. I'll
see if I can push for it to be included in IDL this year.
mp
|
|
|