+
    Ai                     :    ^ RI t^ RIt^ RItR tR tR tRR ltR# )    Nc                 d   V w  rW,          pV^,          pV^,          pWT,          p\         P                  ! . RO4      ^,          p\         P                  ! \         P                  ! \         P                  ! V4      V4      ^	4      p\         P                  ! \         P                  ! \         P                  ! V4      V4      ^	4      p	V^,          \         P                  ! . ROV4      ,           p
V	^,          \         P                  ! . ROV4      ,           p^ V
8*  W8  ,          ^ V8*  ,          W8*  ,          pWV,          ,           V,          pWV,          ,           V,          p\         P                  ! Wv4      V,          p\
        P                  P                  WV33Wc34      pVP                  pVV3# )   )	   r   r   r      r   r   r   r   )	r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   )	npfloat64repeattilearangescipysparse
csr_matrixT)shapehwnh2w2n2weightsx2y2xymaski_indsj_indsvalues
downsampleupsamples   &                 ]/var/www/html/photoedit/myenv/lib/python3.14/site-packages/pymatting/preconditioner/vcycle.pymake_Pr$      s>   DA	A	
aB	
aB	Bjj45:G	277299R="-q	1B	299RYYr]B/	3B
Q7<<A
Q7<<AFqua(AF3D7lD!Fa%iFWWW!$'F((&62B)CbWMJ||HZ    c                     Vf7   V^ 8  d   WR,          V,          pV^,          pM\         P                  ! V4      p\        V4       F.  pW5W P                  V4      ,
          ,          V,          ,           pK0  	  V# N)r   
zeros_likerangedot)AA_diagbr   num_iteromega_s   &&&&&& r#   jacobi_stepr1       sb    ya<	F"AMHa A8_UU1X&//  Hr%   c           
         Vw  rW,          p
W8:  d*   \         P                  P                  P                  W4      # W#9  dE   \	        V4      w  rVP                  V 4      P                  V4      pV P                  4       pWW3W2&   MW2,          w  rr\        WVR WF4      pWP                  V4      ,
          pVP                  V4      p\        VVV^,          V	^,          3VVVVV4      pWP                  V4      ,          p\        WWWV4      pV# r'   )	r   r   linalgspsolver$   r*   diagonalr1   _vcycle_step)r+   r-   r   cachenum_pre_iternum_post_iterr/   direct_solve_sizer   r   r   r"   r!   coarse_Ar,   r   residualcoarse_residualcoarse_xs   &&&&&&&&           r#   r6   r6   .   s    DA	A||""**100%e}>>!$((2 h?16.h 	Aq$<A 558|H !nnX.O 	
aa	H h	A 	Aq]:AHr%   c                8   a aaaaaa Sf   / oV VVVVVV3R lpV# )av  
Implements the V-Cycle preconditioner.
The V-Cycle solver was recommended by :cite:`lee2014scalable` to solve the alpha matting problem.

Parameters
----------
A: numpy.ndarray
    Input matrix
shape: tuple of ints
    Describing the height and width of the image
num_pre_iter: int
    Number of Jacobi iterations before each V-Cycle, defaults to 1
num_post_iter: int
    Number of Jacobi iterations after each V-Cycle, defaults to 1
omega: float
    Weight parameter for the Jacobi method. If method fails to converge, try different values.

Returns
-------
precondition: function
    Function which applies the V-Cycle preconditioner to a vector

Example
-------
>>> from pymatting import *
>>> import numpy as np
>>> from scipy.sparse import csc_matrix
>>> A = np.array([[2, 3], [3, 5]])
>>> preconditioner = vcycle(A, (2, 2))
>>> preconditioner(np.array([1, 2]))
array([-1.,  1.])
c           
      (   < \        SV SSSSSS4      # r'   )r6   )rr+   r7   r:   r9   r8   r/   r   s   &r#   preconditionvcycle.<locals>.precondition   s"    q%mUDU
 	
r%    )r+   r   r8   r9   r/   r:   r7   rB   s   fffffff r#   vcyclerE   g   s"    T }
 

 r%   )r   r   g?@   N)	numpyr   scipy.sparser   scipy.sparse.linalgr$   r1   r6   rE   rD   r%   r#   <module>rJ      s#       46r2r%   