angle#

ivy.angle(z, /, *, deg=False, out=None)[source]#

Calculate Element-wise the angle for an array of complex numbers(x+yj).

Parameters:
  • z (Union[Array, NativeArray]) – Array-like input.

  • deg (bool, default: False) – optional bool.

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

Return type:

Array

Returns:

ret – Returns an array of angles for each complex number in the input. If deg is False(default), angle is calculated in radian and if deg is True, then angle is calculated in degrees.

Examples

>>> z = ivy.array([-1 + 1j, -2 + 2j, 3 - 3j])
>>> z
ivy.array([-1.+1.j, -2.+2.j,  3.-3.j])
>>> ivy.angle(z)
ivy.array([ 2.35619449,  2.35619449, -0.78539816])
>>> ivy.angle(z,deg=True)
ivy.array([135., 135., -45.])
Array.angle(self, /, *, deg=False, out=None)[source]#

ivy.Array instance method variant of ivy.angle. This method simply wraps the function, and so the docstring for ivy.angle also applies to this method with minimal changes.

Parameters:
  • z – Array-like input.

  • deg (bool, default: False) – optional bool.

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

Return type:

Array

Returns:

ret – Returns an array of angles for each complex number in the input. If def is False(default), angle is calculated in radian and if def is True, then angle is calculated in degrees.

Examples

>>> ivy.set_backend('tensorflow')
>>> z = ivy.array([-1 + 1j, -2 + 2j, 3 - 3j])
>>> z
ivy.array([-1.+1.j, -2.+2.j,  3.-3.j])
>>> ivy.angle(z)
ivy.array([ 2.35619449,  2.35619449, -0.78539816])
>>> ivy.set_backend('numpy')
>>> ivy.angle(z,deg=True)
ivy.array([135., 135., -45.])
Container.angle(self, /, *, deg=False, out=None)[source]#

ivy.Container instance method variant of ivy.angle. This method simply wraps the function, and so the docstring for ivy.angle also applies to this method with minimal changes.

Parameters:
  • z – Array-like input.

  • deg (Union[bool, Container], default: False) – optional bool.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – Returns an array of angles for each complex number in the input. If def is False(default), angle is calculated in radian and if def is True, then angle is calculated in degrees.

Examples

>>> ivy.set_backend('tensorflow')
>>> x = ivy.Container(a=ivy.array([-2.25 + 4.75j, 3.25 + 5.75j]),
                        b=ivy.array([-2.25 + 4.75j, 3.25 + 5.75j]))
>>> x
{
    a: ivy.array([-2.25+4.75j, 3.25+5.75j]),
    b: ivy.array([-2.25+4.75j, 3.25+5.75j])
}
>>> x.angle()
{
    a: ivy.array([2.01317055, 1.05634501]),
    b: ivy.array([2.01317055, 1.05634501])
}
>>> ivy.set_backend('numpy')
>>> x.angle(deg=True)
{
    a: ivy.array([115.3461759, 60.524111]),
    b: ivy.array([115.3461759, 60.524111])
}