+
    åûj÷z  ã                  óö   € R t ^ RIHt ^ RIt^ RIHtHt ^ RIHt ^ RI	H
t
Ht . ROtR R ltR R	 ltR
 R ltR R ltR R ltR R ltR R ltR R ltRR R lltR R R lltR R R lltR!R R llt]tR# )"aì  Homogeneous 4x4 transforms and point transforms, with point-line distances and last-axis vector products.

A transform ``trans_ab`` maps points in frame ``b`` to frame ``a``, :math:`p_a = T_a^{b} p_b`, so
``compose_transformations(trans_01, trans_12)`` is ``trans_02`` and ``transform_points(trans_01, points_1)`` returns
``points_0``. The ``4 x 4`` functions take ``(4, 4)`` or ``(N, 4, 4)`` inputs, two arguments with the same number of
dimensions, and a batch of one broadcasts against a batch of ``N``. The vector functions reduce the last dimension and
broadcast the leading ones.

Which function to use:

- Chain two transforms: :func:`compose_transformations`. Invert a rigid one: :func:`inverse_transformation`. The
  transform between two poses given in one frame: :func:`relative_transformation`.
- Apply a ``(D + 1, D + 1)`` homogeneous matrix, rigid, affine or projective, to ``(..., N, D)`` points:
  :func:`transform_points`.
- Distances: between paired points, :func:`euclidean_distance`; from 2D points to lines :math:`ax + by + c = 0`,
  :func:`point_line_distance`.
- Products over the last dimension: :func:`batched_dot_product`, and the squared norm :func:`batched_squared_norm`,
  also exported as :func:`squared_norm`, the same function.
)ÚannotationsN)ÚKORNIA_CHECK_IS_TENSORÚKORNIA_CHECK_SHAPE)Ú_autocast_disabled)Úconvert_points_from_homogeneousÚconvert_points_to_homogeneousc               ó$   € V ^8„  d   QhRRRRRR/# )é   Útrans_01útorch.TensorÚtrans_12Úreturn© )Úformats   "ÚRC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\linalg.pyÚ__annotate__r   ;   s&   € ÷ Lñ L lð L¸lð LÈ|ñ Ló    c                ó¤  € \        V 4       \        V4       V P                  4       R9   d   V P                  R	R R
8X  g   \        RV P                   24      hVP                  4       R9   d   VP                  R	R R
8X  g   \        RVP                   24      hV P                  4       VP                  4       8w  d.   \        RV P                  4        RVP                  4        24      h \        P
                  ! V P                  RR	 VP                  RR	 4      pT R,          pTR,          pT R,          pTR,          p\        P                  ! YE4      p\        P                  ! YG4      T,           p	T P                  TR
,           4      p
YŠR&   YšR&   RT
R&   T
#   \         d,   p\        RT P                   RTP                   24      ThRp?ii ; i)a	  Compose two 4x4 homogeneous transforms, trans_01 @ trans_12, into trans_02.

``trans_02 = compose_transformations(trans_01, trans_12)`` takes two homogeneous transforms ``(N, 4, 4)`` or
``(4, 4)`` and returns their product ``trans_01 @ trans_12``, the transform from frame 2 to frame 0, with the
broadcast shape. Both inputs need the same number of dimensions: a ``(4, 4)`` with an ``(N, 4, 4)`` raises
``ValueError``, while a batch of one broadcasts against a batch of ``N``. For poses that name their frames and check
them when composing, use :class:`~kornia.geometry.pose.NamedPose`; to apply the result to points,
:func:`transform_points`.

.. math::
    T_0^{2} = \begin{bmatrix} R_0^{1} R_1^{2} & R_0^{1} t_1^{2} + t_0^{1} \\
    \mathbf{0} & 1 \end{bmatrix}

Convention:
    - The result is the matrix product ``trans_01 @ trans_12``, with the frame naming of
      :func:`relative_transformation`. Only the top three rows of each input are read and the last row of the
      result is always :math:`[0, 0, 0, 1]`: any affine pair composes exactly, and a projective input is used as
      if its last row were :math:`[0, 0, 0, 1]`.

Args:
    trans_01: tensor with the homogeneous transformation from
      a reference frame 1 respect to a frame 0. The tensor must have a
      shape of ``(N, 4, 4)`` or ``(4, 4)``.
    trans_12: tensor with the homogeneous transformation from
      a reference frame 2 respect to a frame 1. The tensor must have a
      shape of ``(N, 4, 4)`` or ``(4, 4)``. A batch of one broadcasts against a batch of
      :math:`N` in either argument.

Returns:
    the transformation between the two frames with shape ``(N, 4, 4)`` or ``(4, 4)``.

See Also:
    - :func:`inverse_transformation`: the inverse of a rigid transform, to compose with.
    - :func:`relative_transformation`: ``inverse_transformation(trans_01) @ trans_02`` in one call.
    - :func:`transform_points`: applies a composed transform to points.
    - :class:`~kornia.geometry.pose.NamedPose`: a pose that names its two frames and checks them when composing.
    - :class:`~kornia.geometry.liegroup.Se3`: a rigid pose as a Lie group element, composed with ``*``.

