o
    h                     @   sH   d dl mZmZ d dlmZ d dlmZ ddlmZ G dd deZ	dS )	    )array_namespace	np_compat)cached_property)roots_legendre   )	FixedRulec                   @   s&   e Zd ZdZdddZedd ZdS )GaussLegendreQuadratureaw  
    Gauss-Legendre quadrature.

    Parameters
    ----------
    npoints : int
        Number of nodes for the higher-order rule.

    xp : array_namespace, optional
        The namespace for the node and weight arrays. Default is None, where NumPy is
        used.

    Examples
    --------
    Evaluate a 1D integral. Note in this example that ``f`` returns an array, so the
    estimates will also be arrays.

    >>> import numpy as np
    >>> from scipy.integrate import cubature
    >>> from scipy.integrate._rules import GaussLegendreQuadrature
    >>> def f(x):
    ...     return np.cos(x)
    >>> rule = GaussLegendreQuadrature(21) # Use 21-point GaussLegendre
    >>> a, b = np.array([0]), np.array([1])
    >>> rule.estimate(f, a, b) # True value sin(1), approximately 0.84147
     array([0.84147098])
    >>> rule.estimate_error(f, a, b)
     array([1.11022302e-16])
    Nc                 C   s6   |dk rt d|| _|d u rt}t|d| _d S )N   z5At least 2 nodes required for Gauss-Legendre cubaturer   )
ValueErrornpointsr   r   emptyxp)selfr   r    r   Z/var/www/vscode/kcb/lib/python3.10/site-packages/scipy/integrate/_rules/_gauss_legendre.py__init__)   s   z GaussLegendreQuadrature.__init__c                 C   s6   t | j\}}| jj|| jjd| jj|| jjdfS )N)dtype)r   r   r   asarrayfloat64)r   nodesweightsr   r   r   nodes_and_weights6   s   z)GaussLegendreQuadrature.nodes_and_weights)N)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   
   s
    
r   N)
scipy._lib._array_apir   r   	functoolsr   scipy.specialr   _baser   r   r   r   r   r   <module>   s
    