Re: area summing problem

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Sun Mar 11 2012 - 08:58:40 MDT

This previous email was inadvertently sent before I finished.

I did try a larger array:

x = random_normal(0,5, (/5,200,300/) ) ; float

(0) -1866.58 -1866.57 0.00756836

x = random_normal(0d0,5d0, (/5,200,300/) ) ; double

(0) -1866.57 -1866.57 3.45608e-11

NCL does all computations in double precision. If type float values
are input (a) NCL promotes to double, (b) performs computations in
double, (c) 'demotes' to float.

If double values are input only (b) is performed.

So, for type float

x1 = sum(x(0,:,:)) + sum(x(1,:,:))

*Each* term went through (a), (b), (c)
This results is loss of precision.

x2 = sum(x(0:1,:,:)) ; this is better

Only one (a), (b), (c)

===
So, some minor differences are expected.
However, the following difference is a bit
larger than one would expect.

>> print(sum(emi(0,:,:))+sum(emi(1,:,:)))
>> 294721.4
>> print(sum(emi(0:1,:,:)))
>> 294711.3

What are the dimensions of emi and what are the
range of values (min/max)?

On 3/11/12 8:38 AM, Dennis Shea wrote:
> This behavior can not be replicated.
>
> One simple test:
>
> x = random_normal(0,5, (/5,20,30/) )
> x1 = sum(x(0,:,:)) + sum(x(1,:,:))
> x2 = sum(x(0:1,:,:))
> xd = x2-x1
> print(x1+" "+x2+" "+xd)
>
>
> On 3/11/12 12:59 AM, sk wrote:
>> Hi There,
>> I can't understand why the following happen:
>>
>> print(sum(emi(0,:,:))+sum(emi(1,:,:)))
>> 294721.4
>> print(sum(emi(0:1,:,:)))
>> 294711.3
>>
>> what is the explanation please?
>>
>> Regards,
>> Izo
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Mar 11 08:58:54 2012

This archive was generated by hypermail 2.1.8 : Tue Mar 20 2012 - 15:27:15 MDT