ó
î&]\c           @` sw   d  d l  m Z m Z m Z d  d l Z d „  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ	 d e	 f d	 „  ƒ  YZ
 d S(
   i    (   t   divisiont   print_functiont   absolute_importNc         ` sš   t  j | ƒ } t  j | j t  j ƒ rE | s< t d ƒ ‚ n  t ‰  n t ‰  | j ˆ  d t	 ƒ} | j
 d k r~ t d ƒ ‚ n  ‡  ‡ f d †  } | | f S(   s=   Helper function for checking arguments common to all solvers.sX   `y0` is complex, but the chosen solver does not support integration in a complex domain.t   copyi   s   `y0` must be 1-dimensional.c         ` s   t  j ˆ |  | ƒ d ˆ  ƒS(   Nt   dtype(   t   npt   asarray(   t   tt   y(   R   t   fun(    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyt   fun_wrapped   s    (   R   R   t
   issubdtypeR   t   complexfloatingt
   ValueErrort   complext   floatt   astypet   Falset   ndim(   R	   t   y0t   support_complexR
   (    (   R   R	   s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyt   check_arguments   s    	t	   OdeSolverc           B` sS   e  Z d  Z d Z e d „ Z e d „  ƒ Z d „  Z d „  Z	 d „  Z
 d „  Z RS(   sÐ  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.
    s8   Required step size is less than spacing between numbers.c   	      ` s  d  ˆ  _ | ˆ  _ t | | | ƒ \ ˆ  _ ˆ  _ | ˆ  _ | ˆ  _ | rc ‡  f d †  } ˆ  j } n ˆ  j } ‡  f d †  } ‡  f d †  } | ˆ  _ | ˆ  _	 | ˆ  _
 | | k rÄ t j | | ƒ n d ˆ  _ ˆ  j j ˆ  _ d ˆ  _ d ˆ  _ d ˆ  _ d ˆ  _ d  S(   Nc         ` s&   ˆ  j  |  | d  d  … d  f ƒ j ƒ  S(   N(   t   _funt   Nonet   ravel(   R   R   (   t   self(    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyt
   fun_single}   s    c         ` sU   t  j | ƒ } x? t | j ƒ D]. \ } } ˆ  j |  | ƒ | d  d  … | f <q W| S(   N(   R   t
   empty_liket	   enumeratet   TR   (   R   R   t   ft   it   yi(   R   (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyt   fun_vectorizedƒ   s    &c         ` s   ˆ  j  d 7_  ˆ  j |  | ƒ S(   Ni   (   t   nfevR   (   R   R   (   R   (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyR	   ‰   s    i   t   runningi    (   R   t   t_oldR   R   R   R   t   t_boundt
   vectorizedR	   R   R"   R   t   signt	   directiont   sizet   nt   statusR#   t   njevt   nlu(	   R   R	   t   t0R   R&   R'   R   R   R"   (    (   R   s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyt   __init__t   s(    								(			c         C` s.   |  j  d  k r d  St j |  j |  j  ƒ Sd  S(   N(   R%   R   R   t   absR   (   R   (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyt	   step_size™   s    c         C` sÌ   |  j  d k r t d ƒ ‚ n  |  j d k s? |  j |  j k ri |  j |  _ |  j |  _ d } d |  _  n_ |  j } |  j ƒ  \ } } | s– d |  _  n2 | |  _ |  j |  j |  j d k rÈ d |  _  n  | S(   s  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$   s/   Attempt to step on a failed or finished solver.i    t   finishedt   failedN(	   R,   t   RuntimeErrorR+   R   R&   R%   R   t
   _step_implR)   (   R   t   messageR   t   success(    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyt   step    s    
!		c         C` sf   |  j  d k r t d ƒ ‚ n  |  j d k s? |  j |  j  k rX t |  j  |  j |  j ƒ S|  j ƒ  Sd S(   s½   Compute a local interpolant over the last successful step.

        Returns
        -------
        sol : `DenseOutput`
            Local interpolant over the last successful step.
        s;   Dense output is available after a successful step was made.i    N(   R%   R   R5   R+   R   t   ConstantDenseOutputR   t   _dense_output_impl(   R   (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyt   dense_outputÁ   s
    !c         C` s
   t  ‚ d  S(   N(   t   NotImplementedError(   R   (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyR6   Ó   s    c         C` s
   t  ‚ d  S(   N(   R=   (   R   (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyR;   Ö   s    (   t   __name__t
   __module__t   __doc__t   TOO_SMALL_STEPR   R0   t   propertyR2   R9   R<   R6   R;   (    (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyR      s   W$	!		t   DenseOutputc           B` s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sO  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         C` s:   | |  _  | |  _ t | | ƒ |  _ t | | ƒ |  _ d  S(   N(   R%   R   t   mint   t_mint   maxt   t_max(   R   R%   R   (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyR0   æ   s    		c         C` s:   t  j | ƒ } | j d k r- t d ƒ ‚ n  |  j | ƒ S(   se  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.
        i   s   `t` must be float or 1-d array.(   R   R   R   R   t
   _call_impl(   R   R   (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyt   __call__ì   s    c         C` s
   t  ‚ d  S(   N(   R=   (   R   R   (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyRH   ÿ   s    (   R>   R?   R@   R0   RI   RH   (    (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyRC   Ú   s   		R:   c           B` s    e  Z d  Z d „  Z d „  Z RS(   s“   Constant value interpolator.

    This class used for degenerate integration cases: equal integration limits
    or a system with 0 equations.
    c         C` s&   t  t |  ƒ j | | ƒ | |  _ d  S(   N(   t   superR:   R0   t   value(   R   R%   R   RK   (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyR0   	  s    c         C` s^   | j  d k r |  j St j |  j j d | j d f ƒ } |  j d  d  … d  f | (| Sd  S(   Ni    (   R   RK   R   t   emptyt   shapeR   (   R   R   t   ret(    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyRH     s
    &(   R>   R?   R@   R0   RH   (    (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyR:     s   	(   t
   __future__R    R   R   t   numpyR   R   t   objectR   RC   R:   (    (    (    s8   lib/python2.7/site-packages/scipy/integrate/_ivp/base.pyt   <module>   s
   	À)