+
    LV-ju  ã                   ó0  € ^ RI Ht ^ RIt^ RIHt ^RIHtH	t	 ^RI
Ht ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt Rt ! R	 R
4      t ! R R4      t ! R R4      t ! R R4      t ! R R4      t ! R R4      t ! R R4      t ! R R4      t ! R R]4      tR# )é    )Ú
namedtupleN)Úapprox_derivativeÚgroup_columns)ÚHessianUpdateStrategy)ÚLinearOperator)Úarray_namespaceÚxp_copy)Úarray_api_extra)Ú_ScalarFunctionWrapperc                   ó8   a € ] tR t^t o RtRR ltRR ltRtV tR# )Ú_ScalarGradWrapperz(
Wrapper class for gradient calculation
Nc                ó`   € W n         Wn        Vf   . MTV n        W@n        ^ V n        ^ V n        R # ©N)ÚfunÚgradÚargsÚfinite_diff_optionsÚngevÚnfev)Úselfr   r   r   r   s   &&&&&Úy/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/optimize/_differentiable_functions.pyÚ__init__Ú_ScalarGradWrapper.__init__   s/   € ð ŒØŒ	Øš,‘B¨DˆŒ	Ø#6Ô ØˆŒ	àˆŽ	ó    c                ó°  € \        V P                  4      '       dH   \        P                  ! V P                  ! \        P                  ! V4      .V P
                  O5!  4      pMZV P                  \        9   dF   \        V P                  V3R V/V P                  B w  rEV ;P                  VR,          ,          un
        V ;P                  ^,          un        X# ©Úf0r   )Úcallabler   ÚnpÚ
atleast_1dÚcopyr   Ú
FD_METHODSr   r   r   r   r   )r   Úxr   ÚkwdsÚgÚdcts   &&&,  r   Ú__call__Ú_ScalarGradWrapper.__call__#   s�   € ô �D—I‘I×ÒÜ—’˜dŸiši¬¯ª°«
Ð?°T·Y±YÓ?Ó@‰AØ�Y‰Yœ*Ô$Ü&Ø—‘Øñð ðð ×*Ñ*ñ	‰FˆAð �IŠI˜˜V�Õ$�Ià�	Š	�Q��	Øˆr   )r   r   r   r   r   r   ©NNNr   ©	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r'   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r      s   ø‡ € ñô÷ò r   r   c                   óT   a € ] tR t^5t o RtR
R ltRR ltRR ltR tR t	R t
R	tV tR# )Ú_ScalarHessWrapperz;
Wrapper class for hess calculation via finite differences
Nc                ó¼  € Wn         W0n        Vf   . MTV n        WPn        ^ V n        ^ V n        R V n        R V n        \        V4      '       dü   V! \        P                  ! V4      .VO5!  V n        V ;P
                  ^,          un        \        P                  ! V P                  4      '       d/   RV n        \        P                  ! V P                  4      V n        R # \        V P                  \        4      '       d
   RV n        R # RV n        \        P                   ! \        P"                  ! V P                  4      4      V n        R # V\$        9   d
   RV n        R # R # )NÚsparse_callableÚlinearoperator_callableÚdense_callableÚfd_hess)Úhessr   r   r   r   ÚnhevÚHÚ
_hess_funcr   r   r!   ÚspsÚissparseÚ	csr_arrayÚ
isinstancer   Ú
atleast_2dÚasarrayr"   )r   r;   Úx0r   r   r   s   &&&&&&r   r   Ú_ScalarHessWrapper.__init__9   sì   € ð Œ	ØŒ	Øš,‘B¨DˆŒ	Ø#6Ô àˆŒ	ØˆŒ	ØˆŒØˆŒä�D�>Š>Ùœ"Ÿ'š' "›+Ð-¨Ó-ˆDŒFØ�IŠI˜�N�Iä�|Š|˜DŸF™F×#Ò#Ø"3�”ÜŸš t§v¡vÓ.�–Ü˜DŸF™F¤N×3Ò3Ø";�–ð #3�”ÜŸš¤r§z¢z°$·&±&Ó'9Ó:�–Ø”ZÔØ"+�–ñ  r   c                óö   € V P                   ;R 8X  d    V P                  pM<;R8X  d    V P                  pM';R8X  d    V P                  pMR8X  d   V P                  pX! \
        P                  ! V4      VR7      # )r7   r8   r9   r:   ©r   )r>   Ú_sparse_callableÚ_linearoperator_callableÚ_dense_callableÚ_fd_hessr   r!   )r   r#   r   r$   Ú_hs   &&&, r   r'   Ú_ScalarHessWrapper.__call__[   sT   € Ø�o‰oÞ"Ù×*Ñ*‘Þ*Ù×2Ñ2‘Þ!Ù×)Ñ)‘ÝØ—]‘]�á”"—'’'˜!“* Ô$Ð$r   c                ó°   € \        V P                  V3R V/V P                  B w  V n        pV ;P                  VR,          ,          un        V P                  # r   )r   r   r   r=   r   )r   r#   r   r$   r&   s   &&&, r   rL   Ú_ScalarHessWrapper._fd_hessh   sN   € Ü'Ø�I‰I�qñ
Øð
Ø#'×#;Ñ#;ñ
‰ˆŒ�ð 	�	Š	�S˜•[Õ �	Ø�v‰vˆr   c                óº   € V ;P                   ^,          un         \        P                  ! V P                  ! V.V P                  O5!  4      V n        V P
                  # ©é   )r<   r?   rA   r;   r   r=   ©r   r#   r$   s   &&,r   rI   Ú#_ScalarHessWrapper._sparse_callableo   s:   € Ø�	Š	�Q��	Ü—’˜tŸyšy¨Ð7¨T¯Y©YÓ7Ó8ˆŒØ�v‰vˆr   c                óâ   € V ;P                   ^,          un         \        P                  ! \        P                  ! V P                  ! V.V P
                  O5!  4      4      V n        V P                  # rR   )r<   r   rC   rD   r;   r   r=   rT   s   &&,r   rK   Ú"_ScalarHessWrapper._dense_callablet   sH   € Ø�	Š	�Q��	Ü—’Ü�JŠJ�t—y’y Ð/ T§Y¡YÓ/Ó0ó
ˆŒð �v‰vˆr   c                ó’   € V ;P                   ^,          un         V P                  ! V.V P                  O5!  V n        V P                  # rR   )r<   r;   r   r=   rT   s   &&,r   rJ   Ú+_ScalarHessWrapper._linearoperator_callable{   s1   € Ø�	Š	�Q��	Ø—’˜1Ð)˜tŸy™yÓ)ˆŒØ�v‰vˆr   )r=   r>   r   r   r   r;   r   r<   )NNNNr   )r+   r,   r-   r.   r/   r   r'   rL   rI   rK   rJ   r0   r1   r2   s   @r   r5   r5   5   s.   ø‡ € ñô ,ôD%ôòò
÷ð r   r5   c                   óÄ   a € ] tR t^€t o RtR]P                  ) ]P                  3RR3R lt]R 4       t	]R 4       t
]R 4       tR tR tR	 tR
 tR tR tR tR tRtV tR# )ÚScalarFunctiona“  Scalar function and its derivatives.

This class defines a scalar function F: R^n->R and methods for
computing or approximating its first and second derivatives.

Parameters
----------
fun : callable
    evaluates the scalar function. Must be of the form ``fun(x, *args)``,
    where ``x`` is the argument in the form of a 1-D array and ``args`` is
    a tuple of any additional fixed parameters needed to completely specify
    the function. Should return a scalar.
x0 : array-like
    Provides an initial set of variables for evaluating fun. Array of real
    elements of size (n,), where 'n' is the number of independent
    variables.
args : tuple, optional
    Any additional fixed parameters needed to completely specify the scalar
    function.
grad : {callable, '2-point', '3-point', 'cs'}
    Method for computing the gradient vector.
    If it is a callable, it should be a function that returns the gradient
    vector:

        ``grad(x, *args) -> array_like, shape (n,)``

    where ``x`` is an array with shape (n,) and ``args`` is a tuple with
    the fixed parameters.
    Alternatively, the keywords  {'2-point', '3-point', 'cs'} can be used
    to select a finite difference scheme for numerical estimation of the
    gradient with a relative step size. These finite difference schemes
    obey any specified `bounds`.
hess : {callable, '2-point', '3-point', 'cs', HessianUpdateStrategy}
    Method for computing the Hessian matrix. If it is callable, it should
    return the  Hessian matrix:

        ``hess(x, *args) -> {LinearOperator, spmatrix, array}, (n, n)``

    where x is a (n,) ndarray and `args` is a tuple with the fixed
    parameters. Alternatively, the keywords {'2-point', '3-point', 'cs'}
    select a finite difference scheme for numerical estimation. Or, objects
    implementing `HessianUpdateStrategy` interface can be used to
    approximate the Hessian.
    Whenever the gradient is estimated via finite-differences, the Hessian
    cannot be estimated with options {'2-point', '3-point', 'cs'} and needs
    to be estimated using one of the quasi-Newton strategies.
finite_diff_rel_step : None or array_like
    Relative step size to use. The absolute step size is computed as
    ``h = finite_diff_rel_step * sign(x0) * max(1, abs(x0))``, possibly
    adjusted to fit into the bounds. For ``method='3-point'`` the sign
    of `h` is ignored. If None then finite_diff_rel_step is selected
    automatically,
finite_diff_bounds : tuple of array_like
    Lower and upper bounds on independent variables. Defaults to no bounds,
    (-np.inf, np.inf). Each bound must match the size of `x0` or be a
    scalar, in the latter case the bound will be the same for all
    variables. Use it to limit the range of function evaluation.
epsilon : None or array_like, optional
    Absolute step size to use, possibly adjusted to fit into the bounds.
    For ``method='3-point'`` the sign of `epsilon` is ignored. By default
    relative steps are used, only if ``epsilon is not None`` are absolute
    steps used.
workers : map-like callable, optional
    A map-like callable, such as `multiprocessing.Pool.map` for evaluating
    any numerical differentiation in parallel.
    This evaluation is carried out as ``workers(fun, iterable)``, or
    ``workers(grad, iterable)``, depending on what is being numerically
    differentiated.
    Alternatively, if `workers` is an int the task is subdivided into `workers`
    sections and the function evaluated in parallel
    (uses `multiprocessing.Pool <multiprocessing>`).
    Supply -1 to use all available CPU cores.
    It is recommended that a map-like be used instead of int, as repeated
    calls to `approx_derivative` will incur large overhead from setting up
    new processes.

    .. versionadded:: 1.16.0

Notes
-----
This class implements a memoization logic. There are methods `fun`,
`grad`, hess` and corresponding attributes `f`, `g` and `H`. The following
things should be considered:

    1. Use only public methods `fun`, `grad` and `hess`.
    2. After one of the methods is called, the corresponding attribute
       will be set. However, a subsequent call with a different argument
       of *any* of the methods may overwrite the attribute.
