o
    Ö­jq  ã                	   @   sü   d Z ddlZddlZddlmZ ddlmZ ddlm	Z	m
Z
mZmZmZ ddlmZmZ dd	lmZ dd
lmZ dd„ Zejdd„ ƒZdd„ Zdd„ Zd"dd„Zddddej ejfddddf	dd„Zdd„ Zdd„ Zdd„ Z ej ejfddfd d!„Z!dS )#z'Routines for numerical differentiation.é    N)Únorm)ÚLinearOperatoré   )ÚissparseÚ
csc_matrixÚ
csr_matrixÚ
coo_matrixÚfindé   )Úgroup_denseÚgroup_sparse)Úarray_namespace)Úarray_api_extrac                 C   sÜ  |dkrt j|td�}n|dkrt  |¡}t j|td�}ntdƒ‚t  |t j k|t jk@ ¡r3||fS || }| ¡ }| | }	||  }
|dkr‹| | }||k ||kB }t  |¡t  	|	|
¡k}|||@   d9  < |
|	k| @ }|
| | ||< |
|	k | @ }|	|  | ||< ||fS |dkrê|	|k|
|k@ }|
|	k| @ }t  
|| d|
|  | ¡||< d||< |
|	k | @ }t  
|| d|	|  | ¡ ||< d||< t  
|
|	¡| }| t  |¡|k@ }|| ||< d||< ||fS )	a¨  Adjust final difference scheme to the presence of bounds.

    Parameters
    ----------
    x0 : ndarray, shape (n,)
        Point at which we wish to estimate derivative.
    h : ndarray, shape (n,)
        Desired absolute finite difference steps.
    num_steps : int
        Number of `h` steps in one direction required to implement finite
        difference scheme. For example, 2 means that we need to evaluate
        f(x0 + 2 * h) or f(x0 - 2 * h)
    scheme : {'1-sided', '2-sided'}
        Whether steps in one or both directions are required. In other
        words '1-sided' applies to forward and backward schemes, '2-sided'
        applies to center schemes.
    lb : ndarray, shape (n,)
        Lower bounds on independent variables.
    ub : ndarray, shape (n,)
        Upper bounds on independent variables.

    Returns
    -------
    h_adjusted : ndarray, shape (n,)
        Adjusted absolute step sizes. Step size decreases only if a sign flip
        or switching to one-sided scheme doesn't allow to take a full step.
    use_one_sided : ndarray of bool, shape (n,)
        Whether to switch to one-sided scheme. Informative only for
        ``scheme='2-sided'``.
    ú1-sided©Údtypeú2-sidedz(`scheme` must be '1-sided' or '2-sided'.éÿÿÿÿç      à?TF)ÚnpÚ	ones_likeÚboolÚabsÚ
zeros_likeÚ
ValueErrorÚallÚinfÚcopyÚmaximumÚminimum)Úx0ÚhÚ	num_stepsÚschemeÚlbÚubÚuse_one_sidedÚh_totalÚ
h_adjustedÚ
lower_distÚ
upper_distÚxÚviolatedÚfittingÚforwardÚbackwardÚcentralÚmin_distÚadjusted_central© r3   úT/var/www/html/CropPilot/venv/lib/python3.10/site-packages/scipy/optimize/_numdiff.pyÚ_adjust_scheme_to_bounds   sN   
îÿ
ÿr5   c                 C   s–   t  t j¡j}d}t  | t j¡rt  | ¡j}t  | ¡j}d}t  |t j¡r7t  |¡j}|r7||k r7t  |¡j}|dv r?|d S |dv rG|d S tdƒ‚)a¨  
    Calculates relative EPS step to use for a given data type
    and numdiff step method.

    Progressively smaller steps are used for larger floating point types.

    Parameters
    ----------
    f0_dtype: np.dtype
        dtype of function evaluation

    x0_dtype: np.dtype
        dtype of parameter vector

    method: {'2-point', '3-point', 'cs'}

    Returns
    -------
    EPS: float
        relative step size. May be np.float16, np.float32, np.float64

    Notes
    -----
    The default relative step will be np.float64. However, if x0 or f0 are
    smaller floating point types (np.float16, np.float32), then the smallest
    floating point type is chosen.
    FT)ú2-pointÚcsr   )ú3-pointgUUUUUUÕ?zBUnknown step method, should be one of {'2-point', '3-point', 'cs'})	r   ÚfinfoÚfloat64ÚepsÚ
