
    5[g7(                     P    d dl Zd Z G d d      Z G d d      Z G d de      Zy)	    Nc                     t        j                  |      }t        j                  |j                  t         j                        r|st        d      t        nt        |j                  d      }|j                  dk7  rt        d      t        j                  |      j                         st        d       fd}||fS )z=Helper function for checking arguments common to all solvers.zX`y0` is complex, but the chosen solver does not support integration in a complex domain.F)copy   z`y0` must be 1-dimensional.z8All components of the initial state `y0` must be finite.c                 @    t        j                   | |            S )N)dtype)npasarray)tyr   funs     T/var/www/html/bid-api/venv/lib/python3.12/site-packages/scipy/integrate/_ivp/base.pyfun_wrappedz$check_arguments.<locals>.fun_wrapped   s    zz#a)511    )r   r	   
issubdtyper   complexfloating
ValueErrorcomplexfloatastypendimisfiniteall)r   y0support_complexr   r   s   `   @r   check_argumentsr      s    	BB	}}RXXr112 L M M	5u	%B	ww!|677;;r? STT2 ?r   c                   F    e Zd ZdZdZ	 d
dZed        Zd Zd Z	d Z
d Zy	)	OdeSolveraJ  Base class for ODE solvers.

    In order to implement a new solver you need to follow the guidelines:

        1. A constructor must accept parameters presented in the base class
           (listed below) along with any other parameters specific to a solver.
        2. A constructor must accept arbitrary extraneous arguments
           ``**extraneous``, but warn that these arguments are irrelevant
           using `common.warn_extraneous` function. Do not pass these
           arguments to the base class.
        3. A solver must implement a private method `_step_impl(self)` which
           propagates a solver one step further. It must return tuple
           ``(success, message)``, where ``success`` is a boolean indicating
           whether a step was successful, and ``message`` is a string
           containing description of a failure if a step failed or None
           otherwise.
        4. A solver must implement a private method `_dense_output_impl(self)`,
           which returns a `DenseOutput` object covering the last successful
           step.
        5. A solver must have attributes listed below in Attributes section.
           Note that ``t_old`` and ``step_size`` are updated automatically.
        6. Use `fun(self, t, y)` method for the system rhs evaluation, this
           way the number of function evaluations (`nfev`) will be tracked
           automatically.
        7. For convenience, a base class provides `fun_single(self, t, y)` and
           `fun_vectorized(self, t, y)` for evaluating the rhs in
           non-vectorized and vectorized fashions respectively (regardless of
           how `fun` from the constructor is implemented). These calls don't
           increment `nfev`.
        8. If a solver uses a Jacobian matrix and LU decompositions, it should
           track the number of Jacobian evaluations (`njev`) and the number of
           LU decompositions (`nlu`).
        9. By convention, the function evaluations used to compute a finite
           difference approximation of the Jacobian should not be counted in
           `nfev`, thus use `fun_single(self, t, y)` or
           `fun_vectorized(self, t, y)` when computing a finite difference
           approximation of the Jacobian.

    Parameters
    ----------
    fun : callable
        Right-hand side of the system: the time derivative of the state ``y``
        at time ``t``. The calling signature is ``fun(t, y)``, where ``t`` is a
        scalar and ``y`` is an ndarray with ``len(y) = len(y0)``. ``fun`` must
        return an array of the same shape as ``y``. See `vectorized` for more
        information.
    t0 : float
        Initial time.
    y0 : array_like, shape (n,)
        Initial state.
    t_bound : float
        Boundary time --- the integration won't continue beyond it. It also
        determines the direction of the integration.
    vectorized : bool
        Whether `fun` can be called in a vectorized fashion. Default is False.

        If ``vectorized`` is False, `fun` will always be called with ``y`` of
        shape ``(n,)``, where ``n = len(y0)``.

        If ``vectorized`` is True, `fun` may be called with ``y`` of shape
        ``(n, k)``, where ``k`` is an integer. In this case, `fun` must behave
        such that ``fun(t, y)[:, i] == fun(t, y[:, i])`` (i.e. each column of
        the returned array is the time derivative of the state corresponding
        with a column of ``y``).

        Setting ``vectorized=True`` allows for faster finite difference
        approximation of the Jacobian by methods 'Radau' and 'BDF', but
        will result in slower execution for other methods. It can also
        result in slower overall execution for 'Radau' and 'BDF' in some
        circumstances (e.g. small ``len(y0)``).
    support_complex : bool, optional
        Whether integration in a complex domain should be supported.
        Generally determined by a derived solver class capabilities.
        Default is False.

    Attributes
    ----------
    n : int
        Number of equations.
    status : string
        Current status of the solver: 'running', 'finished' or 'failed'.
    t_bound : float
        Boundary time.
    direction : float
        Integration direction: +1 or -1.
    t : float
        Current time.
    y : ndarray
        Current state.
    t_old : float
        Previous time. None if no steps were made yet.
    step_size : float
        Size of the last successful step. None if no steps were made yet.
    nfev : int
        Number of the system's rhs evaluations.
    njev : int
        Number of the Jacobian evaluations.
    nlu : int
        Number of LU decompositions.
    z8Required step size is less than spacing between numbers.c                     d  _         | _        t        |||      \   _         _        | _        | _        |r fd} j                  }n j                  } fd} fd}| _        | _        | _	        ||k7  rt        j                  ||z
        nd _         j                  j                   _        d _        d _        d _        d _        y )Nc                 R    j                  | |d d d f         j                         S N)_funravelr
   r   selfs     r   
fun_singlez&OdeSolver.__init__.<locals>.fun_single   s%    yyAagJ/5577r   c                     t        j                  |      }t        |j                        D ]  \  }}j	                  | |      |d d |f<     |S r    )r   
empty_like	enumerateTr!   )r
   r   fiyir$   s        r   fun_vectorizedz*OdeSolver.__init__.<locals>.fun_vectorized   sD    MM!$&qss^EAr"ii2.AadG ,r   c                 R    xj                   dz  c_         j                  | |      S )Nr   )nfevr%   r#   s     r   r   zOdeSolver.__init__.<locals>.fun   s!    IINI??1a((r   r   runningr   )t_oldr
   r   r!   r   t_bound
vectorizedr   r%   r-   r   sign	directionsizenstatusr/   njevnlu)	r$   r   t0r   r2   r3   r   r%   r-   s	   `        r   __init__zOdeSolver.__init__   s    
+C_E	46$8!YYNJ	) $,29R-2.Q		r   c                 t    | j                   y t        j                  | j                  | j                   z
        S r    )r1   r   absr
   r$   s    r   	step_sizezOdeSolver.step_size   s+    ::66$&&4::-..r   c                    | j                   dk7  rt        d      | j                  dk(  s| j                  | j                  k(  r-| j                  | _        | j                  | _        d}d| _         |S | j                  }| j                         \  }}|s	d| _         |S || _        | j                  | j                  | j                  z
  z  dk\  rd| _         |S )a  Perform one integration step.

        Returns
        -------
        message : string or None
            Report from the solver. Typically a reason for a failure if
            `self.status` is 'failed' after the step was taken or None
            otherwise.
        r0   z/Attempt to step on a failed or finished solver.r   Nfinishedfailed)r8   RuntimeErrorr7   r
   r2   r1   
