Re: math function

From: Thomas Tobian <thomastobian_at_nyahnyahspammersnyahnyah>
Date: Thu Nov 21 2013 - 06:54:12 MST

Hi Chang,

try this:

a=(/-4.,-16.,4., 16./)
b=a
b=0.

 do i=0, dimsizes(a)-1
  if (a(i).lt.0) then
       b(i)=-1.*sqrt(abs(a(i)))
       else
       b(i)= sqrt(abs(a(i)))
  end if
 end do

print(b)

Variable: b
Type: float
Total Size: 16 bytes
            4 values
Number of Dimensions: 1
Dimensions and sizes: [4]
Coordinates:
(0) -2
(1) -4
(2) 2
(3) 4

Best,
Thomas Tobian

On Thu, Nov 21, 2013 at 2:41 PM, jbuzan <jbuzan@purdue.edu> wrote:

> The square root of a negative number is an imaginary number.
> The square root of -4 = 2*i*.
>
> -Jonathan
>
>
> On Nov 21, 2013, at 8:38 AM, Xi Chang wrote:
>
> Is there any a function in ncl that can be used to calculate something
> like this :
>
> *square root of -4. *=
>
> *-1. * square root of 4. = -2 <----- the result that I want. *
> thank you.
>
> Xi.
> _______________________________________________
> 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 Thu Nov 21 06:54:22 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 22 2013 - 09:36:32 MST