
     hN%                     d    d dl Zd Z G d d          Z G d d          Z G d de          ZdS )	    Nc                 ,    t          j        |          }t          j        |j        t           j                  r|st          d          t          nt          |                    d          }|j	        dk    r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.c                 D    t          j         | |                    S )N)dtype)npasarray)tyr   funs     U/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/scipy/integrate/_ivp/base.pyfun_wrappedz$check_arguments.<locals>.fun_wrapped   s"    z##a))51111    )
r   r	   
issubdtyper   complexfloating
ValueErrorcomplexfloatastypendim)r   y0support_complexr   r   s   `   @r   check_argumentsr      s    	BB	}RXr122  	M L M M M	5u	%	%B	w!||67772 2 2 2 2 2 ?r   c                   N    e Zd ZdZdZ	 ddZed             Zd Zd Z	d Z
d	 Zd
S )	OdeSolvera  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 calling signature is ``fun(t, y)``.
        Here ``t`` is a scalar and there are two options for ndarray ``y``.
        It can either have shape (n,), then ``fun`` must return array_like with
        shape (n,). Or, alternatively, it can have shape (n, n_points), then
        ``fun`` must return array_like with shape (n, n_points) (each column
        corresponds to a single column in ``y``). The choice between the two
        options is determined by `vectorized` argument (see below).
    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` is implemented in a vectorized fashion.
    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.Fc                     d  _         | _        t          |||          \   _         _        | _        | _        |r fd} j        }n j        } fd} fd}| _        | _        | _	        ||k    rt          j        ||z
            nd _         j        j         _        d _        d _        d _        d _        d S )Nc                 h                         | |d d d f                                                   S N)_funravelr
   r   selfs     r   
fun_singlez&OdeSolver.__init__.<locals>.fun_single|   s/    yyAaaagJ//55777r   c                     t          j        |          }t          |j                  D ]"\  }}                    | |          |d d |f<   #|S r   )r   
empty_like	enumerateTr   )r
   r   fiyir"   s        r   fun_vectorizedz*OdeSolver.__init__.<locals>.fun_vectorized   sS    M!$$&qs^^ / /EAr"ii2..AaaadGGr   c                 P    xj         dz  c_                             | |          S )Nr   )nfevr#   r!   s     r   r   zOdeSolver.__init__.<locals>.fun   s&    IINII??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   r0   r1   r   r#   r+   s	   `        r   __init__zOdeSolver.__init__s   s   
+C_EE	46$ 	8 8 8 8 8!YNNJ    	) 	) 	) 	) 	) $,29R--2...Q		r   c                 V    | j         d S t          j        | j        | j         z
            S r   )r/   r   absr
   r"   s    r   	step_sizezOdeSolver.step_size   s(    :46$&4:-...r   c                 V   | j         dk    rt          d          | j        dk    s| j        | j        k    r"| j        | _        | j        | _        d}d| _         nQ| j        }|                                 \  }}|sd| _         n)|| _        | 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.
        r.   z/Attempt to step on a failed or finished solver.r   Nfinishedfailed)r6   RuntimeErrorr5   r
   r0   r/   
_step_implr3   )r"   messager
   successs       r   stepzOdeSolver.step   s     ;)##  ) * * * 6Q;;$&DL00DJ\DFG$DKKA#00GW -&
>TVdl%:;q@@",DKr   c                     | j         t          d          | j        dk    s| j        | j         k    r t	          | j         | j        | j                  S |                                 S )zCompute a local interpolant over the last successful step.

        Returns
        -------
        sol : `DenseOutput`
            Local interpolant over the last successful step.
        Nz;Dense output is available after a successful step was made.r   )r/   rB   r5   r
   ConstantDenseOutputr   _dense_output_implr=   s    r   dense_outputzOdeSolver.dense_output   sh     :  0 1 1 1 6Q;;$&DJ..&tz4646BBB**,,,r   c                     t           r   NotImplementedErrorr=   s    r   rC   zOdeSolver._step_impl       !!r   c                     t           r   rL   r=   s    r   rI   zOdeSolver._dense_output_impl   rN   r   N)F)__name__
__module____qualname____doc__TOO_SMALL_STEPr:   propertyr>   rF   rJ   rC   rI    r   r   r   r      s        V Vn PN "'# # # #J / / X/  B- - -$" " "" " " " "r   r   c                   $    e Zd ZdZd Zd Zd ZdS )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                 v    || _         || _        t          ||          | _        t	          ||          | _        d S r   )r/   r
   mint_minmaxt_max)r"   r/   r
   s      r   r:   zDenseOutput.__init__   s2    
E]]
E]]


r   c                     t          j        |          }|j        dk    rt          d          |                     |          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__   s=     JqMM6A::BCCCq!!!r   c                     t           r   rL   r`   s     r   r_   zDenseOutput._call_impl   rN   r   N)rP   rQ   rR   rS   r:   ra   r_   rV   r   r   rX   rX      sK        
 
# # #" " "&" " " " "r   rX   c                   (     e Zd ZdZ fdZd Z xZS )rH   zConstant value interpolator.

    This class used for degenerate integration cases: equal integration limits
    or a system with 0 equations.
    c                 Z    t                                          ||           || _        d S r   )superr:   value)r"   r/   r
   rf   	__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   rf   r   emptyshape)r"   r
   rets      r   r_   zConstantDenseOutput._call_impl  sZ    6Q;;:(DJ,Q/<==CZ4(CFJr   )rP   rQ   rR   rS   r:   r_   __classcell__)rg   s   @r   rH   rH     sQ         
          r   rH   )numpyr   r   r   rX   rH   rV   r   r   <module>rn      s         *}" }" }" }" }" }" }" }"@&" &" &" &" &" &" &" &"R    +     r   