Re: area summing problem

From: sk <sdk0084_at_nyahnyahspammersnyahnyah>
Date: Mon Mar 12 2012 - 00:09:43 MDT

Thanks, emi is: [Time | 337] x [south_north | 296] x [west_east | 329];   float range: 0-1085.27 I think you are right it something to do with loss of precision    ________________________________ From: Dennis Shea <shea_at_ucar.edu> To: sk <sdk0084_at_yahoo.com> Cc: ncl <ncl-talk_at_ucar.edu> Sent: Sunday, March 11, 2012 5:58 PM Subject: Re: [ncl-talk] area summing problem 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 Mon Mar 12 00:09:52 2012

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