(x_gpu, dx=1.0, even='avg', handle=None)
return float_type(dx)*result
Implementation of composite Simpson's rule similar to 
    scipy.integrate.simps.

    Integrate x_gpu with spacing dx using composite Simpson's rule.
    If there are an even number of samples, N, then there are an odd 
    number of intervals (N-1), but Simpson's rule requires an even number 
    of intervals. The parameter 'even' controls how this is handled.

    Parameters
    ----------
    x_gpu : pycuda.gpuarray.GPUArray
        Input array to integrate.
    dx : scalar
        Spacing.
    even : str {'avg', 'first', 'last'}, optional
        'avg' : Average two results:1) use the first N-2 intervals with
                  a trapezoidal rule on the last interval and 2) use the last
                  N-2 intervals with a trapezoidal rule on the first interval.
        'first' : Use Simpson's rule for the first N-2 intervals with
                a trapezoidal rule on the last interval.
        'last' : Use Simpson's rule for the last N-2 intervals with a
               trapezoidal rule on the first interval.
    handle : int
        CUBLAS context. If no context is specified, the default handle from
        `skcuda.misc._global_cublas_handle` is used.

    Returns
    -------
    result : float
        Definite integral as approximated by the composite Simpson's rule.

    Examples
    --------
    >>> import pycuda.autoinit
    >>> import pycuda.gpuarray
    >>> import numpy as np
    >>> import integrate
    >>> integrate.init()
    >>> x_gpu = gpuarray.arange(0,10,dtype=np.float64)
    >>> integrate.simps(x_gpu)
    40.5
    >>> x_gpu**=3
    >>> integrate.simps(x_gpu)
    1642.5
    >>> integrate.simps(x_gpu, even='first')
    1644.5
Implementation of composite Simpson's rule similar to 
    scipy.integrate.simps.
Implementation of composite Simpson s rule similar to scipy . integrate . simps .
def simps(x_gpu, dx=1.0, even='avg', handle=None):
    """
    Implementation of composite Simpson's rule similar to 
    scipy.integrate.simps.

    Integrate x_gpu with spacing dx using composite Simpson's rule.
    If there are an even number of samples, N, then there are an odd 
    number of intervals (N-1), but Simpson's rule requires an even number 
    of intervals. The parameter 'even' controls how this is handled.

    Parameters
    ----------
    x_gpu : pycuda.gpuarray.GPUArray
        Input array to integrate.
    dx : scalar
        Spacing.
    even : str {'avg', 'first', 'last'}, optional
        'avg' : Average two results:1) use the first N-2 intervals with
                  a trapezoidal rule on the last interval and 2) use the last
                  N-2 intervals with a trapezoidal rule on the first interval.
        'first' : Use Simpson's rule for the first N-2 intervals with
                a trapezoidal rule on the last interval.
        'last' : Use Simpson's rule for the last N-2 intervals with a
               trapezoidal rule on the first interval.
    handle : int
        CUBLAS context. If no context is specified, the default handle from
        `skcuda.misc._global_cublas_handle` is used.

    Returns
    -------
    result : float
        Definite integral as approximated by the composite Simpson's rule.

    Examples
    --------
    >>> import pycuda.autoinit
    >>> import pycuda.gpuarray
    >>> import numpy as np
    >>> import integrate
    >>> integrate.init()
    >>> x_gpu = gpuarray.arange(0,10,dtype=np.float64)
    >>> integrate.simps(x_gpu)
    40.5
    >>> x_gpu**=3
    >>> integrate.simps(x_gpu)
    1642.5
    >>> integrate.simps(x_gpu, even='first')
    1644.5
    """

    if handle is None:
        handle = misc._global_cublas_handle

    if len(x_gpu.shape) > 1:
        raise ValueError('input array must be 1D')
    if np.iscomplex(dx):
        raise ValueError('dx must be real')

    float_type = x_gpu.dtype.type
    if float_type == np.complex64:
        cublas_func = cublas.cublasCdotu
    elif float_type == np.float32:
        cublas_func = cublas.cublasSdot
    elif float_type == np.complex128:
        cublas_func = cublas.cublasZdotu
    elif float_type == np.float64:
        cublas_func = cublas.cublasDdot
    else:
        raise ValueError('unsupported input type')

    simps_mult_gpu = gen_simps_mult(x_gpu.size, float_type, even)
    result = cublas_func(handle, x_gpu.size, x_gpu.gpudata, 1,
                         simps_mult_gpu.gpudata, 1)

    return float_type(dx)*result
def simps ( x_gpu , dx = 1.0 , even = 'avg' , handle = None ) : if handle is None : handle = misc . _global_cublas_handle if len ( x_gpu . shape ) > 1 : raise ValueError ( 'input array must be 1D' ) if np . iscomplex ( dx ) : raise ValueError ( 'dx must be real' ) float_type = x_gpu . dtype . type if float_type == np . complex64 : cublas_func = cublas . cublasCdotu elif float_type == np . float32 : cublas_func = cublas . cublasSdot elif float_type == np . complex128 : cublas_func = cublas . cublasZdotu elif float_type == np . float64 : cublas_func = cublas . cublasDdot else : raise ValueError ( 'unsupported input type' ) simps_mult_gpu = gen_simps_mult ( x_gpu . size , float_type , even ) result = cublas_func ( handle , x_gpu . size , x_gpu . gpudata , 1 , simps_mult_gpu . gpudata , 1 ) return float_type ( dx ) * result