Example::
    >>> trans_01 = torch.eye(4)  # 4x4
    >>> trans_12 = torch.eye(4)  # 4x4
    >>> trans_02 = compose_transformations(trans_01, trans_12)  # 4x4

Nz8Input trans_01 must be a of the shape Nx4x4 or 4x4. Got z8Input trans_12 must be a of the shape Nx4x4 or 4x4. Got ú%Input number of dims must match. Got ú and úIncompatible batch shapes: ç      ð?©r	   é   éþÿÿÿ©é   r   ©.ºNr   Nr   ).r   :r   NN©.r   r   )	r   ÚdimÚshapeÚ
ValueErrorÚtorchÚbroadcast_shapesÚRuntimeErrorÚmatmulÚ	new_zeros)r
   r   Úbatch_shapeÚerrÚrmat_01Úrmat_12Útvec_01Útvec_12Úrmat_02Útvec_02Útrans_02s   &&         r   Úcompose_transformationsr1   ;   s¶  € ôZ ˜8Ô$Ü˜8Ô$à�\‰\‹^˜vÔ%¨H¯N©N¸2¸3Ð,?À6Ô,IÜÐSÐT\×TbÑTbÐScÐdÓeÐeà�\‰\‹^˜vÔ%¨H¯N©N¸2¸3Ð,?À6Ô,IÜÐSÐT\×TbÑTbÐScÐdÓeÐeà‡|�|ƒ~˜Ÿ™›Ô'ÜÐ@ÀÇÁÃÐ@PÐPUÐV^×VbÑVbÓVdÐUeÐfÓgÐgðgÜ×,Ò,¨X¯^©^¸C¸RÐ-@À(Ç.Á.ÐQTÐRTÐBUÓVˆð
 �{Õ#€GØ�{Õ#€GØ�{Õ#€GØ�{Õ#€Gô �lŠl˜7Ó,€GÜ�lŠl˜7Ó,¨wÕ6€Gà×!Ñ! +°Õ"6Ó7€HØ#ˆ[ÑØ#ˆ[ÑØ€HˆYÑØ€Oøô# ô gÜÐ6°x·~±~Ð6FÀeÈHÏNÉNÐK[Ð\Ó]ÐcfÐfûðgús   Ã*1F ÆGÆ$&G
Ç
Gc               ó    € V ^8„  d   QhRRRR/# )r	   r   r   r   r   )r   s   "r   r   r   Š   s   € ÷ =ñ = \ð =°lñ =r   c                ó¶  € \        V 4       V P                  4       R9   d   V P                  RR R8X  g   \        RV P                   24      hV R,          pV R,          pVP	                  R	R4      p\
        P                  ! V) V4      pV P                  V P                  4      pVR,          P                  V4       VR,          P                  V4       RVR
&   V# )aÍ  Invert a 4x4 rigid transform in closed form by transposing its rotation block.

``trans_21 = inverse_transformation(trans_12)`` takes a rigid transform :math:`[R|t]`, ``(N, 4, 4)`` or ``(4, 4)``,
and returns its inverse :math:`[R^\top | -R^\top t]` with the same shape, without a general matrix inversion. It
is the inverse only for a rigid input, as the convention below says; to invert and compose in one call, use
:func:`relative_transformation`.

:math:`T_1^{2} = \begin{bmatrix} R_1 & t_1 \\ \mathbf{0} & 1 \end{bmatrix}`

The inverse transformation is computed as follows:

.. math::

    T_2^{1} = (T_1^{2})^{-1} = \begin{bmatrix} R_1^T & -R_1^T t_1 \\
    \mathbf{0} & 1\end{bmatrix}

Convention:
    - The input must be a rigid :math:`[R|t]`, and this is not validated: the rotation block is transposed, not
      inverted, and the last row is read as :math:`[0, 0, 0, 1]`, so a scaled, sheared or projective matrix
      returns a result that is not its inverse. Use :func:`torch.linalg.inv` for a general matrix. Frame naming
      is on :func:`relative_transformation`.

Args:
    trans_12: transformation tensor of shape ``(N, 4, 4)`` or ``(4, 4)``.

Returns:
    tensor with inverted transformations with shape ``(N, 4, 4)`` or ``(4, 4)``.

See Also:
    - :func:`relative_transformation`: the inverse of one transform composed with another, in one call.
    - :func:`compose_transformations`: chains transforms, such as this inverse with another one.
    - :func:`~kornia.geometry.conversions.camtoworld_to_worldtocam_Rt`: the same rigid inverse for a rotation and
      a translation given apart.

Example:
    >>> trans_12 = torch.eye(4)[None]  # Nx4x4: a rotation of 90 degrees about z and a translation
    >>> trans_12[:, :3, :3] = torch.tensor([[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]])
    >>> trans_12[:, :3, 3] = torch.tensor([1.0, 2.0, 3.0])
    >>> trans_21 = inverse_transformation(trans_12)  # Nx4x4
    >>> trans_21[:, :3, 3]
    tensor([[-2.,  1., -3.]])