_step_implr5   )r$   messager
   successs       r   stepzOdeSolver.step   s     ;;)#  ) * * 66Q;$&&DLL0DJ\\DFG$DK  A#0GW& 	 
>>TVVdll%:;q@",DKr   c                     | j                   t        d      | j                  dk(  s| j                  | j                   k(  r+t	        | j                   | j                  | j
                        S | j                         S )zCompute a local interpolant over the last successful step.

        Returns
        -------
        sol : `DenseOutput`
            Local interpolant over the last successful step.
        z;Dense output is available after a successful step was made.r   )r1   rD   r7   r
   ConstantDenseOutputr   _dense_output_implr?   s    r   dense_outputzOdeSolver.dense_output   sf     ::  0 1 1 66Q;$&&DJJ.&tzz466466BB**,,r   c                     t         r    NotImplementedErrorr?   s    r   rE   zOdeSolver._step_impl       !!r   c                     t         r    rN   r?   s    r   rK   zOdeSolver._dense_output_impl   rP   r   N)F)__name__
__module____qualname____doc__TOO_SMALL_STEPr<   propertyr@   rH   rL   rE   rK    r   r   r   r      sE    cH PN "'#J / /B-$""r   r   c                   "    e Zd ZdZd Zd Zd Zy)DenseOutputaO  Base class for local interpolant over step made by an ODE solver.

    It interpolates between `t_min` and `t_max` (see Attributes below).
    Evaluation outside this interval is not forbidden, but the accuracy is not
    guaranteed.

    Attributes
    ----------
    t_min, t_max : float
        Time range of the interpolation.
    c                 d    || _         || _        t        ||      | _        t	        ||      | _        y r    )r1   r
   mint_minmaxt_max)r$   r1   r
   s      r   r<   zDenseOutput.__init__   s*    
E]
E]
r   c                     t        j                  |      }|j                  dkD  rt        d      | j	                  |      S )ae  Evaluate the interpolant.

        Parameters
        ----------
        t : float or array_like with shape (n_points,)
            Points to evaluate the solution at.

        Returns
        -------
        y : ndarray, shape (n,) or (n, n_points)
            Computed values. Shape depends on whether `t` was a scalar or a
            1-D array.
        r   z#`t` must be a float or a 1-D array.)r   r	   r   r   
_call_implr$   r
   s     r   __call__zDenseOutput.__call__   s7     JJqM66A:BCCq!!r   c                     t         r    rN   rb   s     r   ra   zDenseOutput._call_impl  rP   r   N)rR   rS   rT   rU   r<   rc   ra   rX   r   r   rZ   rZ      s    
#"&"r   rZ   c                   (     e Zd ZdZ fdZd Z xZS )rJ   zConstant value interpolator.

    This class used for degenerate integration cases: equal integration limits
    or a system with 0 equations.
    c                 4    t         |   ||       || _        y r    )superr<   value)r$   r1   r
   rh   	__class__s       r   r<   zConstantDenseOutput.__init__  s    "
r   c                     |j                   dk(  r| j                  S t        j                  | j                  j                  d   |j                  d   f      }| j                  d d d f   |d d  |S )Nr   )r   rh   r   emptyshape)r$   r
   rets      r   ra   zConstantDenseOutput._call_impl  s\    66Q;::((DJJ,,Q/<=CZZ4(CFJr   )rR   rS   rT   rU   r<   ra   __classcell__)ri   s   @r   rJ   rJ     s    
r   rJ   )numpyr   r   r   rZ   rJ   rX   r   r   <module>rp      s1    0J" J"Z&" &"R+ r   