
    Zi                         d Z ddlmZmZ ddlZddlmZ eeej        ej	        ej
        ej        f                  ZdededefdZdededefd	Zdededefd
ZdS )z4
These functions match what the spec of hnswlib is.
    )UnioncastN)NDArrayxyreturnc                 p    t           j                            | |z
            dz                                  S )N   )nplinalgnormitemr   r   s     ^/root/projects/butler/venv/lib64/python3.11/site-packages/chromadb/utils/distance_functions.pyl2r      s+    INN1q5!!Q&,,...    c           	      ^   d}| j         t          j        k    s|j         t          j        k    rd}t          t          dt          j        | |          t          j                            |           t          j                            |          z  |z   z  z
                                            S )NgKH9gHz>      ?)	dtyper   float16r   floatdotr   r   r   )r   r   NORM_EPSs      r   cosiner      s    
 Hw"*2: 5 5"&A,,29>>!#4#4ry~~a7H7H#HH"TUU
$&&	  r   c                 |    t          t          dt          j        | |          z
                                            S )Nr   )r   r   r   r   r   r   s     r   ipr      s-    bfQll*0022333r   )__doc__typingr   r   numpyr   numpy.typingr   int32float32int16r   Vectorr   r   r   r    r   r   <module>r&      s                            	rxRXrzAB	C/& /V / / / / /f  E     4& 4V 4 4 4 4 4 4 4r   