Nz'Input size must be a Nx4x4 or 4x4. Got r   r   r   r   r   ©.r   :r   r   Néÿÿÿÿr   )	r   r    r!   r"   Ú	transposer#   r&   r'   Úcopy_)r   r+   r-   Úrmat_21Útvec_21Útrans_21s   &     r   Úinverse_transformationr;   Š   sÊ   € ôX ˜8Ô$à�\‰\‹^˜vÔ%¨H¯N©N¸2¸3Ð,?À6Ô,IÜÐBÀ8Ç>Á>ÐBRÐSÓTÐTà�{Õ#€GØ�|Õ$€Gð ×Ñ  BÓ'€GÜ�lŠl˜G˜8 WÓ-€Gð ×!Ñ! (§.¡.Ó1€HØˆ[Õ×Ñ Ô(Øˆ\Õ× Ñ  Ô)Ø€HˆYÑØ€Or   c               ó$   € V ^8„  d   QhRRRRRR/# )r	   r
   r   r0   r   r   )r   s   "r   r   r   Ê   s&   € ÷ Mñ M lð M¸lð MÈ|ñ Mr   c                óÈ  € \        V 4       \        V4       V P                  4       R9   d   V P                  RR R	8X  g   \        RV P                   24      hVP                  4       R9   d   VP                  RR R	8X  g   \        RVP                   24      hV P                  4       VP                  4       8X  g.   \        RV P                  4        RVP                  4        24      h \        P
                  ! V P                  RR VP                  RR 4      pT R
,          pT R,          pTR
,          pTR,          pTP                  RR4      p\        P                  ! Y†4      p	\        P                  ! Y‡T,
          4      p
T P                  TR	,           4      pY›R
&   Y«R&   RTR&   T#   \         d,   p\        RT P                   RTP                   24      ThRp?ii ; i)ae  Compute the relative 4x4 transform trans_12 = inv(trans_01) @ trans_02 of two rigid poses.

``trans_12 = relative_transformation(trans_01, trans_02)`` takes two transforms into a common frame 0,
``(N, 4, 4)`` or ``(4, 4)``, and returns the transform from frame 2 to frame 1 with the broadcast shape: for two
camera-to-world poses, the pose of camera 2 in the frame of camera 1. Both inputs need the same number of
dimensions, as in :func:`compose_transformations`. For world-to-camera extrinsics given as rotations and
translations, use :func:`~kornia.geometry.epipolar.relative_camera_motion`.

Given the reference :math:`T_0^{1} = \begin{bmatrix} R_1 & t_1 \\ \mathbf{0} & 1 \end{bmatrix}` and the
destination :math:`T_0^{2} = \begin{bmatrix} R_2 & t_2 \\ \mathbf{0} & 1 \end{bmatrix}`, the relative
transformation is computed as follows:

.. math::

    T_1^{2} = (T_0^{1})^{-1} \cdot T_0^{2}

Convention:
    - ``trans_ab`` (:math:`T_a^{b}`) maps points in frame ``b`` to frame ``a``, :math:`p_a = T_a^{b} p_b`:
      ``transform_points(trans_01, points_1)`` returns ``points_0``, and
      ``compose_transformations(trans_01, trans_12)`` returns ``trans_02``.
      :ref:`Rotations and rigid motions <rotation-conventions>` maps this onto other libraries.
    - ``trans_01`` must be a rigid :math:`[R|t]`, as for :func:`inverse_transformation`, and the last row of
      ``trans_02`` is read as :math:`[0, 0, 0, 1]`, as in :func:`compose_transformations`. Neither is validated:
      a scaled, sheared or projective ``trans_01``, or a projective ``trans_02``, gives a wrong result silently.
    - :func:`~kornia.geometry.epipolar.relative_camera_motion` takes world-to-camera extrinsics
      :math:`E_1, E_2` and returns the :math:`[R|t]` of :math:`E_2 E_1^{-1}`, which is
      ``relative_transformation`` of :math:`E_2^{-1}` and :math:`E_1^{-1}`, in this order, not of :math:`E_1` and
      :math:`E_2`.

Args:
    trans_01: reference transformation tensor of shape ``(N, 4, 4)`` or ``(4, 4)``.
    trans_02: destination transformation tensor of shape ``(N, 4, 4)`` or ``(4, 4)``. A batch
      of one broadcasts against a batch of :math:`N` in either argument.

Returns:
    the relative transformation between the transformations with shape ``(N, 4, 4)`` or ``(4, 4)``.

See Also:
    - :func:`inverse_transformation`: the rigid inverse this function applies to ``trans_01``, alone.
    - :func:`compose_transformations`: the other way, ``trans_01 @ trans_12`` gives back ``trans_02``.
    - :func:`~kornia.geometry.epipolar.relative_camera_motion`: the motion between two world-to-camera
      extrinsics given as rotations and translations, :math:`E_2 E_1^{-1}`.
    - :class:`~kornia.geometry.pose.NamedPose`: a pose that names its two frames.

