Integrate along the given axis using the composite trapezoidal rule.
Args:
y (Tensor): Input tensor to integrate. It's data type should be float16, float32, float64.
x (Tensor, optional): The sample points corresponding to the :attr:`y` values, the same type as :attr:`y`.
It is known that the size of :attr:`y` is `[d_1, d_2, ... , d_n]` and :math:`axis=k`, then the size of :attr:`x` can only be `[d_k]` or `[d_1, d_2, ... , d_n ]`.
If :attr:`x` is None, the sample points are assumed to be evenly spaced :attr:`dx` apart. The default is None.
dx (float, optional): The spacing between sample points when :attr:`x` is None. If neither :attr:`x` nor :attr:`dx` is provided then the default is :math:`dx = 1`.
axis (int, optional): The axis along which to integrate. The default is -1.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
sum_mode (str): use a different summation. The default is `sum`.
Returns:
Tensor, Definite integral of :attr:`y` is N-D tensor as approximated along a single axis by the trapezoidal rule.
"""
ifmode=='sum':
sum_mode=paddle.sum
elifmode=='cumsum':
sum_mode=paddle.cumsum
ifnot(xisNoneordxisNone):
raiseValueError("Not permitted to specify both x and dx input args.")
Integrate along the given axis using the composite trapezoidal rule. Use the sum method.
Args:
y (Tensor): Input tensor to integrate. It's data type should be float16, float32, float64.
x (Tensor, optional): The sample points corresponding to the :attr:`y` values, the same type as :attr:`y`.
It is known that the size of :attr:`y` is `[d_1, d_2, ... , d_n]` and :math:`axis=k`, then the size of :attr:`x` can only be `[d_k]` or `[d_1, d_2, ... , d_n ]`.
If :attr:`x` is None, the sample points are assumed to be evenly spaced :attr:`dx` apart. The default is None.
dx (float, optional): The spacing between sample points when :attr:`x` is None. If neither :attr:`x` nor :attr:`dx` is provided then the default is :math:`dx = 1`.
axis (int, optional): The axis along which to integrate. The default is -1.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
Returns:
Tensor, Definite integral of :attr:`y` is N-D tensor as approximated along a single axis by the trapezoidal rule.
If :attr:`y` is a 1D tensor, then the result is a float. If N is greater than 1, then the result is an (N-1)-D tensor.
Integrate along the given axis using the composite trapezoidal rule. Use the cumsum method
Args:
y (Tensor): Input tensor to integrate. It's data type should be float16, float32, float64.
x (Tensor, optional): The sample points corresponding to the :attr:`y` values, the same type as :attr:`y`.
It is known that the size of :attr:`y` is `[d_1, d_2, ... , d_n]` and :math:`axis=k`, then the size of :attr:`x` can only be `[d_k]` or `[d_1, d_2, ... , d_n ]`.
If :attr:`x` is None, the sample points are assumed to be evenly spaced :attr:`dx` apart. The default is None.
dx (float, optional): The spacing between sample points when :attr:`x` is None. If neither :attr:`x` nor :attr:`dx` is provided then the default is :math:`dx = 1`.
axis (int, optional): The axis along which to integrate. The default is -1.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
Returns:
Tensor, Definite integral of :attr:`y` is N-D tensor as approximated along a single axis by the trapezoidal rule.