issubdtypeÚinexactr   ÚitemsizeÚRuntimeError)Úx0_dtypeÚf0_dtypeÚmethodÚEPSÚx0_is_fpÚx0_itemsizeÚf0_itemsizer3   r3   r4   Ú_eps_for_method\   s   rG   c              
   C   s–   |dk  t¡d d }t|j|j|ƒ}| du r&|| t dt |¡¡ }|S | | t |¡ }|| | }t |dk|| t dt |¡¡ |¡}|S )az  
    Computes an absolute step from a relative step for finite difference
    calculation.

    Parameters
    ----------
    rel_step: None or array-like
        Relative step for the finite difference calculation
    x0 : np.ndarray
        Parameter vector
    f0 : np.ndarray or scalar
    method : {'2-point', '3-point', 'cs'}

    Returns
    -------
    h : float
        The absolute step size

    Notes
    -----
    `h` will always be np.float64. However, if `x0` or `f0` are
    smaller floating point dtypes (e.g. np.float32), then the absolute
    step size will be calculated from the smallest floating point size.
    r   r   r
   Nç      ð?)ÚastypeÚfloatrG   r   r   r   r   Úwhere)Úrel_stepr    Úf0rB   Úsign_x0ÚrstepÚabs_stepÚdxr3   r3   r4   Ú_compute_absolute_step’   s   ÷
þrR   c                 C   sJ   dd„ | D ƒ\}}|j dkrt ||j¡}|j dkr!t ||j¡}||fS )aa  
    Prepares new-style bounds from a two-tuple specifying the lower and upper
    limits for values in x0. If a value is not bound then the lower/upper bound
    will be expected to be -np.inf/np.inf.

    Examples
    --------
    >>> _prepare_bounds([(0, 1, 2), (1, 2, np.inf)], [0.5, 1.5, 2.5])
    (array([0., 1., 2.]), array([ 1.,  2., inf]))
    c                 s   s   � | ]
}t j|td �V  qdS )r   N)r   ÚasarrayrJ   )Ú.0Úbr3   r3   r4   Ú	<genexpr>Î   s   € z"_prepare_bounds.<locals>.<genexpr>r   )Úndimr   ÚresizeÚshape)Úboundsr    r$   r%   r3   r3   r4   Ú_prepare_boundsÃ   s   

r[   c                 C   sØ   t | ƒr	t| ƒ} nt | ¡} | dk tj¡} | jdkrtdƒ‚| j\}}|du s-t 	|¡r9tj
 |¡}| |¡}nt |¡}|j|fkrHtdƒ‚| dd…|f } t | ƒr^t||| j| jƒ}nt||| ƒ}| ¡ ||< |S )aÊ  Group columns of a 2-D matrix for sparse finite differencing [1]_.

    Two columns are in the same group if in each row at least one of them
    has zero. A greedy sequential algorithm is used to construct groups.

    Parameters
    ----------
    A : array_like or sparse matrix, shape (m, n)
        Matrix of which to group columns.
    order : int, iterable of int with shape (n,) or None
        Permutation array which defines the order of columns enumeration.
        If int or None, a random permutation is used with `order` used as
        a random seed. Default is 0, that is use a random permutation but
        guarantee repeatability.

    Returns
    -------
    groups : ndarray of int, shape (n,)
        Contains values from 0 to n_groups-1, where n_groups is the number
        of found groups. Each value ``groups[i]`` is an index of a group to
        which ith column assigned. The procedure was helpful only if
        n_groups is significantly less than n.

    References
    ----------
    .. [1] A. Curtis, M. J. D. Powell, and J. Reid, "On the estimation of
           sparse Jacobian matrices", Journal of the Institute of Mathematics
           and its Applications, 13 (1974), pp. 117-120.
    r   r   z`A` must be 2-dimensional.Nz`order` has incorrect shape.)r   r   r   Ú
atleast_2drI   Úint32rW   r   rY   ÚisscalarÚrandomÚRandomStateÚpermutationrS   r   ÚindicesÚindptrr   r   )ÚAÚorderÚmÚnÚrngÚgroupsr3   r3   r4   Úgroup_columnsØ   s&   




rj   r8   Fr3   c              
      sª  |dvrt d|› d�ƒ‚tˆƒ‰tjˆ ˆ¡dˆd�}ˆj}ˆ |jd¡r(|j}ˆ ||¡‰ˆj	dkr7t dƒ‚t