Example::
    >>> trans_01 = torch.eye(4)  # 4x4
    >>> trans_02 = torch.eye(4)  # 4x4
    >>> trans_12 = relative_transformation(trans_01, trans_02)  # 4x4

Nz/Input must be a of the shape Nx4x4 or 4x4. Got r   r   r   r   r   r   r   r   r4   r5   r   )
r   r    r!   r"   r#   r$   r%   r6   r&   r'   )r
   r0   r(   r)   r*   r,   r.   r/   Úrmat_10r+   r-   r   s   &&          r   Úrelative_transformationr?   Ê   sÀ  € ôf ˜8Ô$Ü˜8Ô$Ø�\‰\‹^˜vÔ%¨H¯N©N¸2¸3Ð,?À6Ô,IÜÐJÈ8Ï>É>ÐJZÐ[Ó\Ð\Ø�\‰\‹^˜vÔ%¨H¯N©N¸2¸3Ð,?À6Ô,IÜÐJÈ8Ï>É>ÐJZÐ[Ó\Ð\Ø�<‰<‹>˜XŸ\™\›^Ô+ÜÐ@ÀÇÁÃÐ@PÐPUÐV^×VbÑVbÓVdÐUeÐfÓgÐgðgÜ×,Ò,¨X¯^©^¸C¸RÐ-@À(Ç.Á.ÐQTÐRTÐBUÓVˆð �{Õ#€GØ�|Õ$€GØ�{Õ#€GØ�|Õ$€GØ×Ñ  BÓ'€GÜ�lŠl˜7Ó,€GÜ�lŠl˜7¨gÕ$5Ó6€GØ×!Ñ! +°Õ"6Ó7€HØ#ˆ[ÑØ$ˆ\ÑØ€HˆYÑà€Oøô ô gÜÐ6°x·~±~Ð6FÀeÈHÏNÉNÐK[Ð\Ó]ÐcfÐfûðgús   Ã*1F+ Æ+G!Æ6&GÇG!c               ó$   € V ^8„  d   QhRRRRRR/# )r	   Útrans_batchz	list[int]Úpoints_batchr   Úboolr   )r   s   "r   r   r     s'   € ÷ lñ l°ð lÈ)ð lÐX\ñ lr   c                ó^  € \        V 4      p\        V4      ^ 8”  d!   VR,          ^8X  d   VP                  4        K0  \        V4      ^ 8X  d   R# . pV  F  pV^8w  g   K  VP                  V4       K  	  \        VR\        V4       4      V8H  ;'       g    \        VR\        V4       4      V8H  # )aD  Whether a matrix batch with several axes lines up with the leading axes of the points' batch.

``transform_points`` pairs the flattened matrix batch with the leading points' axes in order. That pairing is right
when the matrix batch equals those leading axes, or does once its size-1 axes are left out, and wrong otherwise.
TNr5   )ÚlistÚlenÚpopÚappend)rA   rB   ÚstrippedÚnonunitÚsizes   &&   r   Ú_matrix_batch_pairs_with_pointsrL     sž   € ô �KÓ €HÜ
ˆh‹-˜!Ô
 ¨¥°Ô 1Ø�‰ŽÜ
ˆ8ƒ}˜ÔÙØ€GÛˆØ�1Ž9Ø�N‰N˜4Ö ñ ô �˜_œs 8›}Ð-Ó.°(Ñ:×kÐk¼dÀ<ÐP^ÔRUÐV]ÓR^ÐC_Ó>`ÐdkÑ>kÐkr   c               ó$   € V ^8„  d   QhRRRRRR/# )r	   r
   r   Úpoints_1r   r   )r   s   "r   r   r   ,  s&   € ÷ y"ñ y"˜|ð y"°|ð y"Èñ y"r   c                ó^	  € \        V 4       \        V4       VP                  pVP                  4       '       g   VP                  4       '       gi   V P                  4       ;'       g    V P                  4       pV'       d   V P                  M+\        P
                  ! ^ VP                  R7      P                  pV P                  4       '       g(   V P                  4       '       g   V P                  V4      p V P                  ^8X  d   V P                  ^ 4      p VP                  ^8H  ;'       d    V P                  ^ ,          ^8„  pV P                  ^ ,          VP                  ^ ,          8X  d	   V'       d>   V P                  ^ ,          ^8w  d&   \        RV P                   RVP                   24      hV P                  R,          VP                  R,          ^,           8X  g&   \        RV P                   RVP                   24      hVP                  R	,          ^ 8X  d   VP                  V4      # V P                  ^8”  dd   \        \        V P                  RR	 4      \        VP                  RR	 4      4      '       g&   \        RV P                   RVP                   24      h\        VP                  4      pVP                  RVP                  R	,          VP                  R,          4      pV P                  RV P                  R	,          V P                  R,          4      p V P                  ^ ,          ^ 8”  d,   VP                  ^ ,          V P                  ^ ,          ,          M^ p\        P                  ! V \!        V4      ^ R7      p \#        V4      pVP                  V P                  4      pV P%                  ^ ^^4      p \        P&                  P)                  4       '       d   \        P*                  ! Wp4      pMF\-        V P                  P.                  4      ;_uu_ 4        \        P*                  ! Wp4      pRRR4       \1        X4      p	V	P                  R	,          VR	&   V	P                  R,          VR&   V	P                  V4      p	V	P                  V4      #   + '       g   i     Li; i)
a  Transform (..., N, D) Euclidean points by (D+1)x(D+1) homogeneous matrices, dividing by w.

``points_0 = transform_points(trans_01, points_1)`` takes ``(D + 1, D + 1)`` or ``(B, D + 1, D + 1)`` homogeneous
matrices and Euclidean points ``(..., N, D)``, appends ``w = 1`` to each point, multiplies, divides by the
resulting ``w``, and returns the points ``(..., N, D)``. The matrix can be rigid, affine or projective: a
``(B, 3, 3)`` homography for 2D points, a ``(B, 4, 4)`` pose for 3D points. A single matrix, ``(D + 1, D + 1)`` or
``(1, D + 1, D + 1)``, applies to points of any leading shape; ``B > 1`` matrices pair matrix ``b`` with
``points_1[b]``, so the points need a leading axis of size ``B``. To divide points that are already homogeneous by
their ``w``, use :func:`~kornia.geometry.conversions.convert_points_from_homogeneous`.

Convention:
    - ``(B, D + 1, D + 1)`` matrices with ``B > 1`` raise ``ValueError`` for ``(N, D)`` points, whatever ``N``,
      and for ``(1, N, D)`` points: neither has a leading axis of size ``B``.
    - A matrix batch with more than one leading axis pairs with the leading batch axes of the points, either as
      it stands or once its size-1 axes are left out, as the ``trans_01`` argument describes; any other
      multi-axis batch raises ``ValueError``.
    - A point mapped to ``|w| <= 1e-8`` is returned undivided, as
      :func:`~kornia.geometry.conversions.convert_points_from_homogeneous` does.
    - Integer and boolean operands are promoted, not rejected, because a transform moves integer coordinates
      (pixel indices from ``torch.nonzero`` or ``argmax``) to fractional ones. Integer points return in the
      floating dtype of ``trans_01``, or in the default floating dtype when both operands are integer, and an
      integer ``trans_01`` is applied in the dtype of the result. Floating points keep their dtype; the product
      is computed in the dtype of ``trans_01``, so ``float64`` points under a ``float32`` matrix are transformed
      in ``float32``.
    - A caller's autocast region does not change the product, outside TorchScript, where a scripted call keeps the
      caller's precision. Under ``torch.compile`` on MPS it still does (torch ignores the nested guard there).

Args:
    trans_01: tensor for transformations of shape
      ``(D+1, D+1)`` or ``(B, D+1, D+1)``. A batch with several axes, ``(*, D+1, D+1)``, pairs with the
      leading batch axes of ``points_1`` in order, as it stands or once its size-1 axes are left out, so
      ``(B, 1, D+1, D+1)`` and ``(1, B, D+1, D+1)`` both apply matrix ``b`` to ``points_1[b]``; any other
      multi-axis batch raises.
    points_1: tensor of points of shape ``(*, N, D)``: ``(N, D)``, ``(B, N, D)``, or with several leading
      axes, such as ``(M, B, N, D)``, which pair with a multi-axis ``trans_01`` as described there.

Returns:
    transformed points with the same shape as ``points_1``.

See Also:
    - :func:`~kornia.geometry.conversions.convert_points_from_homogeneous`: the division by ``w`` alone, for
      points that are already homogeneous.
    - :func:`compose_transformations`: chains two ``4 x 4`` transforms before they are applied.
    - :func:`~kornia.geometry.transform.warp_grid`: applies homographies to a whole ``(1, H, W, 2)`` grid.
    - :meth:`~kornia.geometry.pose.NamedPose.transform_points`: maps points by a pose that names its frames.

Examples:
    >>> points_1 = torch.rand(2, 4, 3)  # BxNx3
    >>> trans_01 = torch.eye(4).view(1, 4, 4)  # Bx4x4
    >>> points_0 = transform_points(trans_01, points_1)  # BxNx3

)Údevicez=Input batch size must be the same for both tensors or 1. Got r   z3Last input dimensions must differ by one unit. Got NzpA matrix batch with several axes must match the leading batch axes of the points, size-1 matrix axes aside. Got )Úrepeatsr    r5   r   )r   ÚdtypeÚis_floating_pointÚ
is_complexr#   ÚemptyrP   ÚtoÚndimÚ	unsqueezer!   r"   rL   rE   ÚreshapeÚrepeat_interleaveÚintr   ÚpermuteÚjitÚis_scriptingÚbmmr   Útyper   )
r
   rN   Ú	out_dtypeÚfloating_transÚunbatched_pointsÚ	shape_inprQ   Ú
points_1_hÚ
points_0_hÚpoints_0s
   &&        r   Útransform_pointsrh   ,  sž  € ôj ˜8Ô$Ü˜8Ô$ð —‘€IØ×&Ñ&×(Ò(¨H×,?Ñ,?×,AÒ,AØ!×3Ñ3Ó5×NÐN¸×9LÑ9LÓ9Nˆß&4�H—N’N¼%¿+º+ÀaÐPX×P_ÑP_Ô:`×:fÑ:fˆ	Ø×&Ñ&×(Ò(¨H×,?Ñ,?×,AÒ,AØ—;‘;˜yÓ)ˆØ‡}�}˜ÔØ×%Ñ% aÓ(ˆð  —}‘}¨Ñ)×CÐC¨h¯n©n¸QÕ.?À!Ñ.CÐØ�N‰N˜1Õ §¡°Õ!2Ô2×6FÈHÏNÉNÐ[\ÕL]ÐabÔLbÜØKÈHÏNÉNÐK[Ð[`Ðai×aoÑaoÐ`pÐqó
ð 	
ð �>‰>˜"Õ (§.¡.°Õ"4°qÕ"8Ô9ÜÐNÈxÏ~É~ÐN^Ð^cÐdl×drÑdrÐcsÐtÓuÐuð
 ‡~�~�bÕ˜QÔØ�{‰{˜9Ó%Ð%ð ‡}�}�qÔÔ!@ÄÀhÇnÁnÐUXÐVXÐFYÓAZÔ\`Ðai×aoÑaoÐpsÐqsÐatÓ\u×!vÒ!vÜðØ"Ÿ.™.Ð)¨¨x¯~©~Ð.>ð@ó
ð 	
ô �X—^‘^Ó$€IØ×Ñ  H§N¡N°2Õ$6¸¿¹ÀrÕ8JÓK€HØ×Ñ  H§N¡N°2Õ$6¸¿¹ÀrÕ8JÓK€Hð
 9A¿¹ÀqÕ8IÈAÔ8Mˆh�n‰n˜QÕ 8§>¡>°!Õ#4Ö4ÐST€GÜ×&Ò& x¼¸W»È1ÔM€Hä.¨xÓ8€Jð —‘˜xŸ~™~Ó.€JØ×Ñ  1 aÓ(€Hô
 ‡y�y×Ñ×ÒÜ—Y’Y˜zÓ4‰
ä §¡× 4Ñ 4×5Õ5ÜŸš :Ó8ˆJ÷ 6ô /¨zÓ:€Hà—N‘N 2Õ&€Iˆb�MØ—N‘N 2Õ&€Iˆb�MØ×Ñ 	Ó*€HØ�;‰;�yÓ!Ð!÷ 6×5ús   Ð$RÒR,	c               ó    € V ^8„  d   QhRRRR/# )r	   Úxr   r   r   )r   s   "r   r   r   ¨  s   € ÷ 6ñ 6�ð 6 ñ 6r   c                ó`   € \         P                  ! V ^ 8H  \         P                  ! V 4      V 4      # )zn``x`` with 1 in place of its zeros: a divisor for entries the caller then sets to inf with :func:`_inf_where`.)r#   ÚwhereÚ	ones_like)rj   s   &r   Ú_nonzerorn   ¨  s"   € ä�;Š;�q˜A‘vœuŸš¨qÓ1°1Ó5Ð5r   c               ó$   € V ^8„  d   QhRRRRRR/# )r	   Úvaluer   Úsingularr   r   )r   s   "r   r   r   ­  s&   € ÷ Kñ K�lð K¨lð K¸|ñ Kr   c                óx   € \         P                  ! V\         P                  ! V \         P                  4      V 4      # )a9  ``value`` with inf at the ``singular`` entries.

This is the guard that replaces ``eps`` in the two-view metrics (#4881): ``torch.where`` also differentiates the
branch it does not select, so ``value`` must be formed with divisors from :func:`_nonzero`; the gradient at a
singular entry is then 0 instead of NaN.
)r#   rl   Ú	full_likeÚinf)rp   rq   s   &&r   Ú
_inf_whereru   ­  s&   € ô �;Š;�x¤§¢°¼¿	¹	Ó!BÀEÓJÐJr   c               ó    € V ^8„  d   QhRRRR/# )r	   Úsquaredr   r   r   )r   s   "r   r   r   ·  s   € ÷ uñ u˜<ð u¨Lñ ur   c           
     óÔ   € V ^ 8*  p\         P                  ! V\         P                  ! V 4      \         P                  ! V\         P                  ! V 4      V 4      P	                  4       4      # )zn``squared.sqrt()`` with a zero gradient at ``squared == 0``, an exact match, where the root's own is infinite.)r#   rl   Ú
zeros_likerm   Úsqrt)rw   Úzeros   & r   Ú_sqrt_or_zeror|   ·  sJ   € à�a‰<€DÜ�;Š;�tœU×-Ò-¨gÓ6¼¿ºÀDÌ%Ï/Ê/ÐZaÓJbÐdkÓ8l×8qÑ8qÓ8sÓtÐtr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r	   Úpointr   ÚlineÚepsÚfloatr   r   )r   s   "r   r   r   ½  s/   € ÷ A*ñ A*˜|ð A*°<ð A*Àeð A*ÐWcñ A*r   c                ó^  € \        V 4       \        V4       V P                  R,          R9  d   \        RV P                   24      hVP                  R,          ^8w  d   \        RVP                   24      hVR,          V R,          ,          pW1R,          V R,          ,          ,          pV P                  R,          ^8X  d   W1R,          V R,          ,          ,          pMW1R,          ,          pVP                  4        VR,          P	                  4       VR,          P	                  4       ,           pV^ 8H  pV\        V4      P                  4       ,          pV P                  R,          ^8X  d5   V R,          P                  4       pV\        V4      ,          pWW^ 8H  ,          p\        We4      # )a  Compute the distance from 2D points to lines ax + by + c = 0, at any scale of (a, b, c).

