+
    Ai0                         ^ RI t^ RIHtHt ]! RRRR7      R 4       t]! RRRRR7      R	 4       t ! R
 R]4      tR t	R# )    N)njitprangezNi8(i8[:], i8[:], i8[:], i8[:], i8[:], f4[:, :, :], f4[:], f4[:, :], i8[:], i8)T)cachenogilc
                    VP                   ^,          p
\        P                  ! R\        P                  4      p^ p^ p^V	,          p^ W&   V^,          pVP                   ^ ,          W&   V^,          pWV&   V^,          pV^,          pV^ 8  Ed   V^,          pW,          pV^,          pW,          pV^,          pW,          pW_^ 3,          pW_^3,          p\	        V
4       F  pVVV3,          VV&   VVV3,          VV&   K!  	  \	        V^,           V4       FS  p\	        V
4       FA  p\        VV,          VVV3,          4      VV&   \        VV,          VVV3,          4      VV&   KC  	  KU  	  VV,
          V8:  d   VW&   VW&   RW/&   RW?&   RWO&   RWo&   EK  VV,
          p\        P                  ! V4      pVV,          RVV,          ,          ,           pTpV^,
          pVV8  d   VV8  d   VVV3,          V8  d   V^,          pK"  VV8  d   VVV3,          V8  d   V^,          pK"  VV8  g   KT  \	        V
4       F%  pVVV3,          pVVV3,          VVV3&   VVVV3&   K'  	  VV,          pVV,          VV&   VVV&   K  VVV3,          V8  d
   V^,          pTp\        VV	,           \        VV	,
          V4      4      pTpV^,          pTpV^,          pVW&   V^,          pVW&   V^,          pVW&   V^,          pVW&   V^,          pVW&   V^,          pVW&   V^,          pVW&   VW&   VW/&   VW?&   VWO&   VWo&   EK  V# )             g      ?)shapenpemptyint64rangeminmaxargmax)i0_indsi1_inds	less_inds	more_inds
split_dimsboundssplit_valuespointsindicesmin_leaf_size	dimensionstack
stack_sizen_nodesmax_leaf_sizei_nodei1i0lohidilengths	split_dimsplit_valuejtemptemp_i_nodei_splitlessmores   &&&&&&&&&&                     S/var/www/html/photoedit/myenv/lib/python3.14/site-packages/pymatting/util/kdtree.py
_make_treer4      s    QIHHT288$EJG%M E!OJQE!OJ*qLG!OJ q.a
"a
a
AIAIy!A2q5MBqE2q5MBqE "
 rAvr"A9%BqE6!Q$<01BqE6!Q$<01 & # 7m# GO GO "I "I!#J#&L  2gG		'*IY-#	0B*BBK AQAa%!eq)| 4{ BFA!eq)| 4 CFA q5"9-%ad|'-ad|q!t'+q!t .
 #*!*K!(GAJ!,GAJal#k1QG "},c"}2Dg.NOGDqLGDqLG !#E!OJ 'E!OJ $E!OJ !(E!OJ "E!OJ $E!OJ GO GO $I $I!*J#.L N    zgvoid(i8[:], i8[:], i8[:], i8[:], i8[:], f4[:, :, :], f4[:], f4[:, :], f4[:, :], i8[:, :], f4[:, :], i8))r   r   parallelc                 <   VP                   ^,          p\        VP                   ^ ,          4       EFg  pW,          pW,          pW,          p\        P                  ! R\        P                  4      p^ p^ V^ &   ^pV^ 8  Ed   V^,          pVV,          pVV8  dv   Rp\        V4       FM  pVV,          pV\        VV^ V3,          \        VV^V3,          V4      4      ,
          pVVV,          ,          pKO  	  VVV^,
          ,          8  d   K  VV,          R8X  Ed   \        V V,          VV,          4       F  pRp\        V4       F,  pVV,          VVV3,          ,
          pVVV,          ,          pK.  	  Tp\        V^,
          RR4       F  pVV,          V8  g   K  TpK  	  VV8  g   Kx  \        \        VV^,
          4      VR4       F)  pVV^,
          ,          VV&   VV^,
          ,          VV&   K+  	  VVV&   VVV&   \        V^,           V4      pK  	  EK  VV,          pVV,          pVV,          p VV ,          VV,          8  d    VVV&   V^,          pVVV&   V^,          pEK  VVV&   V^,          pVVV&   V^,          pEK  V^ ,          pEKj  	  R# )r   r	   r
   Nr   )r   r   r   r   r   r   r   r   )!r   r   r   r   r   r   r   r   query_pointsout_indicesout_distanceskr   i_queryquery_point	distancesr   r   n_neighborsr    r#   distr(   pdpr)   distancedd
insert_posr-   r1   r2   r+   s!   &&&&&&&&&&&&                     r3   	_find_knnrF      s    QI ,,,Q/0"+!*	& rxx(a
 1n!OJ:&F ay)A#AAS1!5s6&!Q,;OQR7STTBBGOD * )K!O44 &!R'wv@A"H"9-(^fQTl: BG+ .
 "-J";?B;$Q<(2)*J <
 "A~!&s;A'>
B!OA)0QGAJ+4QU+;IaL "P
 /0
+08	*-&)+/1&=/ A4 !( (&v.	 y)L,@@(,E*%!OJ(,E*%!OJ )-E*%!OJ(,E*%!OJ 	a
_ 1r5   c                   4   a  ] tR t^t o RtRR ltR tRtV tR# )KDTreezKDTree implementationc                p   VP                   \        P                  8X  g   Q hVP                  w  r4^W2,           ^,
          V,          ,          p\        P                  ! V\        P
                  4      V n        \        P                  ! V\        P
                  4      V n        \        P                  ! V\        P
                  4      V n        \        P                  ! V\        P
                  4      V n	        \        P                  ! V\        P
                  4      V n
        \        P                  ! V^V3\        P                  4      V n        \        P                  ! V\        P                  4      V n        VP                  4       V n        \        P                  ! V4      P!                  \        P
                  4      V n        \%        V P                  V P                  V P                  V P                  V P                  V P                  V P                  V P                  V P"                  V4
      V n        R# )a3  Constructs a KDTree for given data points. The implementation currently only supports data type `np.float32`.

Parameters
----------
data_points: numpy.ndarray (of type `np.float32`)
    Dataset with shape :math:`n \times d`, where :math:`n` is the number of data points in the data set and :math:`d` is the dimension of each data point
min_leaf_size: int
    Minimum number of nodes in a leaf, defaults to 8

Example
-------
>>> from pymatting import *
>>> import numpy as np
>>> data_set = np.random.randn(100, 2)
>>> tree = KDTree(data_set.astype(np.float32))
N)dtyper   float32r   r   r   r   r   r   r   r   r   r   copyshuffled_data_pointsarangeastypeshuffled_indicesr4   r!   )selfdata_pointsr   n_datar   	max_nodess   &&&   r3   __init__KDTree.__init__   sh   "   BJJ...'--&014FG	xx	2884xx	2884)RXX6)RXX6((9bhh7hh	1i8"**EHHY

;$/$4$4$6! "		& 1 8 8 B!LLLLNNNNOOKK%%!!
r5   c                   VP                   \        P                  8X  g   Q hV P                  P                  ^ ,          V8  d.   \        RV P                  P                  ^ ,           RV R24      hVP                  ^ ,          p\        P                  ! W23\        P                  4      p\        P                  ! W23\        P                  4      p\        V P                  V P                  V P                  V P                  V P                  V P                  V P                  V P                  VVVV4       V P                   V,          p\        P"                  ! V4      pWe3# )a  Query the tree

Parameters
----------
query_points: numpy.ndarray (of type `np.float32`)
    Data points for which the next neighbours should be calculated
k: int
    Number of neighbors to find

Returns
-------
distances: numpy.ndarray
    Distances to the neighbors
indices: numpy.ndarray
    Indices of the k nearest neighbors in original data array

Example
-------
>>> from pymatting import *
>>> import numpy as np
>>> data_set = np.random.randn(100, 2)
>>> tree = KDTree(data_set.astype(np.float32))
>>> tree.query(np.array([[0.5,0.5]], dtype=np.float32), k=3)
(array([[0.14234178, 0.15879704, 0.26760164]], dtype=float32), array([[29, 21, 20]]))
zNumber of data points (z4) is less than the number of neighbors requested (k=z<). Please provide a larger dataset or reduce the value of k.)rJ   r   rK   rM   r   
ValueErrorr   r   rF   r   r   r   r   r   r   r   rP   sqrt)rQ   r8   r;   n_querysquared_distancesr   r>   s   &&&    r3   queryKDTree.query  s6   4 !!RZZ///$$**1-1)$*C*C*I*I!*L)M  NB  CD  BE EM M 
 $$Q'HHg\2::>((G<2LLLLNNNNOOKK%%	
 ''0GG-.	!!r5   )
r   r   r   r   r   r!   rM   rP   r   r   N)   )	__name__
__module____qualname____firstlineno____doc__rU   r\   __static_attributes____classdictcell__)__classdict__s   @r3   rH   rH      s     ,
\9" 9"r5   rH   c                :    \        V 4      pVP                  W4      # )a  Find k nearest neighbors in a data set. The implementation currently only supports data type `np.float32`.

Parameters
----------
data_points: numpy.ndarray (of type `np.float32`)
    Dataset with shape :math:`n \times d`, where :math:`n` is the number of data points in the data set and :math:`d` is the dimension of each data point
query_points: numpy.ndarray (of type `np.float32`)
    Data points for which the next neighbours should be calculated
k: int
    Number of neighbors to find

Returns
-------
distances: numpy.ndarray
    Distances to the neighbors
indices: numpy.ndarray
    Indices of the k nearest neighbors in original data array

Example
-------
>>> from pymatting import *
>>> import numpy as np
>>> data_set = np.random.randn(100, 2)
>>> knn(data_set.astype(np.float32), np.array([[0.5,0.5]], dtype=np.float32), k=2)
(array([[0.16233477, 0.25393516]], dtype=float32), array([[25, 17]]))
)rH   r\   )rR   r8   r;   trees   &&& r3   knnri   Y  s    6 +D::l&&r5   )
numpyr   numbar   r   r4   rF   objectrH   ri    r5   r3   <module>rn      su     
 V^bjno~ p~B ow{  DH  SW  X` X`Dj"V j"Z'r5   