ó
ÚÆ÷Xc           @` s^   d  d l  m Z m Z m Z d d l m Z d  d l m Z m Z m	 Z	 d g Z
 d „  Z d S(   i    (   t   divisiont   print_functiont   absolute_importi   (   t   _nnls(   t   asarray_chkfinitet   zerost   doublet   nnlsc   
      C` s"  t  t |  | f ƒ \ }  } t |  j ƒ d k r? t d ƒ ‚ n  t | j ƒ d k rc t d ƒ ‚ n  |  j \ } } | | j d k r” t d ƒ ‚ n  t | f d t ƒ} t | f d t ƒ} t | f d t ƒ} t j	 |  | | | | | | ƒ \ } } }	 |	 d k rt
 d ƒ ‚ n  | | f S(	   sÀ  
    Solve ``argmin_x || Ax - b ||_2`` for ``x>=0``. This is a wrapper
    for a FORTRAN non-negative least squares solver.

    Parameters
    ----------
    A : ndarray
        Matrix ``A`` as shown above.
    b : ndarray
        Right-hand side vector.

    Returns
    -------
    x : ndarray
        Solution vector.
    rnorm : float
        The residual, ``|| Ax-b ||_2``.

    Notes
    -----
    The FORTRAN code was published in the book below. The algorithm
    is an active set method. It solves the KKT (Karush-Kuhn-Tucker)
    conditions for the non-negative least squares problem.

    References
    ----------
    Lawson C., Hanson R.J., (1987) Solving Least Squares Problems, SIAM

    i   s   expected matrixi   s   expected vectori    s   incompatible dimensionst   dtypes   too many iterations(   t   mapR   t   lent   shapet
   ValueErrorR   R   t   intR   R   t   RuntimeError(
   t   At   bt   mt   nt   wt   zzt   indext   xt   rnormt   mode(    (    s2   /tmp/pip-build-X4mzal/scipy/scipy/optimize/nnls.pyR   	   s    *N(   t
   __future__R    R   R   t    R   t   numpyR   R   R   t   __all__R   (    (    (    s2   /tmp/pip-build-X4mzal/scipy/scipy/optimize/nnls.pyt   <module>   s   	