Re: ncl strange calculation problem

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Dec 17 2013 - 23:06:53 MST

You can always write your own function

undef ("skfunc")
function skfunc (x:numeric, pow[1]:numeric)
begin
    xp = where(x.lt.0.0, -abs(x)^pow, x^pow)
    return(xp)
end

On 12/17/13, 10:52 PM, sk wrote:
> Thank you for the quick reply and the good answers unfortunately my array is with many positive and negative values and the trick you suggest is not applicable directly. anyway i will try to find to make use of what you suggest.
> Regards,
> -SK
>
>
>
>
>
>
> On Tuesday, December 17, 2013 9:24 PM, Dennis Shea <shea@ucar.edu> wrote:
>
> Also
>
> ncl 0> x = 17.8^0.4
> ncl 1> print(x)
>
>
> Variable: x
> Type: float
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 3.163501
>
> ncl 2> print(-(17.8^0.4))
>
> (0) -3.163501
>
> On 12/17/13, 11:19 AM, Rick Brownrigg wrote:
>> This doesn't really answer your question, but I'll note:
>>
>> - my calculator returns "-E-"
>> - C/C++/Java all return NaN
>> - Python returns the same result as your calculator
>>
>> The man-page on C/C++'s "pow()" function state:
>>
>> pow(x,y)
>> …..
>> A domain error occurs if x is finite and negative and y is finite and not an integer.
>>
>> (under MacOSX; similar verbage under Linux)
>>
>> Ncl undoubtably uses the pow() for its computation.
>>
>>
>> On Dec 17, 2013, at 7:00 AM, sk <sdk0084@yahoo.com> wrote:
>>
>>> in ncl:
>>> print(-17.8^0.4)
>>> (0) nan
>>>
>>> in standard calculator the result is: -3.163501181
>>> some explanation?
>>>
>>> Thx!
>>> -SK
>>>
>>> _______________________________________________
>>> 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 Tue Dec 17 23:07:08 2013

This archive was generated by hypermail 2.1.8 : Wed Dec 18 2013 - 14:29:51 MST