+
    A•üi  ã                   ó   € ^ RI tRR ltR# )é    Nc	           	     óÜ  a€ Sf   R p	M\        S4      '       d   Sp	MV3R lp	Vf   \        P                  ! V4      MVP                  4       p
\        P                  P                  V4      p\        V 4      '       d   W! V
4      ,
          pMWP                  V
4      ,
          p\        P                  P                  V4      pWÓ8  g   WÔV,          8  d   V
# V	! V4      pVP                  4       p\        P                  ! WÎ4      p\        V4       EFF  pVP                  4       p\        V 4      '       d
   V ! V4      pMV P                  V4      pV\        P                  ! VV4      ,          pV
VV,          ,          p
VVV,          ,          p\        P                  P                  V4      pVe   V! W
WWÍ4       WÓ8  g   WÔV,          8  d   V
u # V	! V4      pV'       d=   \        P                  ! VV,
          V4      V,          p\        P                  ! WÎ4      pM(RV,          p\        P                  ! WÎ4      pVV,          pVV,          pWþ,          pEKI  	  \        RV,          4      h)a$  Solves a system of linear equations :math:`Ax=b` using conjugate gradient descent :cite:`hestenes1952methods`

Parameters
----------
A: scipy.sparse.csr_matrix
   Square matrix
b: numpy.ndarray
   Vector describing the right-hand side of the system
x0: numpy.ndarray
   Initialization, if `None` then :code:`x=np.zeros_like(b)`
atol: float
   Absolute tolerance. The loop terminates if the :math:`||r||` is smaller than `atol`, where :math:`r` denotes the residual of the current iterate.
rtol: float
   Relative tolerance. The loop terminates if :math:`{||r||}/{||b||}` is smaller than `rtol`, where :math:`r` denotes the residual of the current iterate.
callback: function
   Function :code:`callback(A, x, b, norm_b, r, norm_r)` called after each iteration, defaults to `None`
M: function or scipy.sparse.csr_matrix
   Function that applies the preconditioner to a vector. Alternatively, `M` can be a matrix describing the precondioner.
reorthogonalize: boolean
    Whether to apply reorthogonalization of the residuals after each update, defaults to `False`


Returns
-------
x: numpy.ndarray
    Solution of the system

Example
-------
>>> from pymatting import *
>>> import numpy as np
>>> A = np.array([[3.0, 1.0], [1.0, 2.0]])
>>> M = jacobi(A)
>>> b = np.array([4.0, 3.0])
>>> cg(A, b, M=M)
array([1., 1.])
c                 ó   € V # ©N© )Úxs   &ÚQ/var/www/html/photoedit/myenv/lib/python3.14/site-packages/pymatting/solver/cg.pyÚpreconditionÚcg.<locals>.precondition6   s   € ØˆHó    c                 ó&   <€ SP                  V 4      # r   )Údot)r   ÚMs   &€r   r	   r
   =   s   ø€ Ø—5‘5˜“8ˆOr   g      ð?z@Conjugate gradient descent did not converge within %d iterations)
ÚcallableÚnpÚ
zeros_likeÚcopyÚlinalgÚnormr   ÚinnerÚrangeÚ
ValueError)ÚAÚbÚx0ÚatolÚrtolÚmaxiterÚcallbackr   Úreorthogonalizer	   r   Únorm_bÚrÚnorm_rÚzÚpÚrzÚ	iterationÚr_oldÚApÚalphaÚbetas   &&&&&&&f&             r   Úcgr+      sÔ  ø€ ð` 	‚yó	ô 
!ŠØ‰õ	ð šJŒŠaÔ¨B¯G©G«I€AäY‰Y^‰^˜AÓ€Fä‡{‚{Ø!“H‰à—‘a“LˆäY‰Y^‰^˜AÓ€Fà„}˜¨¥Ô.ØˆáQ‹€AØ	‰‹€AÜ	Š!‹€Bä˜7—^ˆ	Ø—‘“ˆäA;Š;Ù1“‰Bà—‘q“ˆBà”R—X’X˜a “_Õ$ˆØ	ˆUQYˆØ	ˆURZˆä—‘—‘ Ó"ˆàÒÙQ˜1 aÔ0àŒ=˜F¨F¥]Ô2ØŠHá˜‹OˆçÜ—8’8˜A I qÓ)¨BÕ.ˆDÜ—’˜!“‰Bà˜•8ˆDÜ—’˜!“ˆBØBJˆDà	ˆT	ˆØ	‹ñ? $ôB ØJÈWÕTóð r   )Ng        gH¯¼šò×z>i'  NNF)Únumpyr   r+   r   r   r   Ú<module>r-      s   ðÛ öqr   