``d = point_line_distance(points, lines)`` takes 2D points ``(*, N, 2)``, or homogeneous ``(*, N, 3)``, and lines
:math:`(a, b, c)` ``(*, N, 3)``, and returns the Euclidean distance from each point to its line, ``(*, N)``. The
leading dimensions broadcast, so ``(M, 1, 2)`` points and ``(1, N, 3)`` lines give all ``(M, N)`` distances. For
the distance from the points of one image to the epipolar lines of their matches, use
:func:`~kornia.geometry.epipolar.left_to_right_epipolar_distance`, which builds the lines from a fundamental
matrix.

Convention:
    - ``line`` need not be normalised: the distance is :math:`|ax + by + c| / \|(a, b)\|` at every scale of the
      coefficients. A line with :math:`a = b = 0`, the line at infinity or no line at all, is at distance ``inf``
      from every point, as a point at infinity is from every line.

Args:
   point: points ``(*, N, 2)``, or homogeneous points ``(*, N, 3)`` whose last coordinate is the
     weight :math:`w`; a point at infinity (:math:`w = 0`) is at distance ``inf`` from every line.
   line: lines coefficients :math:`(a, b, c)` with shape ``(*, N, 3)``, where :math:`ax + by + c = 0`.
   eps: unused; it was added to :math:`\|(a, b)\|` and made the distance depend on the scale of the line
     (#4881). The singular line is guarded exactly instead. Accepted so that existing calls keep working.

Returns:
    the computed distance with shape ``(*, N)``.

Raises:
    ValueError: if ``point`` does not end in 2 or 3 coordinates, or ``line`` does not end in 3.

See Also:
    - :func:`~kornia.geometry.epipolar.left_to_right_epipolar_distance`: the distance from second-image points to
      the epipolar lines of their matches, built from a fundamental matrix.
    - :func:`euclidean_distance`: the distance between paired points instead of from a point to a line.
    - :meth:`~kornia.geometry.line.ParametrizedLine.distance`: the distance to a line given by an origin and a
      direction, in any dimension.

z&pts must be a (*, 2 or 3) tensor. Got z#lines must be a (*, 3) tensor. Got r5   r   ).é    ).é   ).r	   )	r   r!   r"   Úabs_Úsquarern   rz   Úabsru   )r~   r   r€   Ú	numeratorÚsquared_normrq   ÚdistanceÚws   &&&     r   Úpoint_line_distancerŒ   ½  sX  € ôH ˜5Ô!Ü˜4Ô à‡{�{�2…˜fÔ$ÜÐAÀ%Ç+Á+ÀÐOÓPÐPà‡z�z�"…~˜ÔÜÐ>¸t¿z¹z¸lÐKÓLÐLð �V•˜u V�}Õ,€IØ�f•  f¥Õ-Õ-€IØ‡{�{�2…˜!ÔØ˜&•\ E¨&¥MÕ1Õ1‰	à˜&•\Õ!ˆ	Ø‡N�NÔð ˜•<×&Ñ&Ó(¨4°­<×+>Ñ+>Ó+@Õ@€LØ˜qÑ €HØœ8 LÓ1×6Ñ6Ó8Õ8€HØ‡{�{�2…˜!Ôð �&�M×ÑÓˆØœh q›kÕ)ˆØ A™vÕ&ˆÜ�hÓ)Ð)r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r	   rj   r   ÚyÚkeepdimrC   r   r   )r   s   "r   r   r     s)   € ÷ $ñ $˜<ð $¨Lð $À4ð $ÐT`ñ $r   c                ój   € \        V RR.4       \        VRR.4       W,          P                  RV4      # )aH  Compute the dot product along the last dimension of two broadcast tensors.

``d = batched_dot_product(x, y)`` takes ``x`` and ``y`` of shape ``(*, N)``, whose shapes broadcast, and returns
``(x * y).sum(-1)``: the dot product of each pair of last-dimension vectors, with that dimension removed, or kept
as size 1 with ``keepdim=True``. For the squared norm of one tensor, use :func:`batched_squared_norm`.

Args:
    x: first vectors, with shape ``(*, N)``.
    y: second vectors, with shape ``(*, N)``.
    keepdim: whether to keep the reduced dimension as size 1.

Returns:
    the dot products, with shape ``(*)``, or ``(*, 1)`` with ``keepdim=True``.

See Also:
    - :func:`batched_squared_norm`: the dot product of a tensor with itself.
    - :func:`euclidean_distance`: the root of the summed squared differences of two point sets.

Ú*ÚNr5   )r   Úsum)rj   rŽ   r�   s   &&&r   Úbatched_dot_productr”     s3   € ô( �q˜3 ˜*Ô%Ü�q˜3 ˜*Ô%Ø�E�;‰;�r˜7Ó#Ð#r   c               ó$   € V ^8„  d   QhRRRRRR/# )r	   rj   r   r�   rC   r   r   )r   s   "r   r   r     s!   € ÷ .ñ .˜Lð .°4ð .ÀLñ .r   c                ó   € \        W V4      # )a  Compute the squared Euclidean norm along the last dimension of a tensor.

``n2 = batched_squared_norm(x)`` takes ``(*, N)`` vectors and returns the sum of their squares over the last
dimension, ``batched_dot_product(x, x)``, with that dimension removed, or kept as size 1 with ``keepdim=True``.
``squared_norm`` is the same function under another name. For the root, the norm of ``x - y``, use
:func:`euclidean_distance`.

Args:
    x: vectors with shape ``(*, N)``.
    keepdim: whether to keep the reduced dimension as size 1.

Returns:
    the squared norms, with shape ``(*)``, or ``(*, 1)`` with ``keepdim=True``.

See Also:
    - :func:`batched_dot_product`: the dot product of two tensors.
    - :func:`euclidean_distance`: the unsquared norm of the difference of two point sets.

)r”   )rj   r�   s   &&r   Úbatched_squared_normr—     s   € ô( ˜q WÓ-Ð-r   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r	   rj   r   rŽ   r�   rC   r€   r�   r   r   )r   s   "r   r   r   1  s8   € ÷ "Gñ "G˜,ð "G¨<ð "GÀ$ð "GÐUZð "GÐfrñ "Gr   c                ó\  € \        V RR.4       \        VRR.4       W,
          P                  ^4      P                  RVR7      pV^ 8„  p\        P                  ! WT\        P
                  ! V4      4      p\        P                  ! WVP                  4       \        P                  ! V4      4      # )a²  Compute the Euclidean distance between paired points along the last dimension.

