Bug in IDL or, may be in my head ? [message #88645] |
Fri, 23 May 2014 01:01  |
franciscoaiglesias
Messages: 2 Registered: May 2014
|
Junior Member |
|
|
Hi all,
Any clue what's going on here ?
a = randomn(seed, 248, 256, 9972) * 100. + 4.e3
print, total(a) ; gives 1.42030e+12
print, total(a, /double) ;gives 2.5324144e+12
print, total(total(total(a, 1),1));gives 2.53250e+12
Thanks !
|
|
|
Re: Bug in IDL or, may be in my head ? [message #88650 is a reply to message #88645] |
Fri, 23 May 2014 15:39  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 5/23/14, 2:01 AM, franciscoaiglesias@gmail.com wrote:
> Hi all,
>
> Any clue what's going on here ?
>
> a = randomn(seed, 248, 256, 9972) * 100. + 4.e3
>
> print, total(a) ; gives 1.42030e+12
> print, total(a, /double) ;gives 2.5324144e+12
> print, total(total(total(a, 1),1));gives 2.53250e+12
>
> Thanks !
>
Check out Kahan summation:
http://en.wikipedia.org/wiki/Kahan_summation_algorithm
I have an implementation in mglib:
IDL> print, mg_total(a)
% Loaded DLM: MG_ANALYSIS.
2.53241e+12
Get mglib at:
github.com/mgalloy/mglib
-Mike
|
|
|