[SciPy-user] casting complex numbers
Ryan Krauss
ryanlists at gmail.com
Fri Feb 17 08:41:04 CST 2006
Actually, I may have a small problem in that nls.sqrt cannot take a
vector input.
On 2/17/06, Ryan Krauss <ryanlists at gmail.com> wrote:
> Perfect. Thanks Travis.
>
> On 2/17/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
> > Ryan Krauss wrote:
> >
> > >Is there a way to make python return a complex number number instead
> > >of nan when taking the sqrt of a negative float? I have an
> > >automatically generated function based on Maxima symbolic output that
> > >is giving bad output because of this. Basically, part of the symoblic
> > >expression includes sqrt(-s**2*x) where s is complex and this
> > >expression would evaluate nicely in python. For whatever reason,
> > >Maxima prefers to output this expression as sqrt(-x)*s, which would
> > >also evaluate correctly if sqrt(-x) gave 1.0j*sqrt(x), but since x is
> > >a float it is returning nan. I am hoping for flag similar to from
> > >__future__ import division instead of having to declare all my
> > >variables as complex.
> > >
> > >
> > >
> > import numpy.lib.scimath as nls
> >
> > nls.sqrt(-1)
> >
> > -Travis
> >
> > _______________________________________________
> > SciPy-user mailing list
> > SciPy-user at scipy.net
> > http://www.scipy.net/mailman/listinfo/scipy-user
> >
>
More information about the SciPy-user
mailing list