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

Home » Public Forums » archive » Re: Grumbling about setting double precision
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Grumbling about setting double precision [message #78758] Wed, 21 December 2011 09:26 Go to next message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <MPG.295b9ae6d12361b798995a@news.giganews.com>,
David Fanning <news@dfanning.com> wrote:

> Kenneth P. Bowman writes:
>
>> You could replace "," with "D," and replace "]" with "D]".
>
> Yeah, there are probably very few commas in that code! ;-)
>
> Cheers,
>
> David

David, you're always such a pessimist!

Ken
Re: Grumbling about setting double precision [message #78763 is a reply to message #78758] Wed, 21 December 2011 08:22 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
greg.addr@googlemail.com writes:

> Wouldn't that work?

I don't know. When things start getting really inelegant
in any program I've ever written, with a lot of special
rules and considerations, it's usually a sign I'm headed
down the wrong road. :-)

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 #78765 is a reply to message #78763] Wed, 21 December 2011 08:16 Go to previous messageGo to next message
greg.addr is currently offline  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 Go to previous messageGo to next message
Russell[1] is currently offline  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 #78770 is a reply to message #78766] Wed, 21 December 2011 07:21 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
greg.addr@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 #78771 is a reply to message #78770] Wed, 21 December 2011 07:04 Go to previous messageGo to next message
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
> Well, let's see. Twice as much memory allocated for
> each number comes to mind. :-)

...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? :)
Re: Grumbling about setting double precision [message #78772 is a reply to message #78771] Wed, 21 December 2011 06:45 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
greg.addr@googlemail.com writes:

> Would there be any downside *at all* to having the compiler always
> read values as doubles and convert down to floats when necessary?

Well, let's see. Twice as much memory allocated for
each number comes to mind. :-)

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 #78773 is a reply to message #78772] Wed, 21 December 2011 06:35 Go to previous messageGo to next message
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
Would there be any downside *at all* to having the compiler always read values as doubles and convert down to floats when necessary?

Greg
Re: Grumbling about setting double precision [message #78774 is a reply to message #78773] Wed, 21 December 2011 06:28 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kenneth P. Bowman writes:

> You could replace "," with "D," and replace "]" with "D]".

Yeah, there are probably very few commas in that code! ;-)

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 Go to previous messageGo to next message
Kenneth P. Bowman is currently offline  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 #78829 is a reply to message #78763] Thu, 22 December 2011 03:48 Go to previous messageGo to next message
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
I think it would simply fix the bug transparently to the user, the only losers being those who rely on the truncation of their 8+ digit values. But perhaps longstanding workarounds are a form of elegance... :)
Re: Grumbling about setting double precision [message #78841 is a reply to message #78775] Wed, 21 December 2011 17:34 Go to previous messageGo to next message
wlandsman is currently offline  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 #78853 is a reply to message #78758] Wed, 21 December 2011 10:13 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kenneth P. Bowman writes:

> David, you're always such a pessimist!

I'm just saying, my primary motivation is to prevent
repetitive strain disorder. ;-)

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 #78887 is a reply to message #78841] Tue, 03 January 2012 14:04 Go to previous message
Mark Piper is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: running IDL as a 'sleeping' process
Next Topic: Affordable SEO Services

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

Current Time: Wed Oct 08 15:13:18 PDT 2025

Total time taken to generate the page: 0.00541 seconds