Nc
                óÔ  € \        V4      '       g   V\        9  d   \        R \         R24      h\        V4      '       g5   V\        9   g*   \        V\        4      '       g   \        R\         R24      hV\        9   d   V\        9   d   \        R4      h\        V4      ;V n        p
\        P                  ! V
P                  V4      ^V
R7      pV
P                  pV
P                  VP                  R4      '       d   VP                  p\        W4      V n        Wn        W@n        WPn        W0n        V
P'                  W¼4      V n        WÀn        V P(                  P,                  V n        RV n        RV n        RV n        RV n        \8        P:                  V n        T	;'       g    \>        p	/ pV\        9   d   WMR&   WmR	&   W�R
&   W}R&   W�R&   RVR&   V\        9   d   W]R&   WmR	&   W�R
&   RVR&   W�R&   RVR&   ^ V n         V PC                  4        \E        VV P                  VVR7      V n#        V PI                  4        \        V\        4      '       da   WPn%        V PJ                  PM                  V P.                  R4       RV n        RV n'        RV n(        \S        RRR.4      pV! ^ ^ R7      V n*        R# \        V4      '       d9   \W        VVVVR7      V n*        V PT                  PJ                  V n%        RV n        R# V\        9   de   \W        VVVV PF                  VR7      V n*        V PI                  4        V PU                  V P(                  V PX                  R7      V n%        RV n        R# R# )z)`grad` must be either callable or one of Ú.z@`hess` must be either callable, HessianUpdateStrategy or one of z‹Whenever the gradient is estimated via finite-differences, we require the Hessian to be estimated using one of the quasi-Newton strategies.©ÚndimÚxpúreal floatingFNÚmethodÚrel_stepÚabs_stepÚboundsÚworkersTÚfull_outputÚas_linear_operator)r   r   r   r;   Ú_FakeCounterr   r<   )r   r<   )rE   r   r   )rE   r   r   r   rH   )-r   r"   Ú
ValueErrorrB   r   r   r`   ÚxpxÚ
atleast_ndrD   Úfloat64ÚisdtypeÚdtyper   Ú_wrapped_funÚ	_orig_funÚ
_orig_gradÚ
_orig_hessÚ_argsÚastyper#   Úx_dtypeÚsizeÚnÚ	f_updatedÚ	g_updatedÚ	H_updatedÚ	_lowest_xr   ÚinfÚ	_lowest_fÚmapÚ_nfevÚ_update_funr   Ú_wrapped_gradÚ_update_gradr=   Ú
initializeÚx_prevÚg_prevr   Ú_wrapped_hessr5   r%   )r   r   rE   r   r   r;   Úfinite_diff_rel_stepÚfinite_diff_boundsÚepsilonrf   r`   Ú_xÚ_dtyper   ri   s   &&&&&&&&&&     r   r   ÚScalarFunction.__init__Ú   s&  € ô ˜�~Š~ $¬jÔ"8ÜØ;¼J¸<ÀqÐIóð ô ˜—’ $¬*Ô"4Ü˜dÔ$9×:Ò:ÜðÜ(˜\¨ð,óð ð
 ”:Ô $¬*Ô"4Üð 8ó 9ð 9ô ' rÓ*Ð*ˆŒ�"Ü�^Š^˜BŸJ™J r›N°°rÔ:ˆØ—‘ˆØ�:‰:�b—h‘h ×0Ò0Ø—X‘XˆFô 3°3Ó=ˆÔØŒØŒØŒØŒ
ð —‘˜2Ó&ˆŒØŒØ—‘—‘ˆŒØˆŒØˆŒØˆŒàˆŒÜŸ™ˆŒð —.�.œSˆà ÐØ”:ÔØ,0 Ñ)Ø.B 
Ñ+Ø.5 
Ñ+Ø,> Ñ)Ø-4 	Ñ*Ø15Ð Ñ.Ø”:ÔØ,0 Ñ)Ø.B 
Ñ+Ø.5 
Ñ+Ø8<ÐÐ 4Ñ5Ø-4 	Ñ*Ø15Ð Ñ.ð ˆŒ
Ø×ÑÔô 0ØØ×!Ñ!ØØ 3ô	
ˆÔð 	×ÑÔô �dÔ1×2Ò2ØŒFØ�F‰F×Ñ˜dŸf™f fÔ-Ø!ˆDŒNØˆDŒKØˆDŒKÜ% n°v¸vÐ6FÓGˆLÙ!-°1¸1Ô!=ˆDÖä˜�~Š~Ü%7ØØØØ(;ô	&�Ô"ð ×+Ñ+×-Ñ-�”Ø!%�–ØœÔ#Ü%7ØØØØ×+Ñ+Ø(;ô&�Ô"ð ×!Ñ!Ô#Ø×+Ñ+¨D¯F©F°t·v±vÐ+Ó>�”Ø!%�–ñ $r   c                óP   € V P                   V P                  P                  ,           # r   )r€   r‚   r   ©r   s   &r   r   ÚScalarFunction.nfevE  s   € à�z‰z˜D×.Ñ.×3Ñ3Õ3Ð3r   c                ó.   € V P                   P                  # r   )r‚   r   r�   s   &r   r   ÚScalarFunction.ngevI  ó   € à×!Ñ!×&Ñ&Ð&r   c                ó.   € V P                   P                  # r   )r‡   r<   r�   s   &r   r<   ÚScalarFunction.nhevM  r“   r   c                óº  € \        V P                  \        4      '       dÀ   V P                  4        V P                  V n        V P                  V n        \        P                  ! V P                  P                  V4      ^V P                  R7      pV P                  P                  W P                  4      V n        RV n        RV n        RV n        V P#                  4        R# \        P                  ! V P                  P                  V4      ^V P                  R7      pV P                  P                  W P                  4      V n        RV n        RV n        RV n        R# ©rS   r^   FN)rB   rs   r   rƒ   r#   r…   r%   r†   rk   rl   r`   rD   ru   rv   ry   rz   r{   Ú_update_hess©r   r#   r‹   s   && r   Ú	_update_xÚScalarFunction._update_xQ  sæ   € Ü�d—o‘oÔ'<×=Ò=Ø×ÑÔØŸ&™&ˆDŒKØŸ&™&ˆDŒKô —’ §¡§¡°Ó 2¸¸t¿w¹wÔGˆBØ—W‘W—^‘^ B¯©Ó5ˆDŒFØ"ˆDŒNØ"ˆDŒNØ"ˆDŒNØ×ÑÖô —’ §¡§¡°Ó 2¸¸t¿w¹wÔGˆBØ—W‘W—^‘^ B¯©Ó5ˆDŒFØ"ˆDŒNØ"ˆDŒNØ"ˆDŽNr   c                óþ   € V P                   '       gk   V P                  V P                  4      pV ;P                  ^,          un        WP                  8  d   V P                  V n        Wn        Wn        RV n         R# R# ©rS   TN)ry   rp   r#   r€   r~   r|   Úf)r   Úfxs   & r   r�   ÚScalarFunction._update_funh  sW   € Ø�~�~ˆ~Ø×"Ñ" 4§6¡6Ó*ˆBØ�JŠJ˜!�O�JØ—N‘NÔ"Ø!%§¡�”Ø!#”àŒFØ!ˆDŽNñ r   c                óÞ   € V P                   '       g[   V P                  \        9   d   V P                  4        V P	                  V P
                  V P                  R 7      V n        RV n         R# R# ©rH   TN)rz   rr   r"   r�   r‚   r#   rž   r%   r�   s   &r   rƒ   ÚScalarFunction._update_grads  sN   € Ø�~�~ˆ~Ø�‰¤*Ô,Ø× Ñ Ô"Ø×'Ñ'¨¯©°4·6±6Ð'Ó:ˆDŒFØ!ˆDŽNñ	 r   c                ó&  € V P                   '       gÿ   V P                  \        9   d>   V P                  4        V P	                  V P
                  V P                  R 7      V n        M£\        V P                  \        4      '       dd   V P                  4        V P                  P                  V P
                  V P                  ,
          V P                  V P                  ,
          4       M V P	                  V P
                  4      V n        RV n         R# R# r¢   )r{   rs   r"   rƒ   r‡   r#   r%   r=   rB   r   Úupdater…   r†   r�   s   &r   r˜   ÚScalarFunction._update_hessz  s®   € Ø�~�~ˆ~Ø�‰¤*Ô,Ø×!Ñ!Ô#Ø×+Ñ+¨D¯F©F°t·v±vÐ+Ó>�•Ü˜DŸO™OÔ-B×CÒCØ×!Ñ!Ô#Ø—‘—‘˜dŸf™f t§{¡{Õ2°D·F±F¸T¿[¹[Õ4HÕIà×+Ñ+¨D¯F©FÓ3�”à!ˆDŽNñ r   c                ó¨   € \         P                  ! WP                  4      '       g   V P                  V4       V P	                  4        V P
                  # r   )r   Úarray_equalr#   rš   r�   rž   ©r   r#   s   &&r   r   ÚScalarFunction.fun‡  s6   € Ü�~Š~˜a§¡×(Ò(Ø�N‰N˜1ÔØ×ÑÔØ�v‰vˆr   c                ó¨   € \         P                  ! WP                  4      '       g   V P                  V4       V P	                  4        V P
                  # r   )r   r¨   r#   rš   rƒ   r%   r©   s   &&r   r   ÚScalarFunction.grad�  ó6   € Ü�~Š~˜a§¡×(Ò(Ø�N‰N˜1ÔØ×ÑÔØ�v‰vˆr   c                ó¨   € \         P                  ! WP                  4      '       g   V P                  V4       V P	                  4        V P
                  # r   )r   r¨   r#   rš   r˜   r=   r©   s   &&r   r;   ÚScalarFunction.hess“  r­   r   c                óà   € \         P                  ! WP                  4      '       g   V P                  V4       V P	                  4        V P                  4        V P                  V P                  3# r   )r   r¨   r#   rš   r�   rƒ   rž   r%   r©   s   &&r   Úfun_and_gradÚScalarFunction.fun_and_grad™  sK   € Ü�~Š~˜a§¡×(Ò(Ø�N‰N˜1ÔØ×ÑÔØ×ÑÔØ�v‰v�t—v‘vˆ~Ðr   )r=   r{   rt   r~   r|   r€   rq   rr   rs   rp   r‚   r‡   rž   ry   r%   r†   rz   rx   r#   rv   r…   r`   )r+   r,   r-   r.   r/   r   r}   r   Úpropertyr   r   r<   rš   r�   rƒ   r˜   r   r   r;   r±   r0   r1   r2   s   @r   r[   r[   €   s™   ø‡ € ñXðr HLØ&(§f¡f W¨b¯f©fÐ$5¸tÈTôi&ðV ñ4ó ð4ð ñ'ó ð'ð ñ'ó ð'ò#ò.	"ò"ò"òòò÷ð r   r[   c                   ó,   a € ] tR tRt o R tR tRtV tR# )Ú_VectorFunWrapperi¡  c                ó    € Wn         ^ V n        R# ©r   N©r   r   )r   r   s   &&r   r   Ú_VectorFunWrapper.__init__¢  s   € ØŒØˆŽ	r   c                ó~   € V ;P                   ^,          un         \        P                  ! V P                  V4      4      # rR   )r   r   r    r   r©   s   &&r   r'   Ú_VectorFunWrapper.__call__¦  s&   € Ø�	Š	�Q��	Ü�}Š}˜TŸX™X a›[Ó)Ð)r   r¸   N)r+   r,   r-   r.   r   r'   r0   r1   r2   s   @r   rµ   rµ   ¡  s   ø‡ € ò÷*ð *r   rµ   c                   ó8   a € ] tR tRt o RtRR ltRR ltRtV tR# )	Ú_VectorJacWrapperi«  ú(
Wrapper class for Jacobian calculation
Nc                óR   € W n         Wn        W0n        W@n        ^ V n        ^ V n        R# r·   )r   Újacr   Úsparse_jacobianÚnjevr   )r   rÀ   r   r   rÁ   s   &&&&&r   r   Ú_VectorJacWrapper.__init__¯  s(   € ð ŒØŒØ#6Ô Ø.ÔàˆŒ	àˆŽ	r   c                óF  € \        V P                  4      '       d,   V P                  V4      pV ;P                  ^,          un        MZV P                  \        9   dF   \	        V P
                  V3RV/V P                  B w  rEV ;P                  VR,          ,          un        V P                  '       d   \        P                  ! X4      # \        P                  ! X4      '       d   VP                  4       # \        V\        4      '       d   V# \        P                   ! V4      # )rS   r   r   )r   rÀ   rÂ   r"   r   r   r   r   rÁ   r?   rA   r@   ÚtoarrayrB   r   r   rC   )r   r#   r   r$   ÚJr&   s   &&&,  r   r'   Ú_VectorJacWrapper.__call__¿  sÒ   € ô �D—H‘H×ÒØ—‘˜“ˆAØ�IŠI˜�NŽIØ�X‰XœÔ#Ü&Ø—‘Øñð ðð ×*Ñ*ñ	‰FˆAð �IŠI˜˜V�Õ$�Ià××ÐÜ—=’= Ó#Ð#Ü�\Š\˜!�_Š_Ø—9‘9“;ÐÜ˜œ>×*Ò*ØˆHä—=’= Ó#Ð#r   )r   r   rÀ   r   rÂ   rÁ   r)   r   r*   r2   s   @r   r½   r½   «  s   ø‡ € ñô÷ $ò $r   r½   c                   óN   a € ] tR tRt o RtR
R ltRR ltRR ltR tR t	R	t
V tR# )Ú_VectorHessWrapperiØ  r¾   Nc                óF   € W n         Wn        W0n        ^ V n        ^ V n        R# r·   )rÀ   r;   r   r<   rÂ   )r   r;   rÀ   r   s   &&&&r   r   Ú_VectorHessWrapper.__init__Ü  s"   € ð ŒØŒ	Ø#6Ô ØˆŒ	àˆŽ	r   c                óà   € \        V P                  4      '       d+   V ;P                  ^,          un        V P                  W4      # V P                  \        9   d   V P                  WVR7      # R# )rS   ©ÚJ0N)r   r;   r<   Ú_callable_hessr"   rL   )r   r#   ÚvrÎ   r$   s   &&&&,r   r'   Ú_VectorHessWrapper.__call__é  sU   € ô �D—I‘I×ÒØ�IŠI˜�N�IØ×&Ñ& qÓ,Ð,Ø�Y‰Yœ*Ô$Ø—=‘= ¨"�=Ó-Ð-ñ %r   c                óà   € Vf+   V P                  V4      pV ;P                  ^,          un        \        V P                  V3RVP                  P                  V4      RV3/V P                  B pV# )Nr   r   )rÀ   rÂ   r   Ú	jac_dot_vÚTÚdotr   )r   r#   rÐ   rÎ   r=   s   &&&& r   rL   Ú_VectorHessWrapper._fd_hessò  sj   € ØŠ:Ø—‘˜!“ˆBØ�IŠI˜�N�Iô ˜dŸn™n¨añ :Ø!#§¡§¡¨!£ð:à$% 4ð:ð !%× 8Ñ 8ñ:ˆð ˆr   c                óˆ   € V ;P                   ^,          un         V P                  V4      P                  P                  V4      # rR   )rÂ   rÀ   rÔ   rÕ   ©r   r#   rÐ   s   &&&r   rÓ   Ú_VectorHessWrapper.jac_dot_vþ  s,   € Ø�	Š	�Q��	Ø�x‰x˜‹{�}‰}× Ñ  Ó#Ð#r   c                ó  € V P                  W4      p\        P                  ! V4      '       d   \        P                  ! V4      # \	        V\
        4      '       d   V# \        P                  ! \        P                  ! V4      4      # r   )	r;   r?   r@   rA   rB   r   r   rC   rD   )r   r#   rÐ   r=   s   &&& r   rÏ   Ú!_VectorHessWrapper._callable_hess  sT   € Ø�I‰I�a‹Oˆä�<Š<˜�?Š?Ü—=’= Ó#Ð#Ü˜œ>×*Ò*ØˆHä—=’=¤§¢¨A£Ó/Ð/r   )r   r;   rÀ   r<   rÂ   )NNr   )r+   r,   r-   r.   r/   r   r'   rL   rÓ   rÏ   r0   r1   r2   s   @r   rÉ   rÉ   Ø  s(   ø‡ € ñôô.ô
ò$÷0ð 0r   rÉ   c                   óÆ   a € ] tR tRt o RtRR]P                  ) ]P                  3RR3R lt]R 4       t	]R 4       t
]R 4       tR tR	 tR
 tR tR tR tR tR tRtV tR# )ÚVectorFunctioni  aa  Vector function and its derivatives.

