-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Ufuncs for complex numbers #13179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
@rkern Makes sense. What do you think about making an issue like this in the |
@rkern - sticking to the usual consideration that numpy should just cover the standard C math library, I guess these complex ufuncs indeed do not quite belong in numpy, though especially for Looking a bit further afield, base math for julia includes |
I'm not necessarily opposed to some of these making their way into |
TBH, I've often thought an |
|
@charris - what is "the proposed API document"? |
Implement the absolute square function in scipy.special as suggested 7DB6 in numpy/numpy#3994. See also numpy/numpy#13179.
Uh oh!
There was an error while loading. Please reload this page.
This is a tracker for a number of requests for making working with complex numbers a bit easier/faster
z/|z|
(the sgn function) (see API,ENH: Change definition of complex sign #25441, which changes the behaviour ofnp.sign
to match the Array API and extends it tocopysign
)z * z.conj()
(instead of the slownp.abs(z)**2
).square
might be logical but is already defined to just doz*z
... (see abs() is slow for complex, add abs2() #3994)angle
, i.e.,exp(1j * a) = cos(a) + 1j * sin(a)
. Note that for large angle arrays,exp(1j*a)
needlessly triples memory use for the input (see Have anexp
for pure imaginary numbers #5625; somewhat related:sincos
function, see Implement sincos() (Trac #2034) #2626; discussion moved to ENH: Create a place for "optimization" ufuncs #18483)abs
andangle
and their inverse, perhaps most logical as part of providing polar to cartesian transformations (see ENH: Add to numpy simple functions for transform coordinate systems #5228)EDIT (2021-Jun-25): if there is worry about making the numpy API too big, one option might be to make this part of
numpy.lib.scimath
(which I must admit I didn't know about until today; I see now that it should benp.emath
- https://numpy.org/devdocs/reference/routines.emath.html). Though perhaps that should stay reserved for complex continuationsreal->complex
like forsqrt
.The text was updated successfully, but these errors were encountered: