quantnn/generic/__init__.py
def cumtrapz(module, y, x, dimension):
    """
    Cumulative integral along given axis.

    The returned tensor has the same shape as the input tensor y and the
    values correspond to the numeric integral computed up to the corresponding
    value of the provided x vector assuming that the function described by y
    is 0 outside of the domain described by x.

    Arguments:
        module: The backend array corresponding to the given array.
        y: Rank k-tensor to accumulate along given dimension.
        dimension: The dimension to sum over.

    Return:
       The rank k tensor containing the cumulative integral along the
       given dimension.
    """
    n = len(y.shape)
    if len(x.shape) < n:
        x_shape = [1] * n
        x_shape[dimension] = -1
        x = reshape(module, x, x_shape)

    selection = [slice(0, None)] * n
    selection_l = selection[:]
    selection_l[dimension] = slice(0, -1)
    selection_l = tuple(selection_l)
    selection_r = selection[:]
    selection_r[dimension] = slice(1, None)
    selection_r = tuple(selection_r)

    dx = x[selection_r] - x[selection_l]

    if dx.shape[dimension] == y.shape[dimension]:
        y_int = cumsum(module, dx * y, dimension)
    elif dx.shape[dimension] == y.shape[dimension] - 1:
        y_int = cumsum(
            module, 0.5 * (dx * y[selection_l] + dx * y[selection_r]), dimension
        )
    else:
        raise InvalidDimensionException(
            "To integrate y over x, x must have exactly as many or one more "
            "along dimension."
        )

    return pad_zeros_left(module, y_int, 1, dimension)

    Cumulative integral along given axis.

    The returned tensor has the same shape as the input tensor y and the
    values correspond to the numeric integral computed up to the corresponding
    value of the provided x vector assuming that the function described by y
    is 0 outside of the domain described by x.

    Arguments:
        module: The backend array corresponding to the given array.
        y: Rank k-tensor to accumulate along given dimension.
        dimension: The dimension to sum over.

    Return:
       The rank k tensor containing the cumulative integral along the
       given dimension.
    
Cumulative integral along given axis.
The returned tensor has the same shape as the input tensor y and the
values correspond to the numeric integral computed up to the corresponding
value of the provided x vector assuming that the function described by y
is 0 outside of the domain described by x.
Cumulative integral along given axis . The returned tensor has the same shape as the input tensor y and the values correspond to the numeric integral computed up to the corresponding value of the provided x vector assuming that the function described by y is 0 outside of the domain described by x .
def cumtrapz(module, y, x, dimension):
    n = len(y.shape)
    if len(x.shape) < n:
        x_shape = [1] * n
        x_shape[dimension] = -1
        x = reshape(module, x, x_shape)
    selection = [slice(0, None)] * n
    selection_l = selection[:]
    selection_l[dimension] = slice(0, -1)
    selection_l = tuple(selection_l)
    selection_r = selection[:]
    selection_r[dimension] = slice(1, None)
    selection_r = tuple(selection_r)
    dx = x[selection_r] - x[selection_l]
    if dx.shape[dimension] == y.shape[dimension]:
        y_int = cumsum(module, dx * y, dimension)
    elif dx.shape[dimension] == y.shape[dimension] - 1:
        y_int = cumsum(
            module, 0.5 * (dx * y[selection_l] + dx * y[selection_r]), dimension
        )
    else:
        raise InvalidDimensionException(
            "To integrate y over x, x must have exactly as many or one more "
            "along dimension."
        )
    return pad_zeros_left(module, y_int, 1, dimension)
def cumtrapz ( module , y , x , dimension ) : n = len ( y . shape ) if len ( x . shape ) < n : x_shape = [ 1 ] * n x_shape [ dimension ] = - 1 x = reshape ( module , x , x_shape ) selection = [ slice ( 0 , None ) ] * n selection_l = selection [ : ] selection_l [ dimension ] = slice ( 0 , - 1 ) selection_l = tuple ( selection_l ) selection_r = selection [ : ] selection_r [ dimension ] = slice ( 1 , None ) selection_r = tuple ( selection_r ) dx = x [ selection_r ] - x [ selection_l ] if dx . shape [ dimension ] == y . shape [ dimension ] : y_int = cumsum ( module , dx * y , dimension ) elif dx . shape [ dimension ] == y . shape [ dimension ] - 1 : y_int = cumsum ( module , 0.5 * ( dx * y [ selection_l ] + dx * y [ selection_r ] ) , dimension ) else : raise InvalidDimensionException ( "To integrate y over x, x must have exactly as many or one more " "along dimension." ) return pad_zeros_left ( module , y_int , 1 , dimension )
Cumulative integral along given axis.
Cumulative integral along given axis .
"""
    Cumulative integral along given axis.

    The returned tensor has the same shape as the input tensor y and the
    values correspond to the numeric integral computed up to the corresponding
    value of the provided x vector assuming that the function described by y
    is 0 outside of the domain described by x.

    Arguments:
        module: The backend array corresponding to the given array.
        y: Rank k-tensor to accumulate along given dimension.
        dimension: The dimension to sum over.

    Return:
       The rank k tensor containing the cumulative integral along the
       given dimension.
    """
module
The backend array corresponding to the given array.
The backend array corresponding to the given array .
y
Rank k-tensor to accumulate along given dimension.
Rank k - tensor to accumulate along given dimension .
x
dimension
The dimension to sum over.
The dimension to sum over .