[SciPy-User] numpy array root operation

Odin Den hate_pod@yahoo....
Wed Mar 21 21:43:37 CDT 2012


Hi,
5th root of -32 can be computed correctly as follows:
>>> -32**(1/5)
>>> -2.0

However, when I try to perform same operation on numpy arrays I get
the following:
>>> array([-32])**(1/5)
>>> array([ nan])

Is there anyway to compute roots of numpy arrays? I have a huge matrix which
contains both negative and positive values. What is the easiest way of making
python compute the "nth" roots of each element of this matrix without knowing
the value of "n" a priory?







More information about the SciPy-User mailing list