This class defines a vector function F: R^n->R^m and methods for
computing or approximating its first and second derivatives.

Notes
-----
This class implements a memoization logic. There are methods `fun`,
`jac`, hess` and corresponding attributes `f`, `J` and `H`. The following
things should be considered:

    1. Use only public methods `fun`, `jac` and `hess`.
    2. After one of the methods is called, the corresponding attribute
       will be set. However, a subsequent call with a different argument
       of *any* of the methods may overwrite the attribute.
Nc
                ó  € \        V4      '       g   V\        9  d   \        R \         R24      h\        V4      '       g5   V\        9   g*   \        V\        4      '       g   \        R\         R24      hV\        9   d   V\        9   d   \        R4      h\        V4      ;V n        p
\        P                  ! V
P                  V4      ^V
R7      pV
P                  pV
P                  VP                  R4      '       d   VP                  pWn        W0n        W@n        V
P!                  W¼4      V n        WÀn        V P"                  P&                  V n        ^ V n        ^ V n        ^ V n        RV n        RV n        RV n        T	;'       g    \6        p	/ pV\        9   dQ   W=R&   W]R&   Ve   \9        V4      pVV3VR
&   W}R&   W�R&   RVR&   \:        P<                  ! V P"                  4      V n        V\        9   d3   WMR&   W]R&   RVR&   \:        P<                  ! V P"                  4      V n        V\        9   d   V\        9   d   \        R4      h\A        V4      V n!        V PE                  4        \:        PF                  ! V PH                  4      V n%        V PJ                  P&                  V n&        \        V4      '       dB   V! \O        V P"                  4      4      V n(        RV n        V ;P,                  ^,          un        MgV\        9   d]   \S        V PB                  V P"                  3RV PH                  /VB w  V n(        pRV n        V ;P*                  VR,          ,          un        RV n*        V'       g+   VfT   \V        PX                  ! V PP                  4      '       d.   \V        PZ                  ! V PP                  4      V n(        RV n*        MŒ\V        PX                  ! V PP                  4      '       d!   V PP                  P]                  4       V n(        MF\        V PP                  \^        4      '       d   M%\:        P`                  ! V PP                  4      V n(        \c        VV PB                  VV PT                  R7      V n2        \g        W@Pd                  VR7      V n4        \        V4      '       g   V\        9   dv   V Pi                  \O        V P"                  4      V PJ                  V PP                  R7      V n5        RV n        \        V4      '       d   V ;P.                  ^,          un        R	# R	# \        V\        4      '       dD   W@n5        V Pj                  Pm                  V P(                  R4       RV n        R	V n7        R	V n8        R	# R	# )z(`jac` must be either callable or one of r]   z?`hess` must be either callable,HessianUpdateStrategy or one of z‹Whenever the Jacobian is estimated via finite-differences, we require the Hessian to be estimated using one of the quasi-Newton strategies.r^   ra   Frb   rc   NÚsparsityre   rf   Trg   rh   r   r   )r   r   rÁ   )rÀ   r   rÍ   r;   )9r   r"   rj   rB   r   r   r`   rk   rl   rD   rm   rn   ro   rq   Ú	_orig_jacrs   ru   r#   rv   rw   rx   r€   Ú_njevÚ_nhevry   Ú	J_updatedr{   r   r   r   r!   Úx_diffrµ   Úfun_wrappedr�   Ú
zeros_likerž   rÐ   Úmr	   rÆ   r   rÁ   r?   r@   rA   rÅ   r   rC   r½   Újac_wrappedrÉ   Úhess_wrappedr=   r„   r…   ÚJ_prev)r   r   rE   rÀ   r;   rˆ   Úfinite_diff_jac_sparsityr‰   rÁ   rf   r`   r‹   rŒ   r   Úsparsity_groupsr&   s   &&&&&&&&&&      r   r   ÚVectorFunction.__init__  sQ  € ô ˜�}Š} ¬JÔ!6ÜÐGÌ
À|ÐSTÐUÓVÐVä˜—’ $¬*Ô"4Ü˜dÔ$9×:Ò:Üð @Ü@J¸|È1ðNó Oð Oð ”*Ô ¬Ô!3Üð +ó ,ð ,ô
 ' rÓ*Ð*ˆŒ�"Ü�^Š^˜BŸJ™J r›N°°rÔ:ˆØ—‘ˆØ�:‰:�b—h‘h ×0Ò0Ø—X‘XˆFð ŒØŒØŒð —‘˜2Ó&ˆŒØŒà—‘—‘ˆŒØˆŒ
ØˆŒ
ØˆŒ
ØˆŒØˆŒØˆŒð —.�.œSˆà ÐØ”*ÔØ,/ Ñ)Ø.B 
Ñ+Ø'Ò3Ü"/Ð0HÓ"I�Ø3KØ3Bð3DÐ# JÑ/à,> Ñ)Ø-4 	Ñ*Ø15Ð Ñ.ÜŸ'š' $§&¡&›/ˆDŒKØ”:ÔØ,0 Ñ)Ø.B 
Ñ+Ø8<ÐÐ 4Ñ5ô
 Ÿ'š' $§&¡&›/ˆDŒKØ”*Ô ¬Ô!3Üð +ó ,ð ,ô
 -¨SÓ1ˆÔØ×ÑÔä—’˜tŸv™vÓ&ˆŒØ—‘—‘ˆŒô �C�=Š=Ùœ §¡›Ó)ˆDŒFØ!ˆDŒNØ�JŠJ˜!�OŽJØ”JÔÜ+Ø× Ñ  $§&¡&ñØ-1¯V©VðØ7Jñ‰KˆDŒF�Cð "ˆDŒNØ�JŠJ˜#˜f�+Õ%�Jà$ˆÔßØÒ'¬C¯LªL¸¿¹×,@Ò,@ô —]’] 4§6¡6Ó*ˆDŒFØ#'ˆDÕ Ü�\Š\˜$Ÿ&™&×!Ò!Ø—V‘V—^‘^Ó%ˆD�FÜ˜Ÿ™¤×/Ò/Øä—]’] 4§6¡6Ó*ˆDŒFä,ØØ× Ñ Ø 3Ø ×0Ñ0ô	
ˆÔô /Ø×&Ñ&Ð<Oô
ˆÔô
 �D�>Š>˜T¤ZÔ/Ø×&Ñ&¤w¨t¯v©v£¸¿¹À4Ç6Á6Ð&ÓJˆDŒFØ!ˆDŒNÜ˜�~Š~Ø—
’
˜a•—
ñ ä˜Ô3×4Ò4ØŒFØ�F‰F×Ñ˜dŸf™f fÔ-Ø!ˆDŒNØˆDŒKØˆDŽKñ 5r   c                óP   € V P                   V P                  P                  ,           # r   )r€   rè   r   r�   s   &r   r   ÚVectorFunction.nfev�  s   € à�z‰z˜D×,Ñ,×1Ñ1Õ1Ð1r   c                óP   € V P                   V P                  P                  ,           # r   )rá   ré   rÂ   r�   s   &r   rÂ   ÚVectorFunction.njev¡  s   € à�z‰z˜D×-Ñ-×2Ñ2Õ2Ð2r   c                ó   € V P                   # r   )râ   r�   s   &r   r<   ÚVectorFunction.nhev¥  s   € à�z‰zÐr   c                óp   € \         P                  ! WP                  4      '       g   Wn        R V n        R# R# )FN)r   r¨   rÐ   r{   )r   rÐ   s   &&r   Ú	_update_vÚVectorFunction._update_v©  s&   € Ü�~Š~˜a§¡×(Ò(ØŒFØ"ˆDŽNñ )r   c                ó  € \         P                  ! WP                  4      '       Eg]   \        V P                  \
        4      '       dÀ   V P                  4        V P                  V n        V P                  V n	        \        P                  ! V P                  P                  V4      ^V P                  R7      pV P                  P                  W P                  4      V n        RV n        RV n        RV n        V P'                  4        R# \        P                  ! V P                  P                  V4      ^V P                  R7      pV P                  P                  W P                  4      V n        RV n        RV n        RV n        R# R# r—   )r   r¨   r#   rB   rs   r   Ú_update_jacr…   rÆ   rê   rk   rl   r`   rD   ru   rv   ry   rã   r{   r˜   r™   s   && r   rš   ÚVectorFunction._update_x®  sú   € Ü�~Š~˜a§¡×(Ó(Ü˜$Ÿ/™/Ô+@×AÒAØ× Ñ Ô"Ø"Ÿf™f�”Ø"Ÿf™f�”Ü—^’^ D§G¡G§O¡O°AÓ$6¸QÀ4Ç7Á7ÔK�ØŸ™Ÿ™¨¯L©LÓ9�”Ø!&�”Ø!&�”Ø!&�”Ø×!Ñ!Ö#ä—^’^ D§G¡G§O¡O°AÓ$6¸QÀ4Ç7Á7ÔK�ØŸ™Ÿ™¨¯L©LÓ9�”Ø!&�”Ø!&�”Ø!&�–ñ! )r   c                óÀ   € V P                   '       gL   V P                  \        V P                  4      4      V n        V ;P
                  ^,          un        RV n         R# R# r�   )ry   rå   r	   r#   rž   r€   r�   s   &r   r�   ÚVectorFunction._update_funÁ  s>   € Ø�~�~ˆ~Ø×%Ñ%¤g¨d¯f©f£oÓ6ˆDŒFØ�JŠJ˜!�O�JØ!ˆDŽNñ r   c                ó$  € V P                   '       g~   V P                  \        9   d   V P                  4        MV ;P                  ^,          un        V P                  \        V P                  4      V P                  R7      V n	        RV n         R# R# )rS   rH   TN)
rã   rà   r"   r�   rá   rè   r	   r#   rž   rÆ   r�   s   &r   rø   ÚVectorFunction._update_jacÇ  s_   € Ø�~�~ˆ~Ø�~‰~¤Ô+à× Ñ Õ"à—
’
˜a••
à×%Ñ%¤g¨d¯f©f£o¸$¿&¹&Ð%ÓAˆDŒFØ!ˆDŽNñ r   c                ó¬  € V P                   '       EgÁ   \        V P                  4      '       dP   V P                  \	        V P
                  4      V P                  4      V n        V ;P                  ^,          un        EMMV P                  \        9   dR   V P                  4        V P                  \	        V P
                  4      V P                  V P                  R7      V n        Mç\        V P                  \        4      '       dÈ   V P                  4        V P                  eª   V P                  eœ   V P
                  V P                  ,
          pV P                  P                   P#                  V P                  4      V P                  P                   P#                  V P                  4      ,
          pV P                  P%                  W4       RV n         R# R# )rS   rÍ   NT)r{   r   rs   ré   r	   r#   rÐ   r=   râ   r"   rø   rÆ   rB   r   r…   rê   rÔ   rÕ   r¥   )r   Údelta_xÚdelta_gs   &  r   r˜   ÚVectorFunction._update_hessÒ  s  € Ø�~�~‰~Ü˜Ÿ™×(Ò(Ø×*Ñ*¬7°4·6±6«?¸D¿F¹FÓC�”Ø—
’
˜a•—
Ø—‘¤JÔ.Ø× Ñ Ô"Ø×*Ñ*¬7°4·6±6«?¸D¿F¹FÀtÇvÁvÐ*ÓN�•Ü˜DŸO™OÔ-B×CÒCØ× Ñ Ô"ð —;‘;Ò*¨t¯{©{Ò/FØ"Ÿf™f t§{¡{Õ2�GØ"Ÿf™fŸh™hŸl™l¨4¯6©6Ó2°T·[±[·]±]×5FÑ5FÀtÇvÁvÓ5NÕN�GØ—F‘F—M‘M 'Ô3à!ˆDŽNñ! r   c                ón   € V P                  V4       V P                  4        \        V P                  4      # r   )rš   r�   r	   rž   r©   s   &&r   r   ÚVectorFunction.funå  s*   € Ø�‰�qÔØ×ÑÔô �t—v‘v‹Ðr   c                óò   € V P                  V4       V P                  4        \        V P                  R 4      '       d0   V P                  P	                  V P                  P
                  4      # V P                  # ©ru   )rš   rø   ÚhasattrrÆ   ru   ro   r©   s   &&r   rÀ   ÚVectorFunction.jacì  sQ   € Ø�‰�qÔØ×ÑÔÜ�4—6‘6˜8×$Ò$ð —6‘6—=‘= §¡§¡Ó.Ð.Ø�v‰vˆr   c                ó  € V P                  V4       V P                  V4       V P                  4        \        V P                  R 4      '       d0   V P                  P                  V P                  P                  4      # V P                  # r  )rõ   rš   r˜   r  r=   ru   ro   rØ   s   &&&r   r;   ÚVectorFunction.hessõ  s]   € à�‰�qÔØ�‰�qÔØ×ÑÔÜ�4—6‘6˜8×$Ò$ð —6‘6—=‘= §¡§¡Ó.Ð.Ø�v‰vˆr   )r=   r{   rÆ   rê   rã   r€   râ   rá   rq   rs   rà   rž   ry   rå   ré   rè   rç   rx   rÁ   rÐ   r#   rä   rv   r…   r`   )r+   r,   r-   r.   r/   r   r}   r   r³   r   rÂ   r<   rõ   rš   r�   rø   r˜   r   rÀ   r;   r0   r1   r2   s   @r   rÝ   rÝ     s˜   ø‡ € ñð" '+ÀTØ&(§f¡f W¨b¯f©fÐ$5ÀtØô}ð~ ñ2ó ð2ð ñ3ó ð3ð ñó ðò#ò
'ò&"ò	"ò"ò&ò÷	ð 	r   rÝ   c                   óB   a € ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
ÚLinearVectorFunctioni  zìLinear vector function and its derivatives.

Defines a linear function F = A x, where x is N-D vector and
A is m-by-n matrix. The Jacobian is constant and equals to A. The Hessian
is identically zero and it is returned as a csr matrix.
c                óú  € V'       g!   Vf@   \         P                  ! V4      '       d$   \         P                  ! V4      V n        RV n        Mo\         P                  ! V4      '       d   VP                  4       V n        RV n        M6\        P                  ! \        P                  ! V4      4      V n        RV n        V P                  P                  w  V n
        V n        \        V4      ;V n        p\        P                  ! VP                  V4      ^VR7      pVP                   pVP#                  VP$                  R4      '       d   VP$                  pVP'                  WV4      V n        W`n        V P                  P-                  V P(                  4      V n        RV n        \        P2                  ! V P                  \4        R7      V n        \         P                  ! V P                  V P                  34      V n        R # )NTFr^   ra   )ro   )r?   r@   rA   rÆ   rÁ   rÅ   r   rC   rD   Úshaperç   rx   r   r`   rk   rl   rm   rn   ro   ru   r#   rv   rÕ   rž   ry   ÚzerosÚfloatrÐ   r=   )r   ÚArE   rÁ   r`   r‹   rŒ   s   &&&&   r   r   ÚLinearVectorFunction.__init__  sB  € ß˜oÒ5¼#¿,º,Àq¿/º/Ü—]’] 1Ó%ˆDŒFØ#'ˆDÕ Ü�\Š\˜!�_Š_Ø—Y‘Y“[ˆDŒFØ#(ˆDÕ ô —]’]¤2§:¢:¨a£=Ó1ˆDŒFØ#(ˆDÔ àŸ™Ÿ™‰ˆŒ�”ä& rÓ*Ð*ˆŒ�"Ü�^Š^˜BŸJ™J r›N°°rÔ:ˆØ—‘ˆØ�:‰:�b—h‘h ×0Ò0Ø—X‘XˆFð —‘˜2Ó&ˆŒØŒà—‘—‘˜DŸF™FÓ#ˆŒØˆŒä—’˜$Ÿ&™&¬Ô.ˆŒÜ—’ §¡¨¯©Ð/Ó0ˆŽr   c                ó0  € \         P                  ! WP                  4      '       gp   \        P                  ! V P
                  P                  V4      ^V P
                  R7      pV P
                  P                  W P                  4      V n        RV n	        R# R# r—   )
r   r¨   r#   rk   rl   r`   rD   ru   rv   ry   r™   s   && r   rš   ÚLinearVectorFunction._update_x&  s\   € Ü�~Š~˜a§¡×(Ò(Ü—’ §¡§¡°Ó 2¸¸t¿w¹wÔGˆBØ—W‘W—^‘^ B¯©Ó5ˆDŒFØ"ˆDŽNñ )r   c                ó®   € V P                  V4       V P                  '       g(   V P                  P                  V4      V n        R V n        V P                  # )T)rš   ry   rÆ   rÕ   rž   r©   s   &&r   r   ÚLinearVectorFunction.fun,  s:   € Ø�‰�qÔØ�~�~ˆ~Ø—V‘V—Z‘Z “]ˆDŒFØ!ˆDŒNØ�v‰vˆr   c                ó<   € V P                  V4       V P                  # r   )rš   rÆ   r©   s   &&r   rÀ   ÚLinearVectorFunction.jac3  s   € Ø�‰�qÔØ�v‰vˆr   c                óH   € V P                  V4       W n        V P                  # r   )rš   rÐ   r=   rØ   s   &&&r   r;   ÚLinearVectorFunction.hess7  s   € Ø�‰�qÔØŒØ�v‰vˆr   )r=   rÆ   rž   ry   rç   rx   rÁ   rÐ   r#   rv   r`   N)r+   r,   r-   r.   r/   r   rš   r   rÀ   r;   r0   r1   r2   s   @r   r  r    s(   ø‡ € ñò1ò<#òò÷ð r   r  c                   ó6   a a€ ] tR tRt oRtV 3R ltRtVtV ;t# )ÚIdentityVectorFunctioni=  zîIdentity vector function and its derivatives.

The Jacobian is the identity matrix, returned as a dense array when
`sparse_jacobian=False` and as a csr matrix otherwise. The Hessian is
identically zero and it is returned as a csr matrix.
c                ó¼   <€ \        V4      pV'       g   Vf   \        P                  ! VRR7      pRpM\        P                  ! V4      pRp\
        SV `  WAV4       R # )NÚcsr)ÚformatTF)Úlenr?   Ú	eye_arrayr   ÚeyeÚsuperr   )r   rE   rÁ   rx   r  Ú	__class__s   &&&  €r   r   ÚIdentityVectorFunction.__init__D  sJ   ø€ Ü�‹Gˆß˜oÒ5Ü—’˜a¨Ô.ˆAØ"‰Oä—’�q“	ˆAØ#ˆOÜ‰Ñ˜ Ö0r   © )	r+   r,   r-   r.   r/   r   r0   r1   Ú__classcell__)r#  r3   s   @@r   r  r  =  s   ù‡ € ñ÷1õ 1r   r  )z2-pointz3-pointÚcs) Úcollectionsr   Únumpyr   Úscipy.sparseÚsparser?   Ú_numdiffr   r   Ú_hessian_update_strategyr   Úscipy.sparse.linalgr   Úscipy._lib._array_apir   r	   Ú
scipy._libr
   rk   Úscipy._lib._utilr   r"   r   r5   r[   rµ   r½   rÉ   rÝ   r  r  r%  r   r   Ú<module>r2     s‘   ðÝ "ã Ý ß 6Ý ;Ý .ß :Ý -Ý 3ð *€
÷"ñ "÷JIñ I÷V^ñ ^÷B	*ñ *÷*$ñ *$÷Z20ñ 20÷jqñ q÷h9ñ 9ôx1Ð1ö 1r   