+
    /i<                        R t ^ RIt^RIHt ^RIHtHtHtH	t	 ^RI
HtHtHtHtHt ^RIHt ^RIHt ^RIHtHtHtHtHtHt ^RIHtHtHt ^R	IH t  ^R
I!H"t" ^RI#H$t$H%t% ^RI&H't'H(t(H)t) ^RI*H+t+H,t, ^RI-H.t.H/t/ ^RI0H1t1H2t2 R t3R t4R t5R# )z
This module performs the major calculations of COBYLA.

Translated from Zaikun Zhang's modern-Fortran reference implementation in PRIMA.

Dedicated to late Professor M. J. D. Powell FRS (1936--2015).

Python translation by Nickolai Belakovski.
N)checkbreak_con)REALMAXEPS	DEBUGGINGMIN_MAXFILT)INFO_DEFAULTMAXTR_REACHEDDAMAGING_ROUNDINGSMALL_TR_RADIUSCALLBACK_TERMINATE)evaluate)savehist)isinvmatprodinprodnormprimasum	primapow2)fmsgretmsgrhomsg)redrat)redrho)savefiltselectx)
updatepolefindpole	updatexfc)
setdrop_trgeostep)trstlptrrad)initxfcinitfiltc                   . p. p. p. pRp\         P                  ! \         P                  ! V4      \         P                  ! V4      34      p\         P                  ! \         P                  ! V4      ^,           4      p\        pVe   \         P                  ! V4      M^ p\         P                  ! V4      pVV,
          p\         P                  ! V4      p\        '       Ed   \        V4      ^8:  g   Q hVV8  d   V^ 8  g   Q hV^8  g   Q hVV^,           8  g   Q hW8  d   V^ 8  g   Q h\        \         P                  ! V4      4      '       g   Q h^ Tu;8:  d   T	u;8:  d	   ^8  g   Q h Q h^ Tu;8  d   ^u;8  d	   V8  g   Q h Q h^ V8:  g   Q h^ V8:  g   Q h^ Tu;8:  d	   V8:  g   Q h Q hVe    \         P                  ! V4      VV38X  g   Q h\        \        V4      Tu;8:  d	   V8:  g   Q h Q h\        WW?WEVVWVVVVVV4      w  p p!p"p#p$p%p&p'\         P                  ! \         P                  ! \         P                  ! V^4      V4      4      p(\         P                  ! \         P                  ! V4      \         P                  ! V(4      34      p)\         P                  ! \         P                  ! V(4      4      p*\         P                  ! \         P                  ! V4      \         P                  ! V(4      34      p+\        V!WgV"V%V#V V(V)V*V+4      p,V'\        8w  d   T'p-\!        V*RV, V(RV, Wv4      p.V+RV.3,          pV*V.,          pV)RV.3,          pV(V.,          p/\#        VV-VV&VVV/V4       \        '       d   V&V8:  g   Q h\         P                  ! V4      V8X  d&   \%        \         P&                  ! V4      4      '       d   Q h\         P&                  ! V4      '       g   \         P(                  ! V4      '       d   Q hVVVV/V&VVVVV-3
# Tp0Tp1\         P                  ! V\         P                  ! R\+        V!V%4      4      4      p2Rp3Rp4^ p5\         P                  ! ^\         P                  ! RV,          R4      4      p6^
V,          p7\,        p-\/        V74       EF  p8\1        WEV!V2V"V1V%V0V#V$4
      p2\3        V2V!V"V%V#V$4      w  p!p"p%p#p$p'V'\4        8X  d   T'p- EM\        \7        \9        V#RRV13,          4      ^ R7      ^\9        V14      ,          8*  4      p9\;        V%RV V%V,          ,
          V$4      p:Ve   VP<                  MTVRRV13&   \;        V!VR1RV13,          \         P>                  ! V!VR1V3,          V^34      P<                  ,
          V$4      P<                  VRVR13&   \A        VV!RV3,          ) V1V:4      p;\        V1\C        V;4      4      p<V<R	V0,          8*  p3\E        V;V:4      ) p=V"V,          \         PF                  ! \         PH                  ! ^ V!RV3,          \;        V;V4      ,           4      4      ,
          p>V=V2V>,          ,           p?V?R