``d = euclidean_distance(x, y)`` takes points ``x`` and ``y`` of shape ``(*, N)`` and returns the distance between
each pair, with the last dimension removed, or kept as size 1 with ``keepdim=True``. The points are paired, not
compared all against all: the leading dimensions broadcast, so pass ``x[:, None]`` and ``y[None]`` for an
``(M, K)`` distance matrix, or use :func:`torch.cdist`. Coincident points give exactly ``0`` with a zero gradient.

More: https://en.wikipedia.org/wiki/Euclidean_distance

Args:
    x: first set of points of shape ``(*, N)``.
    y: second set of points of shape ``(*, N)``.
    keepdim: whether to keep the dimension after reduction.
    eps: unused; kept for backward compatibility. The result is the exact Euclidean distance.

Returns:
    the distances, with shape ``(*)``, or ``(*, 1)`` with ``keepdim=True``.

See Also:
    - :func:`batched_squared_norm`: the squared norm, e.g. of ``x - y`` for squared distances without the root.
    - :func:`batched_dot_product`: the dot product along the last dimension.
    - :func:`point_line_distance`: the distance from 2D points to lines.

r‘   r’   )r    r�   r5   )r   Úpowr“   r#   rl   rm   rz   ry   )rj   rŽ   r�   r€   Úd2ÚpositiveÚsafe_d2s   &&&&   r   Úeuclidean_distancerž   1  s…   € ô2 �q˜3 ˜*Ô%Ü�q˜3 ˜*Ô%à
�%�‰�Q‹×	Ñ	 ¨GÐ	Ó	4€Bð �A‰v€HÜ�kŠk˜(¬¯ª¸Ó(;Ó<€GÜ�;Š;�x§¡£´×1AÒ1AÀ"Ó1EÓFÐFr   )	r”   r—   r1   rž   r;   rŒ   r?   r‰   rh   )g•Ö&è.>)F)Fg�íµ ÷Æ°>)Ú__doc__Ú
__future__r   r#   Úkornia.core.checkr   r   Úkornia.core.utilsr   Úkornia.geometry.conversionsr   r   Ú__all__r1   r;   r?   rL   rh   rn   ru   r|   rŒ   r”   r—   rž   r‰   r   r   r   Ú<module>r¥      ss   ðñ$õ( #ã ç HÝ 0ß fò
€õLõ^=õ@Mõ`lõ$y"õx6õ
Kõu÷A*÷H$÷2.÷."GðL $‚r   