[Numpy-discussion] Calculating roots with negative numbers
Matthias Hillenbrand
mailanhilli at googlemail.com
Tue Jul 15 22:59:18 EDT 2008
Hello,
I want to calculate the root of a numpy array with negative numbers.
Here is an example:
x = linspace(-10,10,100)
h = zeros(100)
h[where(abs(x) < 2)] = sqrt( abs(x) -2 )
h[where(2 <= abs(x))] = 1j * sqrt( 2 - abs(x) )
Unfortunately I get the following error: Warning: invalid value
encountered in sqrt
and h contains some NaN-values
How can I make a correct case differentiation in combination with
roots that might contain negative values?
Thank you very much,
Matthias
More information about the NumPy-Discussion
mailing list