mindspore.ops.ComplexAbs
- class mindspore.ops.ComplexAbs[source]
Returns a Tensor that contains the magnitudes of the input.
The complex numbers in input must be of the form \(a + bj\), where \(a\) is the real part and \(b\) is the imaginary part.
\[y = \sqrt{a^2+b^2}\]Warning
This is an experimental API that is subject to change or deletion.
- Inputs:
x (Tensor) - A Tensor, types: complex64, complex128.
- Outputs:
Tensor, has the same shape as x. If the type of x is complex64, the type of output is float32. If the type of x is complex128, the type of output is float64.
- Raises
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> x = Tensor(np.asarray(np.complex(3+4j)), mindspore.complex64) >>> complex_abs = ops.ComplexAbs() >>> output = complex_abs(x) >>> print(output) 5.0