
    Yha                     f    d dl ZddlmZ d dlmZmZ dgZ eddh          ded	d
            ZdS )    N   )nnls)_deprecate_positional_args_NoValuer   z1.18.0atol)versiondeprecated_args)maxiterr   c                   t          j        | t           j        d          } t          j        |t           j                  }t          | j                  dk    rt          d| j                   |j        dk    s|j        dk    r(|j        d         dk    rt          d|j                   |j        dk    r%|j        d         dk    r|                                }| j        \  }}||j        d         k    r$t          d	d
| d|j        d         f z             |sd|z  }t          | ||          \  }}}|dk    rt          d          ||fS )a  
    Solve ``argmin_x || Ax - b ||_2`` for ``x>=0``.

    This problem, often called as NonNegative Least Squares, is a convex
    optimization problem with convex constraints. It typically arises when
    the ``x`` models quantities for which only nonnegative values are
    attainable; weight of ingredients, component costs and so on.

    Parameters
    ----------
    A : (m, n) ndarray
        Coefficient array
    b : (m,) ndarray, float
        Right-hand side vector.
    maxiter: int, optional
        Maximum number of iterations, optional. Default value is ``3 * n``.
    atol : float, optional
        .. deprecated:: 1.18.0
            This parameter is deprecated and will be removed in SciPy 1.18.0.
            It is not used in the implementation.

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

    See Also
    --------
    lsq_linear : Linear least squares with bounds on the variables

    Notes
    -----
    The code is based on the classical algorithm of [1]_. It utilizes an active
    set method and solves the KKK (Karush-Kuhn-Tucker) conditions for the
    non-negative least squares problem.

    References
    ----------
    .. [1] : Lawson C., Hanson R.J., "Solving Least Squares Problems", SIAM,
       1995, :doi:`10.1137/1.9781611971217`

     Examples
    --------
    >>> import numpy as np
    >>> from scipy.optimize import nnls
    ...
    >>> A = np.array([[1, 0], [1, 0], [0, 1]])
    >>> b = np.array([2, 1, 1])
    >>> nnls(A, b)
    (array([1.5, 1. ]), 0.7071067811865475)

    >>> b = np.array([-1, -1, -1])
    >>> nnls(A, b)
    (array([0., 0.]), 1.7320508075688772)

    C)dtypeorder)r      z+Expected a 2D array, but the shape of A is r   zDExpected a 1D array,(or 2D with one column), but the, shape of b is r   z0Incompatible dimensions. The first dimension of zA is z, while the shape of b is    z%Maximum number of iterations reached.)
npasarray_chkfinitefloat64lenshape
ValueErrorndimravel_nnlsRuntimeError)	Abr
   r   mnxrnorminfos	            f/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/scipy/optimize/_nnls.pyr   r   	   sn   | 	Qbj<<<A
Qbj111A
17||qPqwPPQQQ	

1171:?? 5+,75 5 6 6 	6
&A++AGAJ!OOGGII7DAqAGAJBEEEagaj^EEFG G 	G  A#1a))NAudqyyBCCCe8O    )	numpyr   	_slsqplibr   r   scipy._lib.deprecationr   r   __all__ r#   r"   <module>r)      s        $ $ $ $ $ $ G G G G G G G G ( H-3H6 6 6X U U U U6 6U U Ur#   