|ˆƒ\}}|jˆjksJ|jˆjkrNt dƒ‚|rdt t |¡¡r`t t |¡¡sdt d	ƒ‚ˆd
u rji ‰‡ ‡‡‡‡fdd„}|d
u r}|ˆƒ}nt |¡}|j	dkr‹t dƒ‚t ˆ|k ˆ|kB ¡ršt dƒ‚|r°|d
u r¨tˆj|j|ƒ}t|ˆ|||ƒS |d
u r¼t|ˆ||ƒ}n-ˆdk t¡d d }|}ˆ| ˆ }t |dktˆj|j|ƒ| t dt ˆ¡¡ |¡}|dkrùtˆ|dd||ƒ\}}n|dk�r
tˆ|dd||ƒ\}}n|dk�rd}|d
u �rt|ˆ||||ƒS t|ƒ�s0t|ƒdk�r0|\}}n|}t|ƒ}t|ƒ�r@t|ƒ}nt |¡}t |¡}t|ˆ||||||ƒS )aJ  Compute finite difference approximation of the derivatives of a
    vector-valued function.

    If a function maps from R^n to R^m, its derivatives form m-by-n matrix
    called the Jacobian, where an element (i, j) is a partial derivative of
    f[i] with respect to x[j].

    Parameters
    ----------
    fun : callable
        Function of which to estimate the derivatives. The argument x
        passed to this function is ndarray of shape (n,) (never a scalar
        even if n=1). It must return 1-D array_like of shape (m,) or a scalar.
    x0 : array_like of shape (n,) or float
        Point at which to estimate the derivatives. Float will be converted
        to a 1-D array.
    method : {'3-point', '2-point', 'cs'}, optional
        Finite difference method to use:
            - '2-point' - use the first order accuracy forward or backward
                          difference.
            - '3-point' - use central difference in interior points and the
                          second order accuracy forward or backward difference
                          near the boundary.
            - 'cs' - use a complex-step finite difference scheme. This assumes
                     that the user function is real-valued and can be
                     analytically continued to the complex plane. Otherwise,
                     produces bogus results.
    rel_step : None or array_like, optional
        Relative step size to use. If None (default) the absolute step size is
        computed as ``h = rel_step * sign(x0) * max(1, abs(x0))``, with
        `rel_step` being selected automatically, see Notes. Otherwise
        ``h = rel_step * sign(x0) * abs(x0)``. For ``method='3-point'`` the
        sign of `h` is ignored. The calculated step size is possibly adjusted
        to fit into the bounds.
    abs_step : array_like, optional
        Absolute step size to use, possibly adjusted to fit into the bounds.
        For ``method='3-point'`` the sign of `abs_step` is ignored. By default
        relative steps are used, only if ``abs_step is not None`` are absolute
        steps used.
    f0 : None or array_like, optional
        If not None it is assumed to be equal to ``fun(x0)``, in this case
        the ``fun(x0)`` is not called. Default is None.
    bounds : tuple of array_like, optional
        Lower and upper bounds on independent variables. Defaults to no bounds.
        Each bound must match the size of `x0` or be a scalar, in the latter
        case the bound will be the same for all variables. Use it to limit the
        range of function evaluation. Bounds checking is not implemented
        when `as_linear_operator` is True.
    sparsity : {None, array_like, sparse matrix, 2-tuple}, optional
        Defines a sparsity structure of the Jacobian matrix. If the Jacobian
        matrix is known to have only few non-zero elements in each row, then
        it's possible to estimate its several columns by a single function
        evaluation [3]_. To perform such economic computations two ingredients
        are required:

        * structure : array_like or sparse matrix of shape (m, n). A zero
          element means that a corresponding element of the Jacobian
          identically equals to zero.
        * groups : array_like of shape (n,). A column grouping for a given
          sparsity structure, use `group_columns` to obtain it.

        A single array or a sparse matrix is interpreted as a sparsity
        structure, and groups are computed inside the function. A tuple is
        interpreted as (structure, groups). If None (default), a standard
        dense differencing will be used.

        Note, that sparse differencing makes sense only for large Jacobian
        matrices where each row contains few non-zero elements.
    as_linear_operator : bool, optional
        When True the function returns an `scipy.sparse.linalg.LinearOperator`.
        Otherwise it returns a dense array or a sparse matrix depending on
        `sparsity`. The linear operator provides an efficient way of computing
        ``J.dot(p)`` for any vector ``p`` of shape (n,), but does not allow
        direct access to individual elements of the matrix. By default
        `as_linear_operator` is False.
    args, kwargs : tuple and dict, optional
        Additional arguments passed to `fun`. Both empty by default.
        The calling signature is ``fun(x, *args, **kwargs)``.

    Returns
    -------
    J : {ndarray, sparse matrix, LinearOperator}
        Finite difference approximation of the Jacobian matrix.
        If `as_linear_operator` is True returns a LinearOperator
        with shape (m, n). Otherwise it returns a dense array or sparse
        matrix depending on how `sparsity` is defined. If `sparsity`
        is None then a ndarray with shape (m, n) is returned. If
        `sparsity` is not None returns a csr_matrix with shape (m, n).
        For sparse matrices and linear operators it is always returned as
        a 2-D structure, for ndarrays, if m=1 it is returned
        as a 1-D gradient array with shape (n,).

    See Also
    --------
    check_derivative : Check correctness of a function computing derivatives.

    Notes
    -----
    If `rel_step` is not provided, it assigned as ``EPS**(1/s)``, where EPS is
    determined from the smallest floating point dtype of `x0` or `fun(x0)`,
    ``np.finfo(x0.dtype).eps``, s=2 for '2-point' method and
    s=3 for '3-point' method. Such relative step approximately minimizes a sum
    of truncation and round-off errors, see [1]_. Relative steps are used by
    default. However, absolute steps are used when ``abs_step is not None``.
    If any of the absolute or relative steps produces an indistinguishable
    difference from the original `x0`, ``(x0 + dx) - x0 == 0``, then a
    automatic step size is substituted for that particular entry.

    A finite difference scheme for '3-point' method is selected automatically.
    The well-known central difference scheme is used for points sufficiently
    far from the boundary, and 3-point forward or backward scheme is used for
    points near the boundary. Both schemes have the second-order accuracy in
    terms of Taylor expansion. Refer to [2]_ for the formulas of 3-point
    forward and backward difference schemes.

    For dense differencing when m=1 Jacobian is returned with a shape (n,),
    on the other hand when n=1 Jacobian is returned with a shape (m, 1).
    Our motivation is the following: a) It handles a case of gradient
    computation (m=1) in a conventional way. b) It clearly separates these two
    different cases. b) In all cases np.atleast_2d can be called to get 2-D
    Jacobian with correct dimensions.

    References
    ----------
    .. [1] W. H. Press et. al. "Numerical Recipes. The Art of Scientific
           Computing. 3rd edition", sec. 5.7.

    .. [2] A. Curtis, M. J. D. Powell, and J. Reid, "On the estimation of
           sparse Jacobian matrices", Journal of the Institute of Mathematics
           and its Applications, 13 (1974), pp. 117-120.

    .. [3] B. Fornberg, "Generation of Finite Difference Formulas on
           Arbitrarily Spaced Grids", Mathematics of Computation 51, 1988.

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.optimize._numdiff import approx_derivative
    >>>
    >>> def f(x, c1, c2):
    ...     return np.array([x[0] * np.sin(c1 * x[1]),
    ...                      x[0] * np.cos(c2 * x[1])])
    ...
    >>> x0 = np.array([1.0, 0.5 * np.pi])
    >>> approx_derivative(f, x0, args=(1, 2))
    array([[ 1.,  0.],
           [-1.,  0.]])

    Bounds can be used to limit the region of function evaluation.
    In the example below we compute left and right derivative at point 1.0.

    >>> def g(x):
    ...     return x**2 if x >= 1 else x
    ...
    >>> x0 = 1.0
    >>> approx_derivative(g, x0, bounds=(-np.inf, 1.0))
    array([ 1.])
    >>> approx_derivative(g, x0, bounds=(1.0, np.inf))
    array([ 2.])
    )r6   r8   r7   zUnknown method 'z'. r
   )rW   Úxpúreal floatingz#`x0` must have at most 1 dimension.z,Inconsistent shapes between bounds and `x0`.z7Bounds not supported when `as_linear_operator` is True.Nc                    sN   ˆ  | jd¡rˆ | ˆj¡} t ˆ| gˆ ¢R i ˆ¤Ž¡}|jdkr%tdƒ‚|S )Nrl   r
   z-`fun` return value has more than 1 dimension.)Úisdtyper   rI   r   Ú
atleast_1drW   r?   )r+   Úf©ÚargsÚfunÚkwargsr    rk   r3   r4   Úfun_wrappedÔ  s   
z&approx_derivative.<locals>.fun_wrappedz&`f0` passed has more than 1 dimension.z `x0` violates bound constraints.r   r   rH   r6   r   r8   r   r7   F) r   r   ÚxpxÚ
atleast_ndrS   r:   rm   r   rI   rW   r[   rY   r   r   Úisinfrn   ÚanyrG   Ú_linear_operator_differencerR   rJ   rK   r   r   r5   Ú_dense_differencer   Úlenrj   r   r\   Ú_sparse_difference)rr   r    rB   rL   rP   rM   rZ   ÚsparsityÚas_linear_operatorrq   rs   Ú_xÚ_dtyper$   r%   rt   r!   rN   rQ   r&   Ú	structureri   r3   rp   r4   Úapprox_derivative  s’    $
ÿ


ÿ
ÿÿý
ÿ

ÿ


ÿ





þr‚   c                    sx   ˆ j ‰ˆj }|dkr‡ ‡‡‡‡fdd„}n |dkr#‡‡‡‡fdd„}n|dkr1‡‡‡‡fdd„}ntdƒ‚tˆ|f|ƒS )	Nr6   c                    sH   t  | t  | ¡¡rt  ˆ¡S ˆt| ƒ }ˆ||   }ˆ|ƒˆ  }|| S )N©r   Úarray_equalr   Úzerosr   )ÚprQ   r+   Údf©rM   rr   r!   rf   r    r3   r4   Úmatvec$  s   
z+_linear_operator_difference.<locals>.matvecr8   c                    sl   t  | t  | ¡¡rt  ˆ¡S dˆ t| ƒ }ˆ|d |   }ˆ|d |   }ˆ |ƒ}ˆ |ƒ}|| }|| S )Nr   rƒ   )r†   rQ   Úx1Úx2Úf1Úf2r‡   ©rr   r!   rf   r    r3   r4   r‰   -  s   
r7   c                    sN   t  | t  | ¡¡rt  ˆ¡S ˆt| ƒ }ˆ||  d  }ˆ |ƒ}|j}|| S )Nù              ð?)r   r„   r   r…   r   Úimag)r†   rQ   r+   rŒ   r‡   rŽ   r3   r4   r‰   9  s   
úNever be here.)Úsizer?   r   )rr   r    rM   r!   rB   rg   r‰   r3   rˆ   r4   ry     s   
ry   c                 C   sÖ  |j }|j }t ||f¡}| ¡ }	| ¡ }
|jtdd�}t|j ƒD ]½}|dkr@|	|  || 7  < |	| ||  }| |	ƒ| }nŠ|dkry|| ry|	|  || 7  < |
|  d||  7  < |
| ||  }| |	ƒ}| |
ƒ}d| d|  | }nQ|dkrª|| sª|	|  || 8  < |
|  || 7  < |
| |	|  }| |	ƒ}| |
ƒ}|| }n |dkrÆ||  || d	 7  < | |ƒ}|j}|| }ntd
ƒ‚|| ||< ||  |	|<  |
|< ||< q!|dkrèt 	|¡}|j
S )NT)r   r6   r8   r   g      Àé   r7   r�   r‘   r
   )r’   r   Úemptyr   rI   ÚcomplexÚranger�   r?   ÚravelÚT)rr   r    rM   r!   r&   rB   rf   rg   ÚJ_transposedrŠ   r‹   ÚxcÚirQ   r‡   rŒ   r�   r3   r3   r4   rz   H  sH   


rz   c           !      C   s®  |j }|j }	g }
g }g }t |¡d }t|ƒD �]}t ||¡}|| }|dkrN|| }|| }| |ƒ| }t |¡\}t|d d …|f ƒ\}}}|| }nÔ|dkrô| ¡ }| ¡ }||@ }||  || 7  < ||  d||  7  < | |@ }||  || 8  < ||  || 7  < t |	¡}|| ||  ||< || ||  ||< | |ƒ}| |ƒ}t |¡\}t|d d …|f ƒ\}}}|| }|| }t 	|¡}|| }d||  d||   ||  ||< ||  }|| ||  ||< n.|dk�r| ||d  ƒ}|j
}|}t |¡\}t|d d …|f ƒ\}}}|| }ntd	ƒ‚|
 |¡ | |¡ | || ||  ¡ qt |
¡}
t |¡}t |¡}t||
|ff||	fd
�} t| ƒS )Nr
   r6   r8   r   éýÿÿÿr“   r7   r�   r‘   )rY   )r’   r   Úmaxr–   ÚequalÚnonzeror	   r   r…   r”   r�   r   ÚappendÚhstackr   r   )!rr   r    rM   r!   r&   r�   ri   rB   rf   rg   Úrow_indicesÚcol_indicesÚ	fractionsÚn_groupsÚgroupÚeÚh_vecr+   rQ   r‡   Úcolsr›   ÚjÚ_rŠ   r‹   Úmask_1Úmask_2rŒ   r�   ÚmaskÚrowsÚJr3   r3   r4   r|   t  sn   



$







r|   c              	   C   sÐ   |du ri }||g|¢R i |¤Ž}t |ƒrJt| |||||d�}t|ƒ}|| }t|ƒ\}	}
}t ||	|
f ¡ ¡ }t t |¡t 	dt |¡¡ ¡S t| ||||d�}t || ¡}t |t 	dt |¡¡ ¡S )aT	  Check correctness of a function computing derivatives (Jacobian or
    gradient) by comparison with a finite difference approximation.

    Parameters
    ----------
    fun : callable
        Function of which to estimate the derivatives. The argument x
        passed to this function is ndarray of shape (n,) (never a scalar
        even if n=1). It must return 1-D array_like of shape (m,) or a scalar.
    jac : callable
        Function which computes Jacobian matrix of `fun`. It must work with
        argument x the same way as `fun`. The return value must be array_like
        or sparse matrix with an appropriate shape.
    x0 : array_like of shape (n,) or float
        Point at which to estimate the derivatives. Float will be converted
        to 1-D array.
    bounds : 2-tuple of array_like, optional
        Lower and upper bounds on independent variables. Defaults to no bounds.
        Each bound must match the size of `x0` or be a scalar, in the latter
        case the bound will be the same for all variables. Use it to limit the
        range of function evaluation.
    args, kwargs : tuple and dict, optional
        Additional arguments passed to `fun` and `jac`. Both empty by default.
        The calling signature is ``fun(x, *args, **kwargs)`` and the same
        for `jac`.

    Returns
    -------
    accuracy : float
        The maximum among all relative errors for elements with absolute values
        higher than 1 and absolute errors for elements with absolute values
        less or equal than 1. If `accuracy` is on the order of 1e-6 or lower,
        then it is likely that your `jac` implementation is correct.

    See Also
    --------
    approx_derivative : Compute finite difference approximation of derivative.

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.optimize._numdiff import check_derivative
    >>>
    >>>
    >>> def f(x, c1, c2):
    ...     return np.array([x[0] * np.sin(c1 * x[1]),
    ...                      x[0] * np.cos(c2 * x[1])])
    ...
    >>> def jac(x, c1, c2):
    ...     return np.array([
    ...         [np.sin(c1 * x[1]),  c1 * x[0] * np.cos(c1 * x[1])],
    ...         [np.cos(c2 * x[1]), -c2 * x[0] * np.sin(c2 * x[1])]
    ...     ])
    ...
    >>>
    >>> x0 = np.array([1.0, 0.5 * np.pi])
    >>> check_derivative(f, jac, x0, args=(1, 2))
    2.4492935982947064e-16
    N)rZ   r}   rq   rs   r
   )rZ   rq   rs   )
r   r‚   r   r	   r   rS   r—   r�   r   r   )rr   Újacr    rZ   rq   rs   Ú	J_to_testÚJ_diffÚabs_errr›   rª   Úabs_err_dataÚJ_diff_datar3   r3   r4   Úcheck_derivativeÄ  s&   =
ÿÿÿr·   )r   )"Ú__doc__Ú	functoolsÚnumpyr   Únumpy.linalgr   Úscipy.sparse.linalgr   Úsparser   r   r   r   r	   Ú_group_columnsr   r   Úscipy._lib._array_apir   Ú
scipy._libr   ru   r5   Ú	lru_cacherG   rR   r[   rj   r   r‚   ry   rz   r|   r·   r3   r3   r3   r4   Ú<module>   s6    O
51
=
þ  ),Pÿ