quantnn/generic/__init__.py
def trapz(module, y, x, dimension):
    """
    Numeric integration using  trapezoidal rule.

    Arguments:
        module: The backend array corresponding to the given array.
        y: Rank k-tensor to integrate over the given dimension.
        x: The domain values to integrate over.
        dimension: The dimension to integrate over.

    Return:
       The rank k-1 tensor containing the numerical integrals corresponding
       to y.
    """
    if len(x) == y.shape[dimension] + 1:
        dx = x[1:] - x[:-1]
        n = len(y.shape)
        dx_shape = [1] * n
        dx_shape[dimension] = -1
        dx = reshape(module, dx, dx_shape)
        return module.sum(y * dx, dimension)

    if module in [np, ma, torch, jnp]:
        return module.trapz(y, x=x, axis=dimension)
    elif module == tf:
        return _trapz(module, y, x, dimension)
    raise UnknownModuleException(f"Module {module.__name__} not supported.")

    Numeric integration using  trapezoidal rule.

    Arguments:
        module: The backend array corresponding to the given array.
        y: Rank k-tensor to integrate over the given dimension.
        x: The domain values to integrate over.
        dimension: The dimension to integrate over.

    Return:
       The rank k-1 tensor containing the numerical integrals corresponding
       to y.
    
Numeric integration using  trapezoidal rule.
Numeric integration using trapezoidal rule .
def trapz(module, y, x, dimension):
    if len(x) == y.shape[dimension] + 1:
        dx = x[1:] - x[:-1]
        n = len(y.shape)
        dx_shape = [1] * n
        dx_shape[dimension] = -1
        dx = reshape(module, dx, dx_shape)
        return module.sum(y * dx, dimension)
    if module in [np, ma, torch, jnp]:
        return module.trapz(y, x=x, axis=dimension)
    elif module == tf:
        return _trapz(module, y, x, dimension)
    raise UnknownModuleException(f"Module {module.__name__} not supported.")
def trapz ( module , y , x , dimension ) : if len ( x ) == y . shape [ dimension ] + 1 : dx = x [ 1 : ] - x [ : - 1 ] n = len ( y . shape ) dx_shape = [ 1 ] * n dx_shape [ dimension ] = - 1 dx = reshape ( module , dx , dx_shape ) return module . sum ( y * dx , dimension ) if module in [ np , ma , torch , jnp ] : return module . trapz ( y , x = x , axis = dimension ) elif module == tf : return _trapz ( module , y , x , dimension ) raise UnknownModuleException ( f"Module {module.__name__} not supported." )
Numeric integration using  trapezoidal rule.
Numeric integration using trapezoidal rule .
"""
    Numeric integration using  trapezoidal rule.

    Arguments:
        module: The backend array corresponding to the given array.
        y: Rank k-tensor to integrate over the given dimension.
        x: The domain values to integrate over.
        dimension: The dimension to integrate over.

    Return:
       The rank k-1 tensor containing the numerical integrals corresponding
       to y.
    """
module
The backend array corresponding to the given array.
The backend array corresponding to the given array .
y
Rank k-tensor to integrate over the given dimension.
Rank k - tensor to integrate over the given dimension .
x
The domain values to integrate over.
The domain values to integrate over .
dimension
The dimension to integrate over.
The dimension to integrate over .