Movatterモバイル変換


[0]ホーム

URL:


Skip to content

abs

abs(x:array,/)array

Calculates the absolute value for each elementx_i of the input arrayx.

For real-valued input arrays, the element-wise result has the same magnitude as the respective element inx but has positive sign.

Note

For signed integer data types, the absolute value of the minimum representable integer is implementation-dependent.

Note

For complex floating-point operands, the complex absolute value is known as the norm, modulus, or magnitude and, for a complex number\(z = a + bj\) is computed as

\[\operatorname{abs}(z) = \sqrt{a^2 + b^2}\]

Note

For complex floating-point operands, conforming implementations should take care to avoid undue overflow or underflow during intermediate stages of computation.

Parameters:

x (array) – input array. Should have a numeric data type.

Returns:

out (array) – an array containing the absolute value of each element inx. Ifx has a real-valued data type, the returned array must have the same data type asx. Ifx has a complex floating-point data type, the returned array must have a real-valued floating-point data type whose precision matches the precision ofx (e.g., ifx iscomplex128, then the returned array must have afloat64 data type).

Notes

Special Cases

For real-valued floating-point operands,

  • Ifx_i isNaN, the result isNaN.

  • Ifx_i is-0, the result is+0.

  • Ifx_i is-infinity, the result is+infinity.

For complex floating-point operands, leta=real(x_i),b=imag(x_i), and

  • Ifa is either+infinity or-infinity andb is any value (includingNaN), the result is+infinity.

  • Ifa is any value (includingNaN) andb is either+infinity or-infinity, the result is+infinity.

  • Ifa is either+0 or-0, the result is equal toabs(b).

  • Ifb is either+0 or-0, the result is equal toabs(a).

  • Ifa isNaN andb is a finite number, the result isNaN.

  • Ifa is a finite number andb isNaN, the result isNaN.

  • Ifa isNaN andb isNaN, the result isNaN.

Changed in version 2022.12:Added complex data type support.


[8]ページ先頭

©2009-2025 Movatter.jp