imag#
- ivy.imag(val, /, *, out=None)[source]#
Return the imaginary part of a complex number for each element
x_i
of the input arrayval
.- Parameters:
- Return type:
- Returns:
ret – Returns an array with the imaginary part of complex numbers. The returned arrau must have a floating-point data type determined by the precision of
val
(e.g., ifval
iscomplex64
, the returned array must befloat32
).This method conforms to the
This docstring is an extension of the
`docstring <https (//data-apis.org/array-api/latest/)
API_specification/generated/array_api.imag.html>`_
in the standard.
Both the description and the type hints above assumes an array input for simplicity,
but this function is nestable, and therefore also accepts
ivy.Container
instances in place of any of the arguments.
Examples
>>> b = ivy.array(np.array([1+2j, 3+4j, 5+6j])) >>> b ivy.array([1.+2.j, 3.+4.j, 5.+6.j]) >>> ivy.imag(b) ivy.array([2., 4., 6.])
- Array.imag()#
Imaginary part of the array.
- Returns:
ret – array containing the imaginary part of each element in the array. The returned array must have the same shape and data type as the original array.
- Container.imag(self, /, *, out=None)[source]#
ivy.Container instance method variant of ivy.imag. This method simply wraps the function, and so the docstring for ivy.imag also applies to this method with minimal changes.
- Parameters:
val – Array-like input.
out (
Optional
[Container
], default:None
) – optional output array, for writing the result to.
- Return type:
Container
- Returns:
ret – Returns an Container including arrays with the imaginary part of complex numbers.
Examples
>>> x = ivy.Container(a=ivy.array(np.array([1+2j, 3+4j, 5+6j])), b=ivy.array(np.array([-2.25 + 4.75j, 3.25 + 5.75j]))) >>> x { a: ivy.array([1.+2.j, 3.+4.j, 5.+6.j]), b: ivy.array([-2.25+4.75j, 3.25+5.75j]) } >>> x.imag() { a: ivy.array([2., 4., 6.]), b: ivy.array([4.75, 5.75]) }