
    `i                     ^    d Z ddlZddddddd	Z G d
 de          Zd Z	 	 ddZ	 	 ddZdS )z- A vendored copy of scipy.optimize.fminbound.    Nz%Optimization terminated successfully.z9Maximum number of function evaluations has been exceeded.z/Maximum number of iterations has been exceeded.z=Desired error not necessarily achieved due to precision loss.zNaN result encountered.z-The result is outside of the provided bounds.)successmaxfevmaxiterpr_lossnanout_of_boundsc                       e Zd ZdZd ZdS )OptimizeResultz) Represents the optimization result.
    c                 X    	 | |         S # t           $ r}t          |          |d }~ww xY w)N)KeyErrorAttributeError)selfnamees      p/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/scipy/signal/_optimize.py__getattr__zOptimizeResult.__getattr__   s@    	.: 	. 	. 	. &&A-	.s   
 
)$)N)__name__
__module____qualname____doc__r        r   r
   r
      s-         . . . . .r   r
   c                     |dk    r|dk    rt          d|d           |dk    r|rt          d           |dk    r/|r-t          d                    t          d                              d S )	Nr      zk
Optimization terminated successfully;
The returned value satisfies the termination criteria
(using xtol = )zO
Maximum number of function evaluations exceeded --- increase maxfun argument.
   z
{}r   )printformat_status_message)xflagfvalmaxfunxtoldisps         r   	_endprintr&      s    qyy!88 #$(#/ / / qyy 	1 0 1 1 1qyy 	9&-- 677888
Fr   r   h㈵>  r   c                 ~    ||d}t          | ||f|fi |}	|r|	d         |	d         |	d         |	d         fS |	d         S )aU  Bounded minimization for scalar functions.

    Parameters
    ----------
    func : callable f(x,*args)
        Objective function to be minimized (must accept and return scalars).
    x1, x2 : float or array scalar
        Finite optimization bounds.
    args : tuple, optional
        Extra arguments passed to function.
    xtol : float, optional
        The convergence tolerance.
    maxfun : int, optional
        Maximum number of function evaluations allowed.
    full_output : bool, optional
        If True, return optional outputs.
    disp : int, optional
        If non-zero, print messages.
            0 : no message printing.
            1 : non-convergence notification messages only.
            2 : print a message on convergence too.
            3 : print iteration results.

    Returns
    -------
    xopt : ndarray
        Parameters (over given interval) which minimize the
        objective function.
    fval : number
        The function value evaluated at the minimizer.
    ierr : int
        An error flag (0 if converged, 1 if maximum number of
        function calls reached).
    numfunc : int
      The number of function calls made.


    Returns
    -------
    xopt : ndarray
        Parameters (over given interval) which minimize the
        objective function.

    See also
    --------
    scipy.optimize.fminbound


    Notes
    -----
    Finds a local minimizer of the scalar function `func` in the
    interval x1 < xopt < x2 using Brent's method. (See `brent`
    for auto-bracketing.)

    References
    ----------
    .. [1] Forsythe, G.E., M. A. Malcolm, and C. B. Moler. "Computer Methods
           for Mathematical Computations." Prentice-Hall Series in Automatic
           Computation 259 (1977).
    .. [2] Brent, Richard P. Algorithms for Minimization Without Derivatives.
           Courier Corporation, 2013.


    )xatolr   r    funstatusnfev)_minimize_scalar_bounded)
funcx1x2argsr$   r#   full_outputr%   optionsress
             r   	fminboundr6   .   sf    D   G #4"b4
C
C7
C
CC 3xUS]CK??3xr   c           	         |}t          |          dk    rt          d          |\  }}	||	k    rt          d          d}
d}d}t          j        d          }dd	t          j        d
          z
  z  }||	}}||||z
  z  z   }||}}dx}}|} | |g|R  }d}d||f}t          j        }|x}}d||z   z  }|t          j        |          z  |d	z  z   }d|z  }|dk    r4t          d           t          |           t          d||fz   z             t          j        ||z
            |d||z
  z  z
  k    r;d} t          j        |          |k    rd} ||z
  ||z
  z  }!||z
  ||z
  z  }"||z
  |"z  ||z
  |!z  z
  }#d|"|!z
  z  }"|"dk    r|# }#t          j        |"          }"|}!|}t          j        |#          t          j        d|"z  |!z            k     r`|#|"||z
  z  k    rT|#|"||z
  z  k     rH|#dz   |"z  }||z   }d}||z
  |k     s	||z
  |k     r&t          j        ||z
            ||z
  dk    z   }$||$z  }nd} | r||k    r||z
  }n||z
  }||z  }d}t          j        |          |dk    z   }$||$t          j        t          j        |          |          z  z   } | |g|R  }|dz  }|||f}|dk    rt          d||fz   z             ||k    r||k    r|}n|}||}}||}}||}}n6||k     r|}n|}||k    s||k    r	||}}||}}n||k    s||k    s||k    r||}}d||z   z  }|t          j        |          z  |d	z  z   }d|z  }||k    rd}
n%t          j        ||z
            |d||z
  z  z
  k    ;t          j	        |          s(t          j	        |          st          j	        |          rd}
|}%|dk    rt          ||
|%|||           t          |%|
|
dk    ddt          d         d                    |
d          |||          }&|&S )a  
    Options
    -------
    maxiter : int
        Maximum number of iterations to perform.
    disp: int, optional
        If non-zero, print messages.
            0 : no message printing.
            1 : non-convergence notification messages only.
            2 : print a message on convergence too.
            3 : print iteration results.
    xatol : float
        Absolute error in solution `xopt` acceptable for convergence.

    r   zbounds must have two elements.z(The lower bound exceeds the upper bound.r   z2 Func-count     x          f(x)          Procedurez       initialgOd@<g      ?g      @g      @g        r   g       @ z%5.0f   %12.6g %12.6g %sz       parabolicz       goldenzSolution found.z)Maximum number of function calls reached.r   )r   r   r    )r+   r,   r   messager    r-   nit)len
ValueErrorcupysqrtinfabsr   signmaximumisnanr&   r
   r   get)'r/   boundsr2   r*   r   r%   unknown_optionsr#   r0   r1   r!   headerstepsqrt_epsgolden_meanabfulcnfcxfratr   r    fxnum	fmin_datafuffulcfnfcxmtol1tol2goldenrqpsir"   results'                                          r   r.   r.   {   s!   $ F
6{{a9:::FB	BwwCDDDDAFDy!!Hty~~-.KrqA{a!e$$DDCMC!
A	a$B
CBI	BED	ABdhrll"US[0D:Daxxc


f(I,?@AAA8BGsa!e} 4558A;;Fcb5j)AdrDy)Ada28q.0Aq1uA3wwBAAA !txAa0000q1a"f:~~a"f%%3w!mH)UdNNQ$27++RA~>B)C 	#RxxFFa-C"DYs^^sax(dl48C==$7777T!^d^^^q!RL	!88,	TG0CDEEE88Bwwt%DBCBB2vvd

r		!4erT++42::43;;eAE]$(2,,&4Tz&==DK 8BGsa!e} 455N z"~~ B 4:b>> Daxx!T4555TDAI(9)3(7(>%@ %@ ADD" s5 5 5F Mr   )r   r'   r(   r   r   )r   r'   r(   r   )r   r>   r   dictr
   r&   r6   r.   r   r   r   <module>rb      s    3 3  F/*33%.	/ 	/. . . . .T . . .    8;"#J J J JZ 13;<J J J J J Jr   