Phillip Feldman
2015-09-19 04:16:42 UTC
In communications and signal processing, it is frequently necessary to
calculate the power of a signal. This can be done with a function like the
following:
def magsq(z):
"""
Return the magnitude squared of the real- or complex-valued input.
"""
return z.real**2 + z.imag**2
A high percentage of the scripts that I write contain or import a function
like this. It would be great if there were a built-in method in NumPy,
preferably with a name like `magsq`, `mag2`, or `msq`.
Phillip
calculate the power of a signal. This can be done with a function like the
following:
def magsq(z):
"""
Return the magnitude squared of the real- or complex-valued input.
"""
return z.real**2 + z.imag**2
A high percentage of the scripts that I write contain or import a function
like this. It would be great if there were a built-in method in NumPy,
preferably with a name like `magsq`, `mag2`, or `msq`.
Phillip