r"""Calculates the sum for each element :math:`x_i` of the input tensor :math:`x` with the respective element :math:`y_i` of the input tensor :math:`y`.
r"""Element-wise addition.
Calculates the sum for each element :math:`x_i` of the input tensor :math:`x` with the respective element :math:`y_i` of the input tensor :math:`y`.
Args:
x: first input tensor. Should have a numeric data type.
y: second input tensor. Must be compatible with ``x`` (see :ref:`broadcasting-rule` ). Should have a numeric data type.
y: second input tensor. Must be compatible with :math:`x` (see :ref:`broadcasting-rule` ). Should have a numeric data type.
Returns:
A tensor containing the element-wise sums. The returned tensor must have a data type determined by :ref:`dtype-promotion`.
A tensor containing the element-wise sums.
The returned tensor must have a data type determined by :ref:`dtype-promotion`.
r"""Calculates the difference for each element :math:`x_i` of the input tensor :math:`x` with the respective element :math:`y` of the input tensor :math:`y`.
r"""Element-wise subtraction.
Calculates the difference for each element :math:`x_i` of the input tensor :math:`x` with the respective element :math:`y` of the input tensor :math:`y`.
The result of :math:`x_i - y_i` must be the same as :math:`x_i + (-y_i)` and must be governed by the same floating-point rules as addition.
(See :func:`~.functional.add` ).
Args:
x: first input tensor. Should have a numeric data type.
y: second input tensor. Must be compatible with ``x`` (see :ref:`broadcasting-rule` ). Should have a numeric data type.
y: second input tensor. Must be compatible with :math:`x` (see :ref:`broadcasting-rule` ). Should have a numeric data type.
Returns:
A tensor containing the element-wise differences. The returned tensor must have a data type determined by :ref:`dtype-promotion`.
A tensor containing the element-wise differences.
The returned tensor must have a data type determined by :ref:`dtype-promotion`.
r"""Calculates the division for each element :math:`x_i` of the input tensor :math:`x` with the respective element :math:`y_i` of the input tensor :math:`y`.
r"""Element-wise division.
Calculates the division for each element :math:`x_i` of the input tensor :math:`x` with the respective element :math:`y_i` of the input tensor :math:`y`.
Args:
x: dividend input tensor. Should have a numeric data type.
y: divisor input tensor. Must be compatible with ``x``` (see :ref:`broadcasting-rule` ). Should have a numeric data type.
y: divisor input tensor. Must be compatible with :math:`x`` (see :ref:`broadcasting-rule` ). Should have a numeric data type.
Returns:
A tensor containing the element-wise results. The returned tensor must have a data type determined by :ref:`dtype-promotion`.
A tensor containing the element-wise results.
The returned tensor must have a data type determined by :ref:`dtype-promotion`.
* If :math:`x` is a negative (i.e., less than ``0``) finite number and :math:`y` is ``-infinity``, the result is ``+0``.
* If :math:`x` and :math:`y` have the same mathematical sign and are both nonzero finite numbers, the result has a positive mathematical sign.
* If :math:`x` and :math:`y` have different mathematical signs and are both nonzero finite numbers, the result has a negative mathematical sign.
* In the remaining cases, where neither ``-infinity``, ``+0``, ``-0``, nor ``NaN`` is involved, the quotient must be computed and rounded to the nearest representable value according to IEEE 754-2019 and a supported rounding mode. If the magnitude is too large to represent, the operation overflows and the result is an infinity of appropriate mathematical sign. If the magnitude is too small to represent, the operation underflows and the result is a zero of appropriate mathematical sign.
* In the remaining cases, where neither ``-infinity``, ``+0``, ``-0``, nor ``NaN`` is involved,
the quotient must be computed and rounded to the nearest representable value according to IEEE 754-2019 and a supported rounding mode.
If the magnitude is too large to represent, the operation overflows and the result is an infinity of appropriate mathematical sign.
If the magnitude is too small to represent, the operation underflows and the result is a zero of appropriate mathematical sign.
* If :math:`x` is a negative (i.e., less than ``0``) finite number and :math:`y` is ``-infinity``, the result is ``+0``.
* If :math:`x` and :math:`y` have the same mathematical sign and are both nonzero finite numbers, the result has a positive mathematical sign.
* If :math:`x` and :math:`y` have different mathematical signs and are both nonzero finite numbers, the result has a negative mathematical sign.
* In the remaining cases, where neither ``-infinity``, ``+0``, ``-0``, nor ``NaN`` is involved, the quotient must be computed and rounded to the nearest representable value according to IEEE 754-2019 and a supported rounding mode. If the magnitude is too large to represent, the operation overflows and the result is an infinity of appropriate mathematical sign. If the magnitude is too small to represent, the operation underflows and the result is a zero of appropriate mathematical sign.
* In the remaining cases, where neither ``-infinity``, ``+0``, ``-0``, nor ``NaN`` is involved,
the quotient must be computed and rounded to the nearest representable value according to IEEE 754-2019 and a supported rounding mode.
If the magnitude is too large to represent, the operation overflows and the result is an infinity of appropriate mathematical sign.
If the magnitude is too small to represent, the operation underflows and the result is a zero of appropriate mathematical sign.
r"""Calculates an implementation-dependent approximation of exponentiation by
r"""Element-wise power.
Calculates an implementation-dependent approximation of exponentiation by
raising each element :math:`x_i` (the base) of the input tensor :math:`x` to
the power of :math:`y_i` (the exponent), where :math:`y_i` is the corresponding element of the input tensor :math:`y`.
Args:
x: first input tensor whose elements correspond to the exponentiation base. Should have a numeric data type.
y: second input tensor whose elements correspond to the exponentiation exponent. Must be compatible with `x` (see :ref:`broadcasting-rule` ). Should have a numeric data type.
y: second input tensor whose elements correspond to the exponentiation exponent.
Must be compatible with `x` (see :ref:`broadcasting-rule` ). Should have a numeric data type.
Returns:
A tensor containing the element-wise results. The returned tensor must have a data type determined by :ref:`dtype-promotion`.
A tensor containing the element-wise results.
The returned tensor must have a data type determined by :ref:`dtype-promotion`.
* If :math:`x_i` is not equal to ``1`` and :math:`y_i` is ``NaN``, the result is ``NaN``.
* If :math:`y_i` is ``+0``, the result is ``1``, even if ``x_i`` is ``NaN``.
* If :math:`y_i` is ``-0``, the result is ``1``, even if ``x_i`` is ``NaN``.
* If :math:`x_i` is ``NaN`` and ``y_i`` is not equal to ``0``, the result is ``NaN``.
* If ``abs(x_i)`` is greater than ``1`` and ``y_i`` is ``+infinity``, the result is ``+infinity``.
* If ``abs(x_i)`` is greater than ``1`` and ``y_i`` is ``-infinity``, the result is ``+0``.
* If ``abs(x_i)`` is ``1`` and ``y_i`` is ``+infinity``, the result is ``1``.
* If ``abs(x_i)`` is ``1`` and ``y_i`` is ``-infinity``, the result is ``1``.
* If ``x_i`` is ``1`` and ``y_i`` is not ``NaN``, the result is ``1``.
* If ``abs(x_i)`` is less than ``1`` and ``y_i`` is ``+infinity``, the result is ``+0``.
* If ``abs(x_i)`` is less than ``1`` and ``y_i`` is ``-infinity``, the result is ``+infinity``.
* If ``x_i`` is ``+infinity`` and ``y_i`` is greater than 0, the result is ``+infinity``.
* If ``x_i`` is ``+infinity`` and ``y_i`` is less than 0, the result is ``+0``.
* If ``x_i`` is ``-infinity``, ``y_i`` is greater than 0, and ``y_i`` is an odd integer value, the result is ``-infinity``.
* If ``x_i`` is ``-infinity``, ``y_i`` is greater than 0, and ``y_i`` is not an odd integer value, the result is ``+infinity``.
* If ``x_i`` is ``-infinity``, ``y_i`` is less than 0, and ``y_i`` is an odd integer value, the result is ``-0``.
* If ``x_i`` is ``-infinity``, ``y_i`` is less than 0, and ``y_i`` is not an odd integer value, the result is ``+0``.
* If ``x_i`` is ``+0`` and ``y_i`` is greater than 0, the result is ``+0``.
* If ``x_i`` is ``+0`` and ``y_i`` is less than 0, the result is ``+infinity``.
* If ``x_i`` is ``-0``, ``y_i`` is greater than 0, and ``y_i`` is an odd integer value, the result is ``-0``.
* If ``x_i`` is ``-0``, ``y_i`` is greater than 0, and ``y_i`` is not an odd integer value, the result is ``+0``.
* If ``x_i`` is ``-0``, ``y_i`` is less than 0, and ``y_i`` is an odd integer value, the result is ``-infinity``.
* If ``x_i`` is ``-0``, ``y_i`` is less than 0, and ``y_i`` is not an odd integer value, the result is ``+infinity``.
* If ``x_i`` is less than 0, ``x_i`` is a finite number, ``y_i`` is a finite number, and ``y_i`` is not an integer value, the result is ``NaN``.
* If :math:`y_i` is ``+0``, the result is ``1``, even if :math:`x_i` is ``NaN``.
* If :math:`y_i` is ``-0``, the result is ``1``, even if :math:`x_i` is ``NaN``.
* If :math:`x_i` is ``NaN`` and :math:`y_i` is not equal to ``0``, the result is ``NaN``.
* If :math:`\abs{x_i}` is greater than ``1`` and :math:`y_i` is ``+infinity``, the result is ``+infinity``.
* If :math:`\abs{x_i}` is greater than ``1`` and :math:`y_i` is ``-infinity``, the result is ``+0``.
* If :math:`\abs{x_i}` is ``1`` and :math:`y_i` is ``+infinity``, the result is ``1``.
* If :math:`\abs{x_i}` is ``1`` and :math:`y_i` is ``-infinity``, the result is ``1``.
* If :math:`x_i` is ``1`` and :math:`y_i` is not ``NaN``, the result is ``1``.
* If :math:`\abs{x_i}` is less than ``1`` and :math:`y_i` is ``+infinity``, the result is ``+0``.
* If :math:`\abs{x_i}` is less than ``1`` and :math:`y_i` is ``-infinity``, the result is ``+infinity``.
* If :math:`x_i` is ``+infinity`` and :math:`y_i` is greater than ``0``, the result is ``+infinity``.
* If :math:`x_i` is ``+infinity`` and :math:`y_i` is less than ``0``, the result is ``+0``.
* If :math:`x_i` is ``-infinity``, :math:`y_i` is greater than ``0``, and :math:`y_i` is an odd integer value, the result is ``-infinity``.
* If :math:`x_i` is ``-infinity``, :math:`y_i` is greater than ``0``, and :math:`y_i` is not an odd integer value, the result is ``+infinity``.
* If :math:`x_i` is ``-infinity``, :math:`y_i` is less than ``0``, and :math:`y_i` is an odd integer value, the result is ``-0``.
* If :math:`x_i` is ``-infinity``, :math:`y_i` is less than ``0``, and :math:`y_i` is not an odd integer value, the result is ``+0``.
* If :math:`x_i` is ``+0`` and :math:`y_i` is greater than ``0``, the result is ``+0``.
* If :math:`x_i` is ``+0`` and :math:`y_i` is less than ``0``, the result is ``+infinity``.
* If :math:`x_i` is ``-0``, :math:`y_i` is greater than ``0``, and :math:`y_i` is an odd integer value, the result is ``-0``.
* If :math:`x_i` is ``-0``, :math:`y_i` is greater than ``0``, and :math:`y_i` is not an odd integer value, the result is ``+0``.
* If :math:`x_i` is ``-0``, :math:`y_i` is less than ``0``, and :math:`y_i` is an odd integer value, the result is ``-infinity``.
* If :math:`x_i` is ``-0``, :math:`y_i` is less than ``0``, and :math:`y_i` is not an odd integer value, the result is ``+infinity``.
* If :math:`x_i` is less than 0, :math:`x_i` is a finite number, :math:`y_i` is a finite number, and :math:`y_i` is not an integer value, the result is ``NaN``.