\        V2^4      ,          V0,          8  * p@V3'       g	   X@'       d   V1R	,          p1V1V6V0,          8:  d   T0p1EM,V#RV3,          V;,           p\7        \9        VV#RV3,          ,
          4      4      VV&   \7        \9        VPK                  V^4      V#RV3,          PK                  V^4      V#RRV13,          ,           ,
          4      ^ R7      VRV% \         PL                  ! V4      pAVVA,          \9        RV,          4      8:  d   V%XA,          pV!RVA3,          pV"VA,          p/Mr\O        V VVWE4      w  pp\         PF                  ! \         PH                  ! ^ V4      4      p/V&^,          p&\Q        VVVVVV/VVV4	       \S        V/WgVVV,V(V*V+VV)4      w  p,p(p*p+p)\U        VRVV&V1VVV/V4	       V%V,          V2V"V,          ,          ,           VV2V/,          ,           ,
          pB\W        VBV?V4      p4\Y        V1V<WWV44      p1V1V6V0,          8:  d   T0p1XB^ 8  pC\[        VCV;V1V0V#V$4      p5\]        V5VV2V/V;VV!V"V%V#V$4      w  p#p$p%p!p"p'V'\4        8X  d   T'p- EM\_        VV&V/VVV
V4      p'V'\        8w  d   T'p- EMT3;'       g    X@;'       g    V4^ 8*  ;'       g    V5RJ pDTD;'       d    V9'       * pEXD;'       d    T9;'       d    \G        V1V<4      V08*  pFXE'       EdO   \        \7        \9        V#RRV13,          4      ^ R7      ^\9        V14      ,          8*  4      '       Eg   \         P`                  ! \7        \9        V#RRV13,          4      ^ R7      ^ R7      pGV1^,          pH\c        VGWEV!V2V"VHV%V$4	      p;V#RV3,          V;,           p\7        \9        VV#RV3,          ,
          4      4      VV&   \7        \9        VPK                  V^4      V#RV3,          PK                  V^4      V#RRV13,          ,           ,
          4      ^ R7      VRV% \         PL                  ! V4      pAVVA,          \9        RV,          4      8:  d   V%XA,          pV!RVA3,          pV"VA,          p/Mr\O        V VVWE4      w  pp\         PF                  ! \         PH                  ! ^ V4      4      p/V&^,          p&\Q        VVVVVV/VVV4	       \S        V/WgVVV,V(V*V+VV)4      w  p,p(p*p+p)\U        VRVV&V1VVV/V4	       \]        XGVV2V/V;VV!V"V%V#V$4      w  p#p$p%p!p"p'V'\4        8X  d   T'p- EM>\_        VV&V/VVV
V4      p'V'\        8w  d   T'p- EMXF'       d   V0V8:  d
   \d        p- EM\G        RV0,          \g        V0V4      4      p1\g        V0V4      p0\         P                  ! V\         P                  ! V2\+        V!V%4      4      4      p2\i        VVV&V%V,          V0V#RV3,          V"V,          V!RV3,          V24	       \3        V2V!V"V%V#V$4      w  p!p"p%p#p$p'V'\4        8X  d   T'p- MMV'       g   EK  V! V#RV3,          V%V,          V&V8V"V,          V!RV3,          4      pIVI'       g   EK  \j        p- M	  V#RV3,          X;,           pV-\d        8X  d   V3'       d   \C        VV#RV3,          ,
          4      RV,          8  d   V&V8  d   \O        V VVWE4      w  pp\         PF                  ! \         PH                  ! ^ V4      4      p/V&^,          p&\Q        VVVVVV/VVV4	       \S        V/WgVVV,V(V*V+VV)4      w  p,p(p*p+p)\U        VRVV&V0VVV/V4	       \!        V*RV, V(RV, \G        V2V4      V4      p.V+RV.3,          pV*V.,          pV)RV.3,          pV(V.,          p/\#        VV-VV&VVV/V4       VVVV/V&VVVVV-3
# )z=
This subroutine performs the actual computations of COBYLA.
COBYLANNNNg     @@Fg      ?g      ?axisg?gư>g-C6?zTrust regionGeometry      ?gMbP?)6npzerossizer   r   absallisfiniteshapeminr   r"   minimummaximumr#   r   r   r   anyisnanisposinffcratior   rangegetcpenr   r	   r   r   r   Ttiler    r   r   maxappendreshapeargminr   r   r   r   r   r!   r   r   r   argmaxr   r
   r   r   r   )Jcalcfciprintmaxfiltmaxfunamatbvecctolcweighteta1eta2ftargetgamma1gamma2rhobegrhoendconstrfxmaxhistcallbackxhistfhistchistconhistsolverAdistsqcpenminm_lconnum_constraintsm_nlconnum_vars	evaluatedconmatcvalsimsimifvalnfsubinfocfiltconfiltffiltxfiltnfiltinfokoptcstrvrhodeltacpenshortdratiojdrop_trgamma3maxtrtradequate_geogddnormprerefprerecpreremtrfailjactrem	ximproved
bad_trstepimprove_geo
reduce_rho	jdrop_geodelbar	terminatesJ   &&&&&&&&&&&&&&&&&&&&                                                      ^/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/_lib/pyprima/cobyla/cobylb.pycobylbr      s    EEEG F
"''!*bggfo./AXXbggaj1n%F G #.RWWT]AFggfoO&GwwqzH y6{a&(Vq[881}}A%%%FQJ..2;;q>""""D$D$1$$$$$6&A&&&&&&DyyG||G%v%%%%%|rxx~&(1CCCC;'7<f<<<<< =DFd$7AUE7G=-9IvtS$b' HHRZZ

7A 6?@Ehh89GHHRWWU^$EHHbggaj"''%.12EVTD$YwE#E , uVe}eFUmWC!T'N$KD!dvtVRAuf=9<<771:)#bhhqk2B2BBBr{{1~~66 !VUBueWdJJ CE::grzz%1FGHDFEH ZZ2::dVmS9:F KED El t64udCdS 2<D&$PT<?2G.dCw ''D 8Ic!YhY,.?$@qIQQZ[`QaMaab T)8_tH~5="&"2!WfW*((:!;''&():";h]KMM"NPTVVWVW 	
!VW* 1vak**E15E47# 39$ A,h"&&1fQ[6IGTUWXM6Y)Z"[[
 $-'vD!4s:;V SLE$ AxK 1$A'	!c!X+6F2F(GHF8 (199Xq3IQ[!))(A6Q		\9JJ4L *MST!VF9H		&!AayIdVm44G1Q %VQD	6ryyF34a!UAueUFGT6>udUV?@%PU?Dfg7W3ueUG UAq%P 8ntd8n'<<TE\AQRF 6640E< %FEJEs
" 
I
 ")QsCFH 6?xQUW\^_abdjlprvx{  ~B  6C2CtVT7++ %VRa!LG,& GGvGG!GGx47G
 55%5MMLMMS5F#5M
l ;s8Ic!YhY,6G,Hq#QUVYbchYiUi#ijj: 		(9SIXI5F+Ga"PWXYI 1WF	4vtT64QUVA AxK 1$A'	!c!X+6F2F(GHF8 (199Xq3IQ[!))(A6Q		\9JJ4L *MST!VF9H		&!AayIdVm44G1Q %VQD	6ryyF34a!UAueUFGT6>udUV?@%PU?Dfg7W3ueUG
 VR1eVL5>y&RVX]_`bcekmqswy|  C  6D2CtVT7++ %VRa!LG,&
 f}&c	6#v#67Ef%C ::grzz$8M'NOD662tH~sC8<LdS[n^defhpep^qswx5?fdTXZ]_c5d2FD$T7++ 8 Q[!14>2r4PX>[abcembm[noIy)y
 B 	AxK1ASH%%&&8K VQ<	6ryyF+,
a!UAueUFGL.6udQPQSXZ_afhmouw~.+ueUGV^VRaE6J 5%=%-T71CTJDagAdAQWF$KE 64Q5&9aE5%$FF    c
                d   VP                  4       pVP                  4       pVP                  4       pVP                  4       pV	P                  4       p	\        P                  ! \        P                  ! V^ 4      \        P                  ! V^ 4      34      p
^pVe   \        P                  ! V4      M^ p\        P                  ! V^ 4      p\        P                  ! V^ 4      p\        '       Ed   V^ 8  g   Q hV^8  g   Q hV^ 8  g   Q h\        P                  ! V^ 4      V8X  d$   \        P                  ! V^4      V^,           8X  g   Q h\        P
                  ! V4      \        P                  ! V4      ,          P                  4       '       d   Q h\        P                  ! V4      V^,           8X  dK   \        V^ \        P
                  ! V4      ,          \        P                  ! V4      ,          8  4      '       d   Q h\        P                  ! V4      V^,           8X  dA   \        \        P
                  ! V4      \        P                  ! V4      ,          4      '       d   Q h\        P                  ! V^ 4      V8X  d$   \        P                  ! V^4      V^,           8X  g   Q h\        P                  ! V4      P                  4       '       g   Q h\        \        P                  ! \        VRRV13,          4      ^ R7      ^ 8  4      '       g   Q h\        P                  ! V	^ 4      V8X  d   \        P                  ! V	^4      V8X  g   Q h\        P                  ! V	4      P                  4       '       g   Q h\        VRRV13,          W4      '       g   Q hWW8  d   V^ 8  g   Q h\        p\        V^,           4       EFu  p\!        W2WFVV	4      w  r$rhrV\"        8X  d    EMV\%        VRV Wn,          ,
          V	4      pV e   V P&                  MT V
RRV13&   \%        W,R1RV13,          \        P(                  ! W,R1V3,          V^34      P&                  ,
          V	4      P&                  V
RVR13&   \+        WRV3,          ) VV4      p\-        VV4      ) pWN,          \        P                  ! \        P.                  ! ^ VRV3,          \%        VV
4      ,           4      4      ,
          pV^ 8  d   V^ 8  g    M@\        V\1        RV,          V,          \2        4      4      p\5        W4V4      V8X  g   EKv   M	  \        '       dq   W38  d   V^ 8  g   Q hXVX,          ,           ^ 8  gM   V\"        8X  gB   V^ 8  d;   \        P6                  ! VV4      ^ 8  d   \        P                  ! V4      '       d   Q hV# )z
This function gets the penalty parameter CPEN so that PREREM = PREREF + CPEN * PREREC > 0.
See the discussions around equation (9) of the COBYLA paper.
Nr&   r'   )copyr,   r-   r.   r   r7   isneginfr6   r8   r1   r0   r>   r/   r   r   r:   r   r	   r   r<   r=   r    r   r?   r3   r   r   r5   )rG   rH   rd   ru   re   rt   rh   rs   rf   rg   r\   itolr_   r`   rb   rp   iterr}   r~   r   r   s   &&&&&&&&&&           r   r;   r;   2  s    [[]F99;D99;D
((*C99;D 	"''#q/27761#567AD #.RWWT]AFggfa(OwwsAH y!###1}}axxwwvq!_49KxZ[|9[[[HHV$r{{6'::??AAAAwwt}1,D1rxx~-D0AAABB	C Cwwt}1,S$"++VZJ[9[5\5\\\wwsA(*rwwsA(Q,/NNN{{3##%%%%266#c!YhY,/0q9A=>>>>wwtQ8+a0@H0LLL{{4 $$&&&&SIXI&3333|a'' D" hl#.8tSV9=/?+d $$ D(Odn4d;"&"2!WfW*((:!;''&():";h]KMM"NPTVVWVW 	
!VW* 1ak**E15 A,"&&1fQ[6IGTUWXM6Y)Z"[[ 
vz 4R&[617;<D%1G $T y|q((v%)T5F-F1FF!;a!?TZH[H[	\ \ Kr   c                v   \         '       dP   \        P                  ! V4      ^8  g   Q h\        P                  ! V ^4      \        P                  ! V4      8X  g   Q h\        P                  ! V ) ^R7      p\        P                  ! V ) ^R7      p\        V4      p\	        V4      p\        VRV,          8  4      '       dd   WE8  d^   \        P                  ! \        P                  ! V^ 4      V,
          VRV,          8  \        P                  R7      pWT,
          V,          pM^ p\         '       d
   V^ 8  g   Q hV# )z
This function calculates the ratio between the "typical change" of F and that of CONSTR.
See equations (12)-(13) in Section 3 of the COBYLA paper for the definition of the ratio.
r'   r*   )whereinitial)r   r,   r.   r3   r>   r6   r5   inf)rd   rh   cmincmaxfminfmaxdenomrs   &&      r   r9   r9     s     ywwt}!!!wwvq!RWWT]222 666'"D666'"Dt9Dt9D
4#*$+rzz$*T1d
9JTVTZTZ[ [E! yAvvHr   )6__doc__numpyr,   common.checkbreakr   common.constsr   r   r   r   common.infosr   r   r	   r
   r   common.evaluater   common.historyr   common.linalgr   r   r   r   r   r   common.messager   r   r   common.ratior   common.redrhor   common.selectxr   r   updater   r   r   geometryr   r   trustregionr    r!   
initializer"   r#   r   r;   r9    r   r   <module>r      s`     . @ @8 8 & % M M 1 1 ! " . 3 3 ) & )QGjqh$r   