mindspore.ops.isreal

mindspore.ops.isreal(input)[source]

Tests element-wise for real number. A complex value is considered real when its imaginary part is 0.

Parameters

input (Tensor) – The input tensor.

Returns

Tensor, true where input is real number, false otherwise.

Raises

TypeError – If input is not a Tensor.

Supported Platforms:

GPU CPU

Examples

>>> from mindspore import ops, Tensor
>>> from mindspore import dtype as mstype
>>> x = Tensor([1, 1+1j, 2+0j], mstype.complex64)
>>> output = ops.isreal(x)
>>> print(output)
[ True False True]