
    ]DiB	                    b[   S SK Jr  \(       d  S\;   a  SSKJr  OS SKr S SKrS r
S rS rS	 r " S
 S\5      r " S S\5      r\R$                  " \5        \R&                  r " S S\5      r\R*                  " \5         " S S\5      r\R.                  " \5         " S S\5      r\R2                  " \5         " S S\5      r\R6                  " \5         " S S\5      r\R:                  " \5         " S S\5      r\R>                  " \5         " S S\5      r \RB                  " \ 5         " S S\5      r"\RF                  " \"5         " S S\5      r$\RJ                  " \$5         " S  S!\5      r&\RN                  " \&5         " S" S#\5      r(\RR                  " \(5         " S$ S%\5      r*\RV                  " \*5         " S& S'\5      r,\RZ                  " \,5         " S( S)\5      r.\R^                  " \.5         " S* S+\5      r0\Rb                  " \05         " S, S-\5      r2\Rf                  " \25         " S. S/\5      r4\Rj                  " \45         " S0 S1\5      r6\Rn                  " \65         " S2 S3\5      r8\Rr                  " \85         " S4 S5\5      r:\Rv                  " \:5         " S6 S7\5      r<\Rz                  " \<5         " S8 S9\5      r>\R~                  " \>5         " S: S;\5      r@\R                  " \@5         " S< S=\5      rB\R                  " \B5        S> rDS? rE " S@ SA\5      rF\R                  " \F5        SB rHSC rISD rJSE rKSF rL " SG SH\5      rM\R                  " \M5        \R                  rO " SI SJ\5      rP\R                  " \P5        SK rRSL rSSM rTGS.SN jrUGS.SO jrVSP rWSQ rXSR rYGS/SS jrZST r[SU r\SV r]SW r^SX r_SY r`SZ raS[ rbS\ rcS] rdS^ reS_ rfS` rgSa rhSb riSc rjSd rkGS0Se jrlSf rmSg rnSh roSi rpSj rqSk rrGS1Sl jrsSm rtSn ruSo rvSp rw " Sq Sr\5      rx\R                  " \x5        \OR                  rz " Ss St\5      r{\R                  " \{5         " Su Sv\5      r}\R                  " \}5        Sw rSx rSy rSz rS{ rS| rGS2S} jrS~ rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rGS3S jrGS3S jrGS.S jrGS.S jrS rS rS r " S S\5      r\GR@                  " \5         " S S\5      r\GRD                  " \5        S rS rS rS rS rS rS rS rS rS rGS4S jrS rS rS rS r\GRd                  r \GRf                  r \GRh                  r \GRj                  r \GRl                  r \GRn                  r \GRp                  r\GRr                  r\GRt                  r \GRv                  r \GRx                  r S r\GR|                  r\GR~                  r\GR                  r\GR                  r\GR                  r\GR                  r\GR                  r\GR                  rS r " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5        S rS rS r " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      r\GR                  " \5         " S S\5      Gr \GR                  " G\ 5         " S S\5      Gr\GR                  " G\5         " S S\5      Gr\GR
                  " G\5         " S SG\5      Gr\GR                  " G\5        S GrGS2S jGr	S Gr
S Gr " S S\5      Gr\GR                  " G\5         " S SG\5      Gr\GR                  " G\5         " S S\5      Gr\GR"                  " G\5         " S S\5      Gr\GR&                  " G\5         " S S\5      Gr\GR*                  " G\5         " S S\5      Gr\GR.                  " G\5         " S S\5      Gr\GR2                  " G\5         " S GS \5      Gr\GR6                  " G\5         " GS GSG\5      Gr\GR:                  " G\5        GS GrGS Gr " GS GS\5      Gr \GRB                  " G\ 5        GS Gr" " GS GS	\5      Gr#\GRH                  " G\#5        GS
 Gr% " GS GS\5      Gr&\GRN                  " G\&5        GS Gr( " GS GS\5      Gr)\GRT                  " G\)5        GS Gr+ " GS GSG\5      Gr,\GRZ                  " G\,5         " GS GSG\5      Gr.\GR^                  " G\.5         " GS GS\5      Gr0\GRb                  " G\05         " GS GS\5      Gr2\GRf                  " G\25         " GS GS\5      Gr4\GRj                  " G\45         " GS GS\5      Gr6\GRn                  " G\65         " GS GSG\5      Gr8\GRr                  " G\85         " GS GS G\85      Gr:\GRv                  " G\:5         " GS! GS"G\85      Gr<\GRz                  " G\<5         " GS# GS$\5      Gr>\GR~                  " G\>5         " GS% GS&G\>5      Gr@\GR                  " G\@5         " GS' GS(\5      GrB\GR                  " G\B5         " GS) GS*\5      GrD\GR                  " G\D5         " GS+ GS,\5      GrF\GR                  " G\F5         " GS- GS.G\F5      GrH\GR                  " G\H5         " GS/ GS0G\H5      GrJ\GR                  " G\J5         " GS1 GS2G\H5      GrL\GR                  " G\L5         " GS3 GS4G\H5      GrN\GR                  " G\N5         " GS5 GS6G\F5      GrP\GR                  " G\P5         " GS7 GS8G\H5      GrR\GR                  " G\R5         " GS9 GS:G\F5      GrT\GR                  " G\T5         " GS; GS<G\F5      GrV\GR                  " G\V5         " GS= GS>G\F5      GrX\GR                  " G\X5         " GS? GS@\5      GrZ\GR                  " G\Z5         " GSA GSB\5      Gr\\GR                  " G\\5         " GSC GSD\5      Gr^\GR                  " G\^5         " GSE GSF\5      Gr`\GR                  " G\`5         " GSG GSHG\`5      Grb\GR                  " G\b5         " GSI GSJ\5      Grd\GR                  " G\d5         " GSK GSL\5      Grf\GR                  " G\f5         " GSM GSN\5      Grh\GR                  " G\h5         " GSO GSPG\h5      Grj\GR                  " G\j5         " GSQ GSRG\f5      Grl\GR                  " G\l5         " GSS GSTG\f5      Grn\GR                  " G\n5         " GSU GSV\5      Grp\GR                  " G\p5         " GSW GSX\5      Grr\GR                  " G\r5         " GSY GSZ\5      Grt\GR                  " G\t5         " GS[ GS\\5      Grv\GR                  " G\v5         " GS] GS^G\v5      Grx\GR                  " G\x5         " GS_ GS`\5      Grz\GR                  " G\z5         " GSa GSbG\z5      Gr|\GR                  " G\|5         " GSc GSdG\z5      Gr~\GR                  " G\~5         " GSe GSfG\z5      Gr\GR                  " G\5         " GSg GShG\z5      Gr\GR                  " G\5         " GSi GSj\5      Gr\GR
                  " G\5         " GSk GSl\5      Gr\GR                  " G\5         " GSm GSnG\5      Gr\GR                  " G\5         " GSo GSpG\5      Gr\GR                  " G\5         " GSq GSr\5      Gr\GR                  " G\5         " GSs GSt\5      Gr\GR                  " G\5         " GSu GSvG\5      Gr\GR"                  " G\5         " GSw GSxG\5      Gr\GR&                  " G\5         " GSy GSzG\5      Gr\GR*                  " G\5         " GS{ GS|G\5      Gr\GR.                  " G\5         " GS} GS~G\5      Gr\GR2                  " G\5         " GS GSG\5      Gr\GR6                  " G\5         " GS GSG\5      Gr\GR:                  " G\5         " GS GSG\5      Gr\GR>                  " G\5         " GS GS\5      Gr\GRB                  " G\5         " GS GSG\5      Gr\GRF                  " G\5        GS GrGS GrGS Gr " GS GS\5      Gr\GRP                  " G\5         " GS GS\5      Gr\GRT                  " G\5         " GS GS\5      Gr\GRX                  " G\5         " GS GS\5      Gr\GR\                  " G\5         " GS GSG\5      Gr\GR`                  " G\5         " GS GS\G\5      Gr\GRd                  " G\5         " GS GS\5      Gr\GRh                  " G\5         " GS GS\5      Gr\GRl                  " G\5        GS GrGS GrGS GrGS GrGS GrGS Gr " GS GS\5      Gr\GR|                  " G\5        GS GrGS GrGS5GS jGrGS5GS jGrGS GrGS3GS jGr " GS GS\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5        GS GrGS Gr " GS GSG\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5        GS6GS jGrGS GrGS GrGS7GS jGr " GS GS\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5        GS GrGS Gr " GS GS\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                   " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5        GS Gr " GS GS\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GS\5      Gr
\GR                  " G\
5         " GS GSG\
5      Gr\GR                  " G\5         " GS GSG\
5      Gr\GR                  " G\5         " GS GSG\
5      Gr\GR"                  " G\5         " GS GS\5      Gr\GR&                  " G\5         " GS GSG\5      Gr\GR*                  " G\5         " GS GS\5      Gr\GR.                  " G\5         " GS GS\5      Gr\GR2                  " G\5         " GS GS \5      Gr\GR6                  " G\5         " GS GS\5      Gr\GR:                  " G\5         " GS GSG\G\5      Gr\GR>                  " G\5         " GS GSG\5      Gr \GRB                  " G\ 5         " GS GSG\5      Gr"\GRF                  " G\"5         " GS	 GS
\5      Gr$\GRJ                  " G\$5         " GS GSG\5      Gr&\GRN                  " G\&5         " GS GSG\5      Gr(\GRR                  " G\(5        GS Gr* " GS GS\5      Gr+\GRX                  " G\+5         " GS GSG\(5      Gr-\GR\                  " G\-5         " GS GS\5      Gr/\GR`                  " G\/5         " GS GS\5      Gr1\GRd                  " G\15         " GS GS\5      Gr3\GRh                  " G\35         " GS GS\5      Gr5\GRl                  " G\55         " GS GSG\35      Gr7\GRp                  " G\75         " GS GSG\75      Gr9\GRt                  " G\95         " GS  GS!G\75      Gr;\GRx                  " G\;5         " GS" GS#G\75      Gr=\GR|                  " G\=5         " GS$ GS%G\75      Gr?\GR                  " G\?5         " GS& GS'G\35      GrA\GR                  " G\A5         " GS( GS)\5      GrC\GR                  " G\C5         " GS* GS+\5      GrE\GR                  " G\E5         " GS, GS-G\E5      GrG\GR                  " G\G5         " GS. GS/G\E5      GrI\GR                  " G\I5         " GS0 GS1G\E5      GrK\GR                  " G\K5         " GS2 GS3G\5      GrM\GR                  " G\M5         " GS4 GS5\5      GrO\GR                  " G\O5         " GS6 GS7G\M5      GrQ\GR                  " G\Q5         " GS8 GS9G\Q5      GrS\GR                  " G\S5         " GS: GS;G\Q5      GrU\GR                  " G\U5         " GS< GS=G\Q5      GrW\GR                  " G\W5         " GS> GS?G\Q5      GrY\GR                  " G\Y5         " GS@ GSA\5      Gr[\GR                  " G\[5         " GSB GSCG\M5      Gr]\GR                  " G\]5        GS5GSD jGr_GS5GSE jGr`GS5GSF jGraGSG GrbGSH Grc " GSI GSJ\5      Grd\GR                  " G\d5         " GSK GSLG\d5      Grf\GR                  " G\f5         " GSM GSNG\d5      Grh\GR                  " G\h5         " GSO GSP\5      Grj\GR                  " G\j5         " GSQ GSRG\d5      Grl\GR                  " G\l5         " GSS GSTG\d5      Grn\GR                  " G\n5         " GSU GSVG\n5      Grp\GR                  " G\p5         " GSW GSXG\d5      Grr\GR                  " G\r5         " GSY GSZ\5      Grt\GR                  " G\t5         " GS[ GS\G\d5      Grv\GR                  " G\v5         " GS] GS^\5      Grx\GR                  " G\x5         " GS_ GS`G\d5      Grz\GR                  " G\z5         " GSa GSbG\x5      Gr|\GR                  " G\|5         " GSc GSdG\z5      Gr~\GR                  " G\~5         " GSe GSfG\|G\5      Gr\GR                  " G\5         " GSg GShG\x5      Gr\GR                  " G\5         " GSi GSjG\z5      Gr\GR
                  " G\5         " GSk GSl\5      Gr\GR                  " G\5         " GSm GSn\5      Gr\GR                  " G\5         " GSo GSp\5      Gr\GR                  " G\5         " GSq GSrG\5      Gr\GR                  " G\5         " GSs GStG\5      Gr\GR                  " G\5         " GSu GSv\5      Gr\GR"                  " G\5         " GSw GSx\5      Gr\GR&                  " G\5         " GSy GSz\5      Gr\GR*                  " G\5         " GS{ GS|\5      Gr\GR.                  " G\5         " GS} GS~\5      Gr\GR2                  " G\5         " GS GSG\5      Gr\GR6                  " G\5         " GS GS\5      Gr\GR:                  " G\5         " GS GS\5      Gr\GR>                  " G\5         " GS GS\5      Gr\GRB                  " G\5         " GS GSG\5      Gr\GRF                  " G\5         " GS GSG\5      Gr\GRJ                  " G\5         " GS GS\5      Gr\GRN                  " G\5         " GS GS\5      Gr\GRR                  " G\5         " GS GSG\5      Gr\GRV                  " G\5         " GS GS\5      Gr\GRZ                  " G\5         " GS GS\5      Gr\GR^                  " G\5        GS GrGS GrGS GrGS GrGS GrGS GrGS GrGS GrGS Gr " GS GS\5      Gr\GRt                  " G\5        \OGRv                  Gr " GS GS\5      Gr\GRz                  " G\5         " GS GSG\35      Gr\GR~                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\M5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GS\5      Gr\GR                  " G\5         " GS GSG\d5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5         " GS GSG\5      Gr\GR                  " G\5        \GR                  Gr\GR                  Gr\GR                  Gr\GR                  Gr\GR                  GrGS GrGS GrGS GrGS GrGS GrGS GrGS GrGS GrGS GrGS Gr GS GrGS GrGS GrGS GrGS GrGS4GS jGrGS Gr " GS GS\5      Gr\GR                  " G\5        \OGR                  Gr
\OGR                  Gr\OGR                  Gr\OGR                  Gr\OGR                  Gr\OGR                  Gr\OGR                   Gr\OGR"                  GrGS GrGS Gr " GS GS\5      Gr\GR*                  " G\5         " GS GSG\5      Gr\GR.                  " G\5         " GS GSG\5      Gr\GR2                  " G\5         " GS GS\5      Gr\GR6                  " G\5         " GS GS\5      Gr\GR:                  " G\5         " GS GS\5      Gr\GR>                  " G\5         " GS GS\5      Gr \GRB                  " G\ 5        GS Gr"GS8GS jGr# " GS GS\5      Gr$\GRJ                  " G\$5         " GS GS\5      Gr&\GRN                  " G\&5         " GS GS \5      Gr(\GRR                  " G\(5         " GS GSG\5      Gr*\GRV                  " G\*5         " GS GSG\5      Gr,\GRZ                  " G\,5         " GS GS\5      Gr.\GR^                  " G\.5         " GS GS\5      Gr0\GRb                  " G\05         " GS	 GS
\5      Gr2\GRf                  " G\25         " GS GS\5      Gr4\GRj                  " G\45        GS Gr6GS Gr7 " GS GS\5      Gr8\GRr                  " G\85         " GS GS\5      Gr:\GRv                  " G\:5         " GS GS\5      Gr<\GRz                  " G\<5         " GS GS\5      Gr>\GR~                  " G\>5         " GS GS\5      Gr@\GR                  " G\@5         " GS GS\5      GrB\GR                  " G\B5        GS GrDGS GrEGS GrFGS GrG " GS GS \5      GrH\GR                  " G\H5        GS! GrJGS" GrKGS# GrL " GS$ GS%G\5      GrM\GR                  " G\M5        GS& GrOGS' GrPGS( GrQGS) GrRGS* GrSGS+ GrTGS, GrUGS- GrVg! \	 a    S SKr G-Nf = f(9      )version_info.   )
_swigfaissNc                      SU R                   R                  5       -   nSU R                  R
                  < SU R                  R                  < SU< S3$ ! [        R                   a    Sn NOf = f)Nz	proxy of  <r   z; z >)this__repr____builtin__	Exception	__class__
__module____name__)selfstrthiss     W/var/www/html/Aiprofessor/professorTrac/lib/python3.13/site-packages/faiss/swigfaiss.py
_swig_reprr      s_    		 2 2 44 "^^668O8OQXZZ    s   A A/.A/c                    ^  U 4S jnU$ )Nc                   > US:X  a
  T" XU5        g US:X  a  U R                   R                  U5        g [        X5      (       a2  [        [	        [        U 5      U5      [        5      (       a
  T" XU5        g [        SU -  5      e)Nr
   thisownz(You cannot add instance attributes to %s)r
   ownhasattr
isinstancegetattrtypepropertyAttributeError)r   namevaluesets      r   set_instance_attrE_swig_setattr_nondynamic_instance_variable.<locals>.set_instance_attr   si    6>E"YIIMM% T  ZT
D0I8%T%TE" !Kd!RSS     )r!   r"   s   ` r   *_swig_setattr_nondynamic_instance_variabler&      s    T r$   c                    ^  U 4S jnU$ )Nc                    > [        X5      (       a(  [        [        X5      [        5      (       d
  T" XU5        g [	        SU -  5      e)Nz%You cannot add class attributes to %s)r   r   r   r   r   )clsr   r    r!   s      r   set_class_attr?_swig_setattr_nondynamic_class_variable.<locals>.set_class_attr)   s:    3j1CX&N&N5! !H3!NOOr$   r%   )r!   r*   s   ` r   '_swig_setattr_nondynamic_class_variabler,   (   s    P
 r$   c                    ^  U 4S jnU$ )zlClass decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclassc                 p   > T" U R                   U R                  U R                  R                  5       5      $ N)r   	__bases____dict__copy)r)   	metaclasss    r   wrapper$_swig_add_metaclass.<locals>.wrapper3   s'    s}}cll6G6G6IJJr$   r%   )r3   r4   s   ` r   _swig_add_metaclassr6   1   s    KNr$   c                   <    \ rS rSrSr\" \R                  5      rSrg)_SwigNonDynamicMeta8   zKMeta class to enforce nondynamic attributes (no new attributes) for a classr%   N)	r   r   __qualname____firstlineno____doc__r,   r   __setattr____static_attributes__r%   r$   r   r8   r8   8   s    U9$:J:JKKr$   r8   c                       \ rS rSr\" S S SS9rS r\r\	R                  rS rSS jrSS	 jrS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)SwigPyIterator=   c                 6    U R                   R                  5       $ r/   r
   r   xs    r   <lambda>SwigPyIterator.<lambda>>       r$   c                 8    U R                   R                  U5      $ r/   rC   rE   vs     r   rF   rG   >       AFFJJqMr$   The membership flagdocc                     [        S5      eNz*No constructor defined - class is abstractr   r   argskwargss      r   __init__SwigPyIterator.__init__@       IJJr$   c                 .    [         R                  " U 5      $ r/   )r   SwigPyIterator_valuer   s    r   r    SwigPyIterator.valueE       ..t44r$   c                 .    [         R                  " X5      $ r/   )r   SwigPyIterator_incrr   ns     r   incrSwigPyIterator.incrH       --d66r$   c                 .    [         R                  " X5      $ r/   )r   SwigPyIterator_decrr`   s     r   decrSwigPyIterator.decrK   rd   r$   c                 .    [         R                  " X5      $ r/   )r   SwigPyIterator_distancer   rE   s     r   distanceSwigPyIterator.distanceN       11$::r$   c                 .    [         R                  " X5      $ r/   )r   SwigPyIterator_equalrk   s     r   equalSwigPyIterator.equalQ       ..t77r$   c                 .    [         R                  " U 5      $ r/   )r   SwigPyIterator_copyr[   s    r   r2   SwigPyIterator.copyT       --d33r$   c                 .    [         R                  " U 5      $ r/   )r   SwigPyIterator_nextr[   s    r   nextSwigPyIterator.nextW   rw   r$   c                 .    [         R                  " U 5      $ r/   )r   SwigPyIterator___next__r[   s    r   __next__SwigPyIterator.__next__Z       11$77r$   c                 .    [         R                  " U 5      $ r/   )r   SwigPyIterator_previousr[   s    r   previousSwigPyIterator.previous]   r   r$   c                 .    [         R                  " X5      $ r/   )r   SwigPyIterator_advancer`   s     r   advanceSwigPyIterator.advance`       0099r$   c                 .    [         R                  " X5      $ r/   )r   SwigPyIterator___eq__rk   s     r   __eq__SwigPyIterator.__eq__c       //88r$   c                 .    [         R                  " X5      $ r/   )r   SwigPyIterator___ne__rk   s     r   __ne__SwigPyIterator.__ne__f   r   r$   c                 .    [         R                  " X5      $ r/   )r   SwigPyIterator___iadd__r`   s     r   __iadd__SwigPyIterator.__iadd__i   rn   r$   c                 .    [         R                  " X5      $ r/   )r   SwigPyIterator___isub__r`   s     r   __isub__SwigPyIterator.__isub__l   rn   r$   c                 .    [         R                  " X5      $ r/   )r   SwigPyIterator___add__r`   s     r   __add__SwigPyIterator.__add__o   r   r$   c                 0    [         R                  " U /UQ76 $ r/   )r   SwigPyIterator___sub__r   rT   s     r   __sub__SwigPyIterator.__sub__r       00===r$   c                     U $ r/   r%   r[   s    r   __iter__SwigPyIterator.__iter__t   s    r$   r%   Nr   )r   r   r:   r;   r   r   rV   r   r   r   delete_SwigPyIterator__swig_destroy__r    rb   rg   rl   rq   r2   rz   r~   r   r   r   r   r   r   r   r   r   r>   r%   r$   r   r@   r@   =   s    -/IOdeGKH!77577;84488:99;;:>r$   r@   c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)Float32Vectorz   c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Float32Vector.<lambda>{   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r   {   rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Float32Vector_swiginitnew_Float32Vectorr[   s    r   rV   Float32Vector.__init__~       ))$
0L0L0NOr$   c                 .    [         R                  " X5      $ r/   )r   Float32Vector_push_backr   arg2s     r   	push_backFloat32Vector.push_back       11$==r$   c                 .    [         R                  " U 5      $ r/   )r   Float32Vector_clearr[   s    r   clearFloat32Vector.clear   rw   r$   c                 .    [         R                  " U 5      $ r/   )r   Float32Vector_datar[   s    r   dataFloat32Vector.data       ,,T22r$   c                 .    [         R                  " U 5      $ r/   )r   Float32Vector_sizer[   s    r   sizeFloat32Vector.size   r   r$   c                 .    [         R                  " X5      $ r/   )r   Float32Vector_atr`   s     r   atFloat32Vector.at       **433r$   c                 .    [         R                  " X5      $ r/   )r   Float32Vector_resizer`   s     r   resizeFloat32Vector.resize   rs   r$   c                 .    [         R                  " X5      $ r/   )r   Float32Vector_swapr   others     r   swapFloat32Vector.swap       ,,T99r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_Float32Vectorr   r>   r%   r$   r   r   r   z   M    -/IOdeGHP>43348:!66r$   r   c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)Float64Vector   c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Float64Vector.<lambda>   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r      rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Float64Vector_swiginitnew_Float64Vectorr[   s    r   rV   Float64Vector.__init__   r   r$   c                 .    [         R                  " X5      $ r/   )r   Float64Vector_push_backr   s     r   r   Float64Vector.push_back   r   r$   c                 .    [         R                  " U 5      $ r/   )r   Float64Vector_clearr[   s    r   r   Float64Vector.clear   rw   r$   c                 .    [         R                  " U 5      $ r/   )r   Float64Vector_datar[   s    r   r   Float64Vector.data   r   r$   c                 .    [         R                  " U 5      $ r/   )r   Float64Vector_sizer[   s    r   r   Float64Vector.size   r   r$   c                 .    [         R                  " X5      $ r/   )r   Float64Vector_atr`   s     r   r   Float64Vector.at   r   r$   c                 .    [         R                  " X5      $ r/   )r   Float64Vector_resizer`   s     r   r   Float64Vector.resize   rs   r$   c                 .    [         R                  " X5      $ r/   )r   Float64Vector_swapr   s     r   r   Float64Vector.swap   r   r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_Float64Vectorr   r>   r%   r$   r   r   r      r   r$   r   c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)
Int8Vector   c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Int8Vector.<lambda>   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r      rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Int8Vector_swiginitnew_Int8Vectorr[   s    r   rV   Int8Vector.__init__   s    &&tZ-F-F-HIr$   c                 .    [         R                  " X5      $ r/   )r   Int8Vector_push_backr   s     r   r   Int8Vector.push_back       ..t::r$   c                 .    [         R                  " U 5      $ r/   )r   Int8Vector_clearr[   s    r   r   Int8Vector.clear       **400r$   c                 .    [         R                  " U 5      $ r/   )r   Int8Vector_datar[   s    r   r   Int8Vector.data       ))$//r$   c                 .    [         R                  " U 5      $ r/   )r   Int8Vector_sizer[   s    r   r   Int8Vector.size   r  r$   c                 .    [         R                  " X5      $ r/   )r   Int8Vector_atr`   s     r   r   Int8Vector.at   s    ''00r$   c                 .    [         R                  " X5      $ r/   )r   Int8Vector_resizer`   s     r   r   Int8Vector.resize       ++D44r$   c                 .    [         R                  " X5      $ r/   )r   Int8Vector_swapr   s     r   r   Int8Vector.swap       ))$66r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_Int8Vectorr   r>   r%   r$   r   r   r      sM    -/IOdeGHJ;100157!33r$   r   c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)Int16Vector   c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Int16Vector.<lambda>   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r%     rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Int16Vector_swiginitnew_Int16Vectorr[   s    r   rV   Int16Vector.__init__       ''j.H.H.JKr$   c                 .    [         R                  " X5      $ r/   )r   Int16Vector_push_backr   s     r   r   Int16Vector.push_back       //;;r$   c                 .    [         R                  " U 5      $ r/   )r   Int16Vector_clearr[   s    r   r   Int16Vector.clear       ++D11r$   c                 .    [         R                  " U 5      $ r/   )r   Int16Vector_datar[   s    r   r   Int16Vector.data   r  r$   c                 .    [         R                  " U 5      $ r/   )r   Int16Vector_sizer[   s    r   r   Int16Vector.size   r  r$   c                 .    [         R                  " X5      $ r/   )r   Int16Vector_atr`   s     r   r   Int16Vector.at       ((11r$   c                 .    [         R                  " X5      $ r/   )r   Int16Vector_resizer`   s     r   r   Int16Vector.resize       ,,T55r$   c                 .    [         R                  " X5      $ r/   )r   Int16Vector_swapr   s     r   r   Int16Vector.swap       **477r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_Int16Vectorr   r>   r%   r$   r   r"  r"     M    -/IOdeGHL<211268!44r$   r"  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)Int32Vector   c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Int32Vector.<lambda>   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rL     rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Int32Vector_swiginitnew_Int32Vectorr[   s    r   rV   Int32Vector.__init__   r+  r$   c                 .    [         R                  " X5      $ r/   )r   Int32Vector_push_backr   s     r   r   Int32Vector.push_back   r/  r$   c                 .    [         R                  " U 5      $ r/   )r   Int32Vector_clearr[   s    r   r   Int32Vector.clear   r3  r$   c                 .    [         R                  " U 5      $ r/   )r   Int32Vector_datar[   s    r   r   Int32Vector.data  r  r$   c                 .    [         R                  " U 5      $ r/   )r   Int32Vector_sizer[   s    r   r   Int32Vector.size  r  r$   c                 .    [         R                  " X5      $ r/   )r   Int32Vector_atr`   s     r   r   Int32Vector.at	  r=  r$   c                 .    [         R                  " X5      $ r/   )r   Int32Vector_resizer`   s     r   r   Int32Vector.resize  rA  r$   c                 .    [         R                  " X5      $ r/   )r   Int32Vector_swapr   s     r   r   Int32Vector.swap  rE  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_Int32Vectorr   r>   r%   r$   r   rI  rI     rG  r$   rI  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)Int64Vectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Int64Vector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rk    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Int64Vector_swiginitnew_Int64Vectorr[   s    r   rV   Int64Vector.__init__  r+  r$   c                 .    [         R                  " X5      $ r/   )r   Int64Vector_push_backr   s     r   r   Int64Vector.push_back  r/  r$   c                 .    [         R                  " U 5      $ r/   )r   Int64Vector_clearr[   s    r   r   Int64Vector.clear  r3  r$   c                 .    [         R                  " U 5      $ r/   )r   Int64Vector_datar[   s    r   r   Int64Vector.data"  r  r$   c                 .    [         R                  " U 5      $ r/   )r   Int64Vector_sizer[   s    r   r   Int64Vector.size%  r  r$   c                 .    [         R                  " X5      $ r/   )r   Int64Vector_atr`   s     r   r   Int64Vector.at(  r=  r$   c                 .    [         R                  " X5      $ r/   )r   Int64Vector_resizer`   s     r   r   Int64Vector.resize+  rA  r$   c                 .    [         R                  " X5      $ r/   )r   Int64Vector_swapr   s     r   r   Int64Vector.swap.  rE  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_Int64Vectorr   r>   r%   r$   r   ri  ri    rG  r$   ri  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)UInt8Vectori4  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   UInt8Vector.<lambda>5  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  5  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   UInt8Vector_swiginitnew_UInt8Vectorr[   s    r   rV   UInt8Vector.__init__8  r+  r$   c                 .    [         R                  " X5      $ r/   )r   UInt8Vector_push_backr   s     r   r   UInt8Vector.push_back;  r/  r$   c                 .    [         R                  " U 5      $ r/   )r   UInt8Vector_clearr[   s    r   r   UInt8Vector.clear>  r3  r$   c                 .    [         R                  " U 5      $ r/   )r   UInt8Vector_datar[   s    r   r   UInt8Vector.dataA  r  r$   c                 .    [         R                  " U 5      $ r/   )r   UInt8Vector_sizer[   s    r   r   UInt8Vector.sizeD  r  r$   c                 .    [         R                  " X5      $ r/   )r   UInt8Vector_atr`   s     r   r   UInt8Vector.atG  r=  r$   c                 .    [         R                  " X5      $ r/   )r   UInt8Vector_resizer`   s     r   r   UInt8Vector.resizeJ  rA  r$   c                 .    [         R                  " X5      $ r/   )r   UInt8Vector_swapr   s     r   r   UInt8Vector.swapM  rE  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_UInt8Vectorr   r>   r%   r$   r   r  r  4  rG  r$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)UInt16VectoriS  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   UInt16Vector.<lambda>T  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  T  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   UInt16Vector_swiginitnew_UInt16Vectorr[   s    r   rV   UInt16Vector.__init__W      ((z/J/J/LMr$   c                 .    [         R                  " X5      $ r/   )r   UInt16Vector_push_backr   s     r   r   UInt16Vector.push_backZ      00<<r$   c                 .    [         R                  " U 5      $ r/   )r   UInt16Vector_clearr[   s    r   r   UInt16Vector.clear]  r   r$   c                 .    [         R                  " U 5      $ r/   )r   UInt16Vector_datar[   s    r   r   UInt16Vector.data`  r3  r$   c                 .    [         R                  " U 5      $ r/   )r   UInt16Vector_sizer[   s    r   r   UInt16Vector.sizec  r3  r$   c                 .    [         R                  " X5      $ r/   )r   UInt16Vector_atr`   s     r   r   UInt16Vector.atf      ))$22r$   c                 .    [         R                  " X5      $ r/   )r   UInt16Vector_resizer`   s     r   r   UInt16Vector.resizei  rd   r$   c                 .    [         R                  " X5      $ r/   )r   UInt16Vector_swapr   s     r   r   UInt16Vector.swapl      ++D88r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_UInt16Vectorr   r>   r%   r$   r   r  r  S  M    -/IOdeGHN=322379!55r$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)UInt32Vectorir  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   UInt32Vector.<lambda>s  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  s  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   UInt32Vector_swiginitnew_UInt32Vectorr[   s    r   rV   UInt32Vector.__init__v  r  r$   c                 .    [         R                  " X5      $ r/   )r   UInt32Vector_push_backr   s     r   r   UInt32Vector.push_backy  r  r$   c                 .    [         R                  " U 5      $ r/   )r   UInt32Vector_clearr[   s    r   r   UInt32Vector.clear|  r   r$   c                 .    [         R                  " U 5      $ r/   )r   UInt32Vector_datar[   s    r   r   UInt32Vector.data  r3  r$   c                 .    [         R                  " U 5      $ r/   )r   UInt32Vector_sizer[   s    r   r   UInt32Vector.size  r3  r$   c                 .    [         R                  " X5      $ r/   )r   UInt32Vector_atr`   s     r   r   UInt32Vector.at  r  r$   c                 .    [         R                  " X5      $ r/   )r   UInt32Vector_resizer`   s     r   r   UInt32Vector.resize  rd   r$   c                 .    [         R                  " X5      $ r/   )r   UInt32Vector_swapr   s     r   r   UInt32Vector.swap  r  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_UInt32Vectorr   r>   r%   r$   r   r  r  r  r  r$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)UInt64Vectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   UInt64Vector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   UInt64Vector_swiginitnew_UInt64Vectorr[   s    r   rV   UInt64Vector.__init__  r  r$   c                 .    [         R                  " X5      $ r/   )r   UInt64Vector_push_backr   s     r   r   UInt64Vector.push_back  r  r$   c                 .    [         R                  " U 5      $ r/   )r   UInt64Vector_clearr[   s    r   r   UInt64Vector.clear  r   r$   c                 .    [         R                  " U 5      $ r/   )r   UInt64Vector_datar[   s    r   r   UInt64Vector.data  r3  r$   c                 .    [         R                  " U 5      $ r/   )r   UInt64Vector_sizer[   s    r   r   UInt64Vector.size  r3  r$   c                 .    [         R                  " X5      $ r/   )r   UInt64Vector_atr`   s     r   r   UInt64Vector.at  r  r$   c                 .    [         R                  " X5      $ r/   )r   UInt64Vector_resizer`   s     r   r   UInt64Vector.resize  rd   r$   c                 .    [         R                  " X5      $ r/   )r   UInt64Vector_swapr   s     r   r   UInt64Vector.swap  r  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_UInt64Vectorr   r>   r%   r$   r   r  r    r  r$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)Float32VectorVectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Float32VectorVector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Float32VectorVector_swiginitnew_Float32VectorVectorr[   s    r   rV   Float32VectorVector.__init__      //j6X6X6Z[r$   c                 .    [         R                  " X5      $ r/   )r   Float32VectorVector_push_backr   s     r   r   Float32VectorVector.push_back      77CCr$   c                 .    [         R                  " U 5      $ r/   )r   Float32VectorVector_clearr[   s    r   r   Float32VectorVector.clear      33D99r$   c                 .    [         R                  " U 5      $ r/   )r   Float32VectorVector_datar[   s    r   r   Float32VectorVector.data      22488r$   c                 .    [         R                  " U 5      $ r/   )r   Float32VectorVector_sizer[   s    r   r   Float32VectorVector.size  r  r$   c                 .    [         R                  " X5      $ r/   )r   Float32VectorVector_atr`   s     r   r   Float32VectorVector.at  r   r$   c                 .    [         R                  " X5      $ r/   )r   Float32VectorVector_resizer`   s     r   r   Float32VectorVector.resize      44T==r$   c                 .    [         R                  " X5      $ r/   )r   Float32VectorVector_swapr   s     r   r   Float32VectorVector.swap      224??r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_Float32VectorVectorr   r>   r%   r$   r   r	  r	    O    -/IOdeGH\D:99:>@!<<r$   r	  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)UInt8VectorVectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   UInt8VectorVector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r1    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   UInt8VectorVector_swiginitnew_UInt8VectorVectorr[   s    r   rV   UInt8VectorVector.__init__      --dJ4T4T4VWr$   c                 .    [         R                  " X5      $ r/   )r   UInt8VectorVector_push_backr   s     r   r   UInt8VectorVector.push_back      55dAAr$   c                 .    [         R                  " U 5      $ r/   )r   UInt8VectorVector_clearr[   s    r   r   UInt8VectorVector.clear  r   r$   c                 .    [         R                  " U 5      $ r/   )r   UInt8VectorVector_datar[   s    r   r   UInt8VectorVector.data      0066r$   c                 .    [         R                  " U 5      $ r/   )r   UInt8VectorVector_sizer[   s    r   r   UInt8VectorVector.size  rB  r$   c                 .    [         R                  " X5      $ r/   )r   UInt8VectorVector_atr`   s     r   r   UInt8VectorVector.at  rs   r$   c                 .    [         R                  " X5      $ r/   )r   UInt8VectorVector_resizer`   s     r   r   UInt8VectorVector.resize      224;;r$   c                 .    [         R                  " X5      $ r/   )r   UInt8VectorVector_swapr   s     r   r   UInt8VectorVector.swap      00==r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_UInt8VectorVectorr   r>   r%   r$   r   r/  r/    N    -/IOdeGHXB8778<>!::r$   r/  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)Int32VectorVectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Int32VectorVector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rV    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Int32VectorVector_swiginitnew_Int32VectorVectorr[   s    r   rV   Int32VectorVector.__init__  r7  r$   c                 .    [         R                  " X5      $ r/   )r   Int32VectorVector_push_backr   s     r   r   Int32VectorVector.push_back  r;  r$   c                 .    [         R                  " U 5      $ r/   )r   Int32VectorVector_clearr[   s    r   r   Int32VectorVector.clear  r   r$   c                 .    [         R                  " U 5      $ r/   )r   Int32VectorVector_datar[   s    r   r   Int32VectorVector.data  rB  r$   c                 .    [         R                  " U 5      $ r/   )r   Int32VectorVector_sizer[   s    r   r   Int32VectorVector.size  rB  r$   c                 .    [         R                  " X5      $ r/   )r   Int32VectorVector_atr`   s     r   r   Int32VectorVector.at  rs   r$   c                 .    [         R                  " X5      $ r/   )r   Int32VectorVector_resizer`   s     r   r   Int32VectorVector.resize  rL  r$   c                 .    [         R                  " X5      $ r/   )r   Int32VectorVector_swapr   s     r   r   Int32VectorVector.swap  rP  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_Int32VectorVectorr   r>   r%   r$   r   rT  rT    rR  r$   rT  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)Int64VectorVectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Int64VectorVector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   ru    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Int64VectorVector_swiginitnew_Int64VectorVectorr[   s    r   rV   Int64VectorVector.__init__  r7  r$   c                 .    [         R                  " X5      $ r/   )r   Int64VectorVector_push_backr   s     r   r   Int64VectorVector.push_back  r;  r$   c                 .    [         R                  " U 5      $ r/   )r   Int64VectorVector_clearr[   s    r   r   Int64VectorVector.clear  r   r$   c                 .    [         R                  " U 5      $ r/   )r   Int64VectorVector_datar[   s    r   r   Int64VectorVector.data  rB  r$   c                 .    [         R                  " U 5      $ r/   )r   Int64VectorVector_sizer[   s    r   r   Int64VectorVector.size  rB  r$   c                 .    [         R                  " X5      $ r/   )r   Int64VectorVector_atr`   s     r   r   Int64VectorVector.at   rs   r$   c                 .    [         R                  " X5      $ r/   )r   Int64VectorVector_resizer`   s     r   r   Int64VectorVector.resize#  rL  r$   c                 .    [         R                  " X5      $ r/   )r   Int64VectorVector_swapr   s     r   r   Int64VectorVector.swap&  rP  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_Int64VectorVectorr   r>   r%   r$   r   rs  rs    rR  r$   rs  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)VectorTransformVectori,  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   VectorTransformVector.<lambda>-  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  -  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   VectorTransformVector_swiginitnew_VectorTransformVectorr[   s    r   rV   VectorTransformVector.__init__0      11$
8\8\8^_r$   c                 .    [         R                  " X5      $ r/   )r   VectorTransformVector_push_backr   s     r   r   VectorTransformVector.push_back3      99$EEr$   c                 .    [         R                  " U 5      $ r/   )r   VectorTransformVector_clearr[   s    r   r   VectorTransformVector.clear6      55d;;r$   c                 .    [         R                  " U 5      $ r/   )r   VectorTransformVector_datar[   s    r   r   VectorTransformVector.data9      44T::r$   c                 .    [         R                  " U 5      $ r/   )r   VectorTransformVector_sizer[   s    r   r   VectorTransformVector.size<  r  r$   c                 .    [         R                  " X5      $ r/   )r   VectorTransformVector_atr`   s     r   r   VectorTransformVector.at?  rL  r$   c                 .    [         R                  " X5      $ r/   )r   VectorTransformVector_resizer`   s     r   r   VectorTransformVector.resizeB      66t??r$   c                 .    [         R                  " X5      $ r/   )r   VectorTransformVector_swapr   s     r   r   VectorTransformVector.swapE      44TAAr$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_VectorTransformVectorr   r>   r%   r$   r   r  r  ,  sP    -/IOdeGH`F<;;<@B!>>r$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)OperatingPointVectoriK  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   OperatingPointVector.<lambda>L  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  L  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   OperatingPointVector_swiginitnew_OperatingPointVectorr[   s    r   rV   OperatingPointVector.__init__O      00z7Z7Z7\]r$   c                 .    [         R                  " X5      $ r/   )r   OperatingPointVector_push_backr   s     r   r   OperatingPointVector.push_backR      88DDr$   c                 .    [         R                  " U 5      $ r/   )r   OperatingPointVector_clearr[   s    r   r   OperatingPointVector.clearU  r  r$   c                 .    [         R                  " U 5      $ r/   )r   OperatingPointVector_datar[   s    r   r   OperatingPointVector.dataX  r  r$   c                 .    [         R                  " U 5      $ r/   )r   OperatingPointVector_sizer[   s    r   r   OperatingPointVector.size[  r  r$   c                 .    [         R                  " X5      $ r/   )r   OperatingPointVector_atr`   s     r   r   OperatingPointVector.at^  rn   r$   c                 .    [         R                  " X5      $ r/   )r   OperatingPointVector_resizer`   s     r   r   OperatingPointVector.resizea      55d>>r$   c                 .    [         R                  " X5      $ r/   )r   OperatingPointVector_swapr   s     r   r   OperatingPointVector.swapd      33D@@r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_OperatingPointVectorr   r>   r%   r$   r   r  r  K  O    -/IOdeGH^E;::;?A!==r$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)InvertedListsPtrVectorij  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   InvertedListsPtrVector.<lambda>k  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  k  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   InvertedListsPtrVector_swiginitnew_InvertedListsPtrVectorr[   s    r   rV   InvertedListsPtrVector.__init__n      2249^9^9`ar$   c                 .    [         R                  " X5      $ r/   )r    InvertedListsPtrVector_push_backr   s     r   r    InvertedListsPtrVector.push_backq  s    ::4FFr$   c                 .    [         R                  " U 5      $ r/   )r   InvertedListsPtrVector_clearr[   s    r   r   InvertedListsPtrVector.cleart      66t<<r$   c                 .    [         R                  " U 5      $ r/   )r   InvertedListsPtrVector_datar[   s    r   r   InvertedListsPtrVector.dataw  r  r$   c                 .    [         R                  " U 5      $ r/   )r   InvertedListsPtrVector_sizer[   s    r   r   InvertedListsPtrVector.sizez  r  r$   c                 .    [         R                  " X5      $ r/   )r   InvertedListsPtrVector_atr`   s     r   r   InvertedListsPtrVector.at}      33D<<r$   c                 .    [         R                  " X5      $ r/   )r   InvertedListsPtrVector_resizer`   s     r   r   InvertedListsPtrVector.resize  s    77@@r$   c                 .    [         R                  " X5      $ r/   )r   InvertedListsPtrVector_swapr   s     r   r   InvertedListsPtrVector.swap  s    55dBBr$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_InvertedListsPtrVectorr   r>   r%   r$   r   r  r  j  sP    -/IOdeGHbG=<<=AC!??r$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)RepeatVectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   RepeatVector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   RepeatVector_swiginitnew_RepeatVectorr[   s    r   rV   RepeatVector.__init__  r  r$   c                 .    [         R                  " X5      $ r/   )r   RepeatVector_push_backr   s     r   r   RepeatVector.push_back  r  r$   c                 .    [         R                  " U 5      $ r/   )r   RepeatVector_clearr[   s    r   r   RepeatVector.clear  r   r$   c                 .    [         R                  " U 5      $ r/   )r   RepeatVector_datar[   s    r   r   RepeatVector.data  r3  r$   c                 .    [         R                  " U 5      $ r/   )r   RepeatVector_sizer[   s    r   r   RepeatVector.size  r3  r$   c                 .    [         R                  " X5      $ r/   )r   RepeatVector_atr`   s     r   r   RepeatVector.at  r  r$   c                 .    [         R                  " X5      $ r/   )r   RepeatVector_resizer`   s     r   r   RepeatVector.resize  rd   r$   c                 .    [         R                  " X5      $ r/   )r   RepeatVector_swapr   s     r   r   RepeatVector.swap  r  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_RepeatVectorr   r>   r%   r$   r   r  r    r  r$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)ClusteringIterationStatsVectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   'ClusteringIterationStatsVector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   'ClusteringIterationStatsVector_swiginit"new_ClusteringIterationStatsVectorr[   s    r   rV   'ClusteringIterationStatsVector.__init__  s    ::4AnAnApqr$   c                 .    [         R                  " X5      $ r/   )r   (ClusteringIterationStatsVector_push_backr   s     r   r   (ClusteringIterationStatsVector.push_back      BB4NNr$   c                 .    [         R                  " U 5      $ r/   )r   $ClusteringIterationStatsVector_clearr[   s    r   r   $ClusteringIterationStatsVector.clear      >>tDDr$   c                 .    [         R                  " U 5      $ r/   )r   #ClusteringIterationStatsVector_datar[   s    r   r   #ClusteringIterationStatsVector.data      ==dCCr$   c                 .    [         R                  " U 5      $ r/   )r   #ClusteringIterationStatsVector_sizer[   s    r   r   #ClusteringIterationStatsVector.size  r/  r$   c                 .    [         R                  " X5      $ r/   )r   !ClusteringIterationStatsVector_atr`   s     r   r   !ClusteringIterationStatsVector.at      ;;DDDr$   c                 .    [         R                  " X5      $ r/   )r   %ClusteringIterationStatsVector_resizer`   s     r   r   %ClusteringIterationStatsVector.resize  s    ??HHr$   c                 .    [         R                  " X5      $ r/   )r   #ClusteringIterationStatsVector_swapr   s     r   r   #ClusteringIterationStatsVector.swap  s    ==dJJr$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   %delete_ClusteringIterationStatsVectorr   r>   r%   r$   r   r  r    sT    -/IOdeGHrOEDDEIK!GGr$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)ParameterRangeVectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ParameterRangeVector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rA    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   ParameterRangeVector_swiginitnew_ParameterRangeVectorr[   s    r   rV   ParameterRangeVector.__init__  r  r$   c                 .    [         R                  " X5      $ r/   )r   ParameterRangeVector_push_backr   s     r   r   ParameterRangeVector.push_back  r  r$   c                 .    [         R                  " U 5      $ r/   )r   ParameterRangeVector_clearr[   s    r   r   ParameterRangeVector.clear  r  r$   c                 .    [         R                  " U 5      $ r/   )r   ParameterRangeVector_datar[   s    r   r   ParameterRangeVector.data  r  r$   c                 .    [         R                  " U 5      $ r/   )r   ParameterRangeVector_sizer[   s    r   r   ParameterRangeVector.size  r  r$   c                 .    [         R                  " X5      $ r/   )r   ParameterRangeVector_atr`   s     r   r   ParameterRangeVector.at  rn   r$   c                 .    [         R                  " X5      $ r/   )r   ParameterRangeVector_resizer`   s     r   r   ParameterRangeVector.resize  r  r$   c                 .    [         R                  " X5      $ r/   )r   ParameterRangeVector_swapr   s     r   r   ParameterRangeVector.swap  r  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_ParameterRangeVectorr   r>   r%   r$   r   r?  r?    r  r$   r?  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)MaybeOwnedVectorUInt8Vectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   $MaybeOwnedVectorUInt8Vector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r`    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   $MaybeOwnedVectorUInt8Vector_swiginitnew_MaybeOwnedVectorUInt8Vectorr[   s    r   rV   $MaybeOwnedVectorUInt8Vector.__init__      77j>h>h>jkr$   c                 .    [         R                  " X5      $ r/   )r   %MaybeOwnedVectorUInt8Vector_push_backr   s     r   r   %MaybeOwnedVectorUInt8Vector.push_back      ??KKr$   c                 .    [         R                  " U 5      $ r/   )r   !MaybeOwnedVectorUInt8Vector_clearr[   s    r   r   !MaybeOwnedVectorUInt8Vector.clear      ;;DAAr$   c                 .    [         R                  " U 5      $ r/   )r    MaybeOwnedVectorUInt8Vector_datar[   s    r   r    MaybeOwnedVectorUInt8Vector.data      ::4@@r$   c                 .    [         R                  " U 5      $ r/   )r    MaybeOwnedVectorUInt8Vector_sizer[   s    r   r    MaybeOwnedVectorUInt8Vector.size  rr  r$   c                 .    [         R                  " X5      $ r/   )r   MaybeOwnedVectorUInt8Vector_atr`   s     r   r   MaybeOwnedVectorUInt8Vector.at      88AAr$   c                 .    [         R                  " X5      $ r/   )r   "MaybeOwnedVectorUInt8Vector_resizer`   s     r   r   "MaybeOwnedVectorUInt8Vector.resize      <<TEEr$   c                 .    [         R                  " X5      $ r/   )r    MaybeOwnedVectorUInt8Vector_swapr   s     r   r    MaybeOwnedVectorUInt8Vector.swap      ::4GGr$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   "delete_MaybeOwnedVectorUInt8Vectorr   r>   r%   r$   r   r^  r^    T    -/IOdeGHlLBAABFH!DDr$   r^  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)MaybeOwnedVectorInt32Vectori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   $MaybeOwnedVectorInt32Vector.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   $MaybeOwnedVectorInt32Vector_swiginitnew_MaybeOwnedVectorInt32Vectorr[   s    r   rV   $MaybeOwnedVectorInt32Vector.__init__	  rf  r$   c                 .    [         R                  " X5      $ r/   )r   %MaybeOwnedVectorInt32Vector_push_backr   s     r   r   %MaybeOwnedVectorInt32Vector.push_back  rj  r$   c                 .    [         R                  " U 5      $ r/   )r   !MaybeOwnedVectorInt32Vector_clearr[   s    r   r   !MaybeOwnedVectorInt32Vector.clear  rn  r$   c                 .    [         R                  " U 5      $ r/   )r    MaybeOwnedVectorInt32Vector_datar[   s    r   r    MaybeOwnedVectorInt32Vector.data  rr  r$   c                 .    [         R                  " U 5      $ r/   )r    MaybeOwnedVectorInt32Vector_sizer[   s    r   r    MaybeOwnedVectorInt32Vector.size  rr  r$   c                 .    [         R                  " X5      $ r/   )r   MaybeOwnedVectorInt32Vector_atr`   s     r   r   MaybeOwnedVectorInt32Vector.at  ry  r$   c                 .    [         R                  " X5      $ r/   )r   "MaybeOwnedVectorInt32Vector_resizer`   s     r   r   "MaybeOwnedVectorInt32Vector.resize  r}  r$   c                 .    [         R                  " X5      $ r/   )r    MaybeOwnedVectorInt32Vector_swapr   s     r   r    MaybeOwnedVectorInt32Vector.swap  r  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   "delete_MaybeOwnedVectorInt32Vectorr   r>   r%   r$   r   r  r    r  r$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)MaybeOwnedVectorFloat32Vectori$  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   &MaybeOwnedVectorFloat32Vector.<lambda>%  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  %  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   &MaybeOwnedVectorFloat32Vector_swiginit!new_MaybeOwnedVectorFloat32Vectorr[   s    r   rV   &MaybeOwnedVectorFloat32Vector.__init__(  s    99$
@l@l@nor$   c                 .    [         R                  " X5      $ r/   )r   'MaybeOwnedVectorFloat32Vector_push_backr   s     r   r   'MaybeOwnedVectorFloat32Vector.push_back+      AA$MMr$   c                 .    [         R                  " U 5      $ r/   )r   #MaybeOwnedVectorFloat32Vector_clearr[   s    r   r   #MaybeOwnedVectorFloat32Vector.clear.  r/  r$   c                 .    [         R                  " U 5      $ r/   )r   "MaybeOwnedVectorFloat32Vector_datar[   s    r   r   "MaybeOwnedVectorFloat32Vector.data1      <<TBBr$   c                 .    [         R                  " U 5      $ r/   )r   "MaybeOwnedVectorFloat32Vector_sizer[   s    r   r   "MaybeOwnedVectorFloat32Vector.size4  r  r$   c                 .    [         R                  " X5      $ r/   )r    MaybeOwnedVectorFloat32Vector_atr`   s     r   r    MaybeOwnedVectorFloat32Vector.at7      ::4CCr$   c                 .    [         R                  " X5      $ r/   )r   $MaybeOwnedVectorFloat32Vector_resizer`   s     r   r   $MaybeOwnedVectorFloat32Vector.resize:  s    >>tGGr$   c                 .    [         R                  " X5      $ r/   )r   "MaybeOwnedVectorFloat32Vector_swapr   s     r   r   "MaybeOwnedVectorFloat32Vector.swap=      <<TIIr$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   $delete_MaybeOwnedVectorFloat32Vectorr   r>   r%   r$   r   r  r  $  sT    -/IOdeGHpNDCCDHJ!FFr$   r  c                   t    \ rS rSr\" S S SS9r\rS rS r	S r
S	 rS
 rS rS rS r\R"                  rSrg)OnDiskOneListVectoriC  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   OnDiskOneListVector.<lambda>D  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  D  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   OnDiskOneListVector_swiginitnew_OnDiskOneListVectorr[   s    r   rV   OnDiskOneListVector.__init__G  r  r$   c                 .    [         R                  " X5      $ r/   )r   OnDiskOneListVector_push_backr   s     r   r   OnDiskOneListVector.push_backJ  r  r$   c                 .    [         R                  " U 5      $ r/   )r   OnDiskOneListVector_clearr[   s    r   r   OnDiskOneListVector.clearM  r  r$   c                 .    [         R                  " U 5      $ r/   )r   OnDiskOneListVector_datar[   s    r   r   OnDiskOneListVector.dataP  r  r$   c                 .    [         R                  " U 5      $ r/   )r   OnDiskOneListVector_sizer[   s    r   r   OnDiskOneListVector.sizeS  r  r$   c                 .    [         R                  " X5      $ r/   )r   OnDiskOneListVector_atr`   s     r   r   OnDiskOneListVector.atV  r   r$   c                 .    [         R                  " X5      $ r/   )r   OnDiskOneListVector_resizer`   s     r   r   OnDiskOneListVector.resizeY  r'  r$   c                 .    [         R                  " X5      $ r/   )r   OnDiskOneListVector_swapr   s     r   r   OnDiskOneListVector.swap\  r+  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   r   r   r   r   r   r   r   delete_OnDiskOneListVectorr   r>   r%   r$   r   r  r  C  r-  r$   r  c                 2    [         R                  " XX#U5      $ )z
 low level SIMD histogramming functions  8-bin histogram of (x - min) >> shift
values outside the range are ignored.
the data table should be aligned on 32 bytes
)r   simd_histogram_8r   ra   minshifthists        r   r  r  c  s     &&tDAAr$   c                 2    [         R                  " XX#U5      $ )zsame for 16-bin histogram)r   simd_histogram_16r  s        r   r  r  k  s    ''TBBr$   c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS rS r\R"                  rSrg	)
PartitionStatsin  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PartitionStats.<lambda>o  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  o  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   PartitionStats_swiginitnew_PartitionStatsr[   s    r   rV   PartitionStats.__init__t      **41N1N1PQr$   c                 .    [         R                  " U 5      $ r/   )r   PartitionStats_resetr[   s    r   resetPartitionStats.resetw  r]   r$   r%   N)r   r   r:   r;   r   r   r   r   r    PartitionStats_bisect_cycles_get PartitionStats_bisect_cycles_setbisect_cycles"PartitionStats_compress_cycles_get"PartitionStats_compress_cycles_setcompress_cyclesrV   r  delete_PartitionStatsr   r>   r%   r$   r   r  r  n  s_    -/IOdeGHZHH*JuJuvMzLLjN{N{|OR5!77r$   r  c                 .    [         R                  " X5      $ r/   )r   bitvec_print)bds     r   r  r  ~  s    ""1((r$   c                 0    [         R                  " XX#5      $ r/   )r   fvecs2bitvecs)rE   r  r  ra   s       r   r  r        ##A!//r$   c                 0    [         R                  " XX#5      $ r/   )r   bitvecs2fvecs)r  rE   r  ra   s       r   r
  r
    r  r$   c                 0    [         R                  " XU5      $ r/   )r   fvec2bitvec)rE   r  r  s      r   r  r    s    !!!**r$   c                 2    [         R                  " XX#XE5      $ )z/Shuffle the bits from b(i, j) := a(i, order[j]))r   bitvec_shuffle)ra   dadborderar  s         r   r  r    s    $$QBq<<r$   c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      rS rS r\R(                  rSrg	)
BitstringWriteri  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   BitstringWriter.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   BitstringWriter_swiginitnew_BitstringWriterr   code	code_sizes      r   rV   BitstringWriter.__init__      ++D*2P2PQU2abr$   c                 0    [         R                  " XU5      $ r/   )r   BitstringWriter_write)r   rE   nbits      r   writeBitstringWriter.write  s    //>>r$   r%   N)r   r   r:   r;   r   r   r   r   r   BitstringWriter_code_getBitstringWriter_code_setr  BitstringWriter_code_size_getBitstringWriter_code_size_setr  BitstringWriter_i_getBitstringWriter_i_setirV   r#  delete_BitstringWriterr   r>   r%   r$   r   r  r    sw    -/IOdeGHJ779\9\]DAA:CkCklI11:3S3STAc?!88r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      rS rS r\R(                  rSrg	)
BitstringReaderi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   BitstringReader.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r0    rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   BitstringReader_swiginitnew_BitstringReaderr  s      r   rV   BitstringReader.__init__  r  r$   c                 .    [         R                  " X5      $ r/   )r   BitstringReader_read)r   r"  s     r   readBitstringReader.read  r	  r$   r%   N)r   r   r:   r;   r   r   r   r   r   BitstringReader_code_getBitstringReader_code_setr  BitstringReader_code_size_getBitstringReader_code_size_setr  BitstringReader_i_getBitstringReader_i_setr+  rV   r8  delete_BitstringReaderr   r>   r%   r$   r   r.  r.    sw    -/IOdeGHJ779\9\]DAA:CkCklI11:3S3STAc;!88r$   r.  c                 2    [         R                  " XX#XE5      $ )aP  
 Compute a set of Hamming distances between na and nb binary vectors

:type a: uint8_t
:param a:             size na * nbytespercode
:type b: uint8_t
:param b:             size nb * nbytespercode
:type nbytespercode: int
:param nbytespercode: should be multiple of 8
:type dis: int
:param dis:           output distances, size na * nb
)r   hammings)r  r  nanbnbytespercodediss         r   rB  rB    s     qR]@@r$   c                  (    [         R                  " U 6 $ )aw  
 Return the k smallest Hamming distances for a set of binary query vectors,
using a max heap.
:type a: uint8_t
:param a:       queries, size ha->nh * ncodes
:type b: uint8_t
:param b:       database, size nb * ncodes
:type nb: int
:param nb:      number of database vectors
:type ncodes: int
:param ncodes:  size of the binary codes (bytes)
:type ordered: int
:param ordered: if != 0: order the results by decreasing distance
                   (may be bottleneck for k/n > 0.01)
:type approx_topk_mode: int, optional
:param approx_topk_mode: allows to use approximate top-k facilities
                            to speedup heap
)r   hammings_knn_hcrT   s    r   rH  rH    s    & %%t,,r$   c                 2    [         R                  " XX#XE5      $ r/   )r   hammings_knn)har  r  rD  ncodesordereds         r   rK  rK    s    ""2!AAr$   c	                 6    [         R                  " XX#XEXgU5	      $ )a  
 Return the k smallest Hamming distances for a set of binary query vectors,
using counting max.
:type a: uint8_t
:param a:       queries, size na * ncodes
:type b: uint8_t
:param b:       database, size nb * ncodes
:type na: int
:param na:      number of query vectors
:type nb: int
:param nb:      number of database vectors
:type k: int
:param k:       number of vectors/distances to return
:type ncodes: int
:param ncodes:  size of the binary codes (bytes)
:type distances: int
:param distances: output distances from each query vector to its k nearest
                   neighbors
:type labels: int
:param labels:  output ids of the k nearest neighbors to each query vector
)r   hammings_knn_mc)	r  r  rC  rD  krM  	distanceslabelssels	            r   rP  rP    s    , %%aBAyRUVVr$   c           
      4    [         R                  " XX#XEXg5      $ )zCsame as hammings_knn except we are doing a range search with radius)r   hamming_range_search)r  r  rC  rD  radiusrM  resultrT  s           r   rV  rV    s    **1UUr$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   hamming_count_thres)bs1bs2n1n2htrM  nptrs          r   rZ  rZ    s    ))#BBMMr$   c           
      4    [         R                  " XX#XEXg5      $ r/   )r   match_hamming_thres)r[  r\  r]  r^  r_  rM  idxrF  s           r   rb  rb    s    ))#BBQQr$   c                 2    [         R                  " XX#U5      $ r/   )r   crosshamming_count_thres)dbsra   r_  rM  r`  s        r   re  re    s    ..sr4HHr$   c                 2    [         R                  " XX#XE5      $ )zS
generalized Hamming distances (= count number of code bytes that
   are the same)
)r   generalized_hammings_knn_hc)rL  r  r  rD  r  rN  s         r   rh  rh    s    
 11"	SSr$   c                  (    [         R                  " U 6 $ )aT  
*Overload 1:*
 Pack a set of n codes of size M * nbit

:type n: int
:param n:           number of codes to pack
:type M: int
:param M:           number of elementary codes per code
:type nbit: int
:param nbit:        number of bits per elementary code
:type unpacked: int
:param unpacked:    input unpacked codes, size (n, M)
:type packed: uint8_t
:param packed:      output packed codes, size (n, code_size)
:type code_size: int
:param code_size:   should be >= ceil(M * nbit / 8)

|

*Overload 2:*
 Pack a set of n codes of variable sizes

:param nbit:       number of bits per entry (size M)
)r   pack_bitstringsrI  s    r   rj  rj    s    2 %%t,,r$   c                  (    [         R                  " U 6 $ )aX  
*Overload 1:*
 Unpack a set of n codes of size M * nbit

:type n: int
:param n:           number of codes to pack
:type M: int
:param M:           number of elementary codes per code
:type nbit: int
:param nbit:        number of bits per elementary code
:type unpacked: int
:param unpacked:    input unpacked codes, size (n, M)
:type packed: uint8_t
:param packed:      output packed codes, size (n, code_size)
:type code_size: int
:param code_size:   should be >= ceil(M * nbit / 8)

|

*Overload 2:*
 Unpack a set of n codes of variable sizes

:param nbit:       number of bits per entry (size M)
)r   unpack_bitstringsrI  s    r   rl  rl    s    2 ''..r$   c                 .    [         R                  " U 5      $ r/   )r   
popcount32rD   s    r   rn  rn  9        ##r$   c                 .    [         R                  " U 5      $ r/   )r   
popcount64rD   s    r   rq  rq  <  ro  r$   c                  ,    [         R                  " 5       $ r/   )r   get_num_gpusr%   r$   r   rs  rs  ?      ""$$r$   c                  ,    [         R                  " 5       $ r/   )r   gpu_profiler_startr%   r$   r   rv  rv  B  s    ((**r$   c                  ,    [         R                  " 5       $ r/   )r   gpu_profiler_stopr%   r$   r   rx  rx  E  s    ''))r$   c                  ,    [         R                  " 5       $ r/   )r   gpu_sync_all_devicesr%   r$   r   rz  rz  H  s    **,,r$   c                  ,    [         R                  " 5       $ )zget compile options)r   get_compile_optionsr%   r$   r   r|  r|  K  s    ))++r$   c                  ,    [         R                  " 5       $ r/   )r   get_versionr%   r$   r   r~  r~  O  s    !!##r$   c                  ,    [         R                  " 5       $ )z%ms elapsed since some arbitrary epoch)r   getmillisecsr%   r$   r   r  r  R      ""$$r$   c                  ,    [         R                  " 5       $ )zget current RSS usage in kB)r   get_mem_usage_kbr%   r$   r   r  r  V  s    &&((r$   c                  ,    [         R                  " 5       $ r/   )r   
get_cyclesr%   r$   r   r  r  Z  s      ""r$   c                 2    [         R                  " XX#U5      $ r/   )r   
reflection)urE   ra   r  nus        r   r  r  ]  s      qR00r$   c                 0    [         R                  " XU5      $ )zs
 compute the Q of the QR decomposition for m > n
:type a: float
:param a:   size n * m: input matrix and output Q
)r   	matrix_qr)mra   r  s      r   r  r  `  s     a((r$   c                 0    [         R                  " XU5      $ )zEdistances are supposed to be sorted. Sorts indices with same distance)r   ranklist_handle_ties)rQ  rc  rF  s      r   r  r  h  s    **1377r$   c                 0    [         R                  " XX#5      $ )z|
 count the number of common elements between v1 and v2
algorithm = sorting + bisection to avoid double-counting duplicates
)r   ranklist_intersection_size)k1v1k2v2s       r   r  r  l  s    
 00@@r$   c           
      4    [         R                  " XX#XEXg5      $ )a  
 merge a result table into another one

:type I0: int
:param I0:, D0       first result table, size (n, k)
:type I1: int
:param I1:, D1       second result table, size (n, k)
:type keep_min: boolean, optional
:param keep_min:     if true, keep min values, otherwise keep max
:type translation: int, optional
:param translation:  add this value to all I1's indexes
:rtype: int
:return: nb of values that were taken from the second table
)r   merge_result_table_with)ra   rQ  I0D0I1D1keep_mintranslations           r   r  r  s  s     --aBBHZZr$   c                  (    [         R                  " U 6 $ )z
*Overload 1:*
a balanced assignment has a IF of 1, a completely unbalanced assignment has
an IF = k.

|

*Overload 2:*
same, takes a histogram as input
)r   imbalance_factorrI  s    r   r  r    s     &&--r$   c                 0    [         R                  " XX#5      $ )zcompute histogram on v)r   	ivec_hist)ra   rK   vmaxr  s       r   r  r    s    d11r$   c                 0    [         R                  " XX#5      $ )z
 Compute histogram of bits on a code array

:type codes: uint8_t
:param codes:   size(n, nbits / 8)
:type hist: int
:param hist:    size(nbits): nb of 1s in the array of codes
)r   bincode_hist)ra   nbitscodesr  s       r   r  r    s     ""1U99r$   c                 .    [         R                  " X5      $ zcompute a checksum on a table.)r   ivec_checksumra   r  s     r   r  r        ##A))r$   c                 .    [         R                  " X5      $ r  )r   bvec_checksumr  s     r   r  r    r  r$   c                 0    [         R                  " XX#5      $ )z
 compute checksums for the rows of a matrix

:type n: int
:param n:   number of rows
:type d: int
:param d:   size per row
:type a: uint8_t
:param a:   matrix to handle, size n * d
:type cs: int
:param cs:  output checksums, size n
)r   bvecs_checksum)ra   r  r  css       r   r  r    s     $$Q111r$   c                 2    [         R                  " XX#XE5      $ )a  
 random subsamples a set of vectors if there are too many of them

:type d: int
:param d:      dimension of the vectors
:type n: int
:param n:      on input: nb of input vectors, output: nb of output vectors
:type nmax: int
:param nmax:   max nb of vectors to keep
:type x: float
:param x:      input array, size *n-by-d
:type seed: int, optional
:param seed:   random seed to use for sampling
:rtype: float
:return: x or an array allocated with new [] with *n vectors
)r   fvecs_maybe_subsample)r  ra   nmaxrE   verboseseeds         r   r  r    s    " ++A$7IIr$   c                 0    [         R                  " XU5      $ )a  
 Convert binary vector to +1/-1 valued float vector.

:type d: int
:param d:      dimension of the vector (multiple of 8)
:type x_in: uint8_t
:param x_in:   input binary vector (uint8_t table of size d / 8)
:type x_out: float
:param x_out:  output float vector (float table of size d)
)r   binary_to_realr  x_inx_outs      r   r  r    s     $$Qe44r$   c                 0    [         R                  " XU5      $ )aA  
 Convert float vector to binary vector. Components > 0 are converted to 1,
others to 0.

:type d: int
:param d:      dimension of the vector (multiple of 8)
:type x_in: float
:param x_in:   input float vector (float table of size d)
:type x_out: uint8_t
:param x_out:  output binary vector (uint8_t table of size d / 8)
)r   real_to_binaryr  s      r   r  r    s     $$Qe44r$   c                 .    [         R                  " X5      $ )zA reasonable hashing function)r   
hash_bytes)bytesra   s     r   r  r    s      **r$   c                  ,    [         R                  " 5       $ )z*Whether OpenMP annotations were respected.)r   check_openmpr%   r$   r   r  r    r  r$   c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS rS r\R"                  rSrg	)
CodeSeti  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   CodeSet.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   CodeSet_swiginitnew_CodeSetr   r  s     r   rV   CodeSet.__init__  s    ##D**@*@*CDr$   c                 0    [         R                  " XX#5      $ r/   )r   CodeSet_insert)r   ra   r  inserteds       r   insertCodeSet.insert  s    ((%BBr$   r%   N)r   r   r:   r;   r   r   r   r   r   CodeSet_d_getCodeSet_d_setr  CodeSet_s_getCodeSet_s_setsrV   r  delete_CodeSetr   r>   r%   r$   r   r  r    s`    -/IOdeGH)):+C+CDA)):+C+CDAEC!00r$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  SS9r\" \	R&                  \	R(                  S	S9rS
 r\" \	R.                  \	R0                  SS9r\" \	R4                  \	R6                  SS9r\" \	R:                  \	R<                  SS9r\" \	R@                  \	RB                  SS9r"\" \	RF                  \	RH                  SS9r%\" \	RL                  \	RN                  SS9r(\" \	RR                  \	RT                  SS9r+S r,S r-\	R\                  r/Sr0g)CombinerRangeKNNfloati  k
 This class is used to combine range and knn search results
in contrib.exhaustive_search.range_search_gpu
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   CombinerRangeKNNfloat.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   nb of queries+number of neighbors for the knn search partrange search radiusc           	      \    [         R                  " U [         R                  " XX45      5        gz*whether to keep max values instead of min.N)r   CombinerRangeKNNfloat_swiginitnew_CombinerRangeKNNfloatr   nqrQ  r2keep_maxs        r   rV   CombinerRangeKNNfloat.__init__
  !    11$
8\8\]_df8qrr$   Knn search resultssize nq * kR
    size nq * k
    optional: range search results (ignored if mask is NULL)
    -mask for where knn results are valid, size nqsize nrange + 1size lim_remain[nrange]c                 .    [         R                  " X5      $ zsize nq + 1)r   #CombinerRangeKNNfloat_compute_sizesr   L_ress     r   compute_sizes#CombinerRangeKNNfloat.compute_sizes      ==dJJr$   c                 0    [         R                  " XU5      $ z]
Phase 2: caller allocates D_res and I_res (size L_res[nq])
Phase 3: fill in D_res and I_res
)r   "CombinerRangeKNNfloat_write_resultr   D_resI_ress      r   write_result"CombinerRangeKNNfloat.write_result      
 <<T%PPr$   r%   N)1r   r   r:   r;   r<   r   r   r   r   r   CombinerRangeKNNfloat_nq_getCombinerRangeKNNfloat_nq_setr  CombinerRangeKNNfloat_k_getCombinerRangeKNNfloat_k_setrQ  CombinerRangeKNNfloat_r2_getCombinerRangeKNNfloat_r2_setr  "CombinerRangeKNNfloat_keep_max_get"CombinerRangeKNNfloat_keep_max_setr  rV   CombinerRangeKNNfloat_I_getCombinerRangeKNNfloat_I_setICombinerRangeKNNfloat_D_getCombinerRangeKNNfloat_D_setDCombinerRangeKNNfloat_mask_getCombinerRangeKNNfloat_mask_setmask$CombinerRangeKNNfloat_lim_remain_get$CombinerRangeKNNfloat_lim_remain_set
lim_remain"CombinerRangeKNNfloat_D_remain_get"CombinerRangeKNNfloat_D_remain_setD_remain"CombinerRangeKNNfloat_I_remain_get"CombinerRangeKNNfloat_I_remain_setI_remainCombinerRangeKNNfloat_L_res_getCombinerRangeKNNfloat_L_res_setr  r  r  delete_CombinerRangeKNNfloatr   r>   r%   r$   r   r  r       
 -/IOdeGH	*99:;b;b	cB779_9_eyzA	*99:;b;b  i[  
\B
EEzGtGt  {U  VHs 	779_9_e~A779_9_ewxAJ==z?h?h o 	D *II:KzKz  Au  vJ
EEzGtGt  {Q  RH
EEzGtGt  {Y  ZHZ??AkAk  rP  QEKQ ">>r$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  SS9r\" \	R&                  \	R(                  S	S9rS
 r\" \	R.                  \	R0                  SS9r\" \	R4                  \	R6                  SS9r\" \	R:                  \	R<                  SS9r\" \	R@                  \	RB                  SS9r"\" \	RF                  \	RH                  SS9r%\" \	RL                  \	RN                  SS9r(\" \	RR                  \	RT                  SS9r+S r,S r-\	R\                  r/Sr0g)CombinerRangeKNNint16i&  r  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   CombinerRangeKNNint16.<lambda>,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r!  ,  rL   r$   rM   rN   r  r  r  c           	      \    [         R                  " U [         R                  " XX45      5        gr  )r   CombinerRangeKNNint16_swiginitnew_CombinerRangeKNNint16r  s        r   rV   CombinerRangeKNNint16.__init__3  r  r$   r  r  r  r  r  r  c                 .    [         R                  " X5      $ r  )r   #CombinerRangeKNNint16_compute_sizesr  s     r   r  #CombinerRangeKNNint16.compute_sizesA  r  r$   c                 0    [         R                  " XU5      $ r  )r   "CombinerRangeKNNint16_write_resultr  s      r   r  "CombinerRangeKNNint16.write_resultE  r  r$   r%   N)1r   r   r:   r;   r<   r   r   r   r   r   CombinerRangeKNNint16_nq_getCombinerRangeKNNint16_nq_setr  CombinerRangeKNNint16_k_getCombinerRangeKNNint16_k_setrQ  CombinerRangeKNNint16_r2_getCombinerRangeKNNint16_r2_setr  "CombinerRangeKNNint16_keep_max_get"CombinerRangeKNNint16_keep_max_setr  rV   CombinerRangeKNNint16_I_getCombinerRangeKNNint16_I_setr
  CombinerRangeKNNint16_D_getCombinerRangeKNNint16_D_setr  CombinerRangeKNNint16_mask_getCombinerRangeKNNint16_mask_setr  $CombinerRangeKNNint16_lim_remain_get$CombinerRangeKNNint16_lim_remain_setr  "CombinerRangeKNNint16_D_remain_get"CombinerRangeKNNint16_D_remain_setr  "CombinerRangeKNNint16_I_remain_get"CombinerRangeKNNint16_I_remain_setr  CombinerRangeKNNint16_L_res_getCombinerRangeKNNint16_L_res_setr  r  r  delete_CombinerRangeKNNint16r   r>   r%   r$   r   r  r  &  r  r$   r  c                 0    [         R                  " XU5      $ )z'Squared L2 distance between two vectors)r   
fvec_L2sqrrE   yr  s      r   rE  rE  P  s      q))r$   c                 0    [         R                  " XU5      $ )zinner product)r   fvec_inner_productrF  s      r   rI  rI  T  s    ((q11r$   c                 0    [         R                  " XU5      $ )zL1 distance)r   fvec_L1rF  s      r   rK  rK  X  s    aA&&r$   c                 0    [         R                  " XU5      $ )zinfinity distance)r   	fvec_LinfrF  s      r   rM  rM  \  s    a((r$   c
                 6    [         R                  " XX#XEXgX5
      $ )zm
Special version of inner product that computes 4 distances
between x and yi, which is performance oriented.
)r   fvec_inner_product_batch_4
rE   y0y1y2y3r  dis0dis1dis2dis3s
             r   rO  rO  `  s    
 00tSW^^r$   c
                 6    [         R                  " XX#XEXgX5
      $ )ze
Special version of L2sqr that computes 4 distances
between x and yi, which is performance oriented.
)r   fvec_L2sqr_batch_4rP  s
             r   rZ  rZ  g  s    
 ((t4VVr$   c	                 6    [         R                  " XX#XEXgU5	      $ )a  
 Compute pairwise distances between sets of vectors

:type d: int
:param d:     dimension of the vectors
:type nq: int
:param nq:    nb of query vectors
:type nb: int
:param nb:    nb of database vectors
:type xq: float
:param xq:    query vectors (size nq * d)
:type xb: float
:param xb:    database vectors (size nb * d)
:type dis: float
:param dis:   output distances (size nq * nb)
:param ldq,ldb:, ldd strides for the matrices
)r   pairwise_L2sqr)	r  r  xqrD  xbrF  ldqldbldds	            r   r\  r\  n  s    $ $$QBBSsKKr$   c                 2    [         R                  " XX#U5      $ r/   )r   fvec_inner_products_ny)iprE   rG  r  nys        r   rc  rc    s    ,,RA"==r$   c                 2    [         R                  " XX#U5      $ r/   )r   fvec_L2sqr_ny)rF  rE   rG  r  re  s        r   rg  rg    s    ##CA"55r$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   fvec_L2sqr_ny_transposed)rF  rE   rG  y_sqlenr  d_offsetre  s          r   ri  ri    s    ..sq1PRSSr$   c                 2    [         R                  " XX#U5      $ r/   )r   fvec_L2sqr_ny_nearest)distances_tmp_bufferrE   rG  r  re  s        r   rm  rm    s    ++,@Q2NNr$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   "fvec_L2sqr_ny_nearest_y_transposed)rn  rE   rG  rj  r  rk  re  s          r   rp  rp    s    889MRS^_kmnnr$   c                 .    [         R                  " X5      $ )zsquared norm of a vector)r   fvec_norm_L2sqr)rE   r  s     r   rr  rr    s    %%a++r$   c                 0    [         R                  " XX#5      $ )z
 compute the L2 norms for a set of vectors

:type norms: float
:param norms:    output norms, size nx
:type x: float
:param x:        set of vectors, size nx * d
)r   fvec_norms_L2normsrE   r  nxs       r   rt  rt    s     ##Ea44r$   c                 0    [         R                  " XX#5      $ )z1same as fvec_norms_L2, but computes squared norms)r   fvec_norms_L2sqrru  s       r   ry  ry    s    &&u77r$   c                 0    [         R                  " XU5      $ r/   )r   fvec_renorm_L2)r  rw  rE   s      r   r{  r{    s    $$QA..r$   c                 2    [         R                  " XX#U5      $ r/   )r   inner_product_to_L2sqr)rF  nr1nr2r]  r^  s        r   r}  r}    s    ,,SsCCr$   c                  (    [         R                  " U 6 $ )aV  
*Overload 1:*
 compute c := a + b for vectors

c and a can overlap, c and b can overlap

:type a: float
:param a: size d
:type b: float
:param b: size d
:type c: float
:param c: size d

|

*Overload 2:*
 compute c := a + b for a, c vectors and b a scalar

c and a can overlap

:type a: float
:param a: size d
:type c: float
:param c: size d
)r   fvec_addrI  s    r   r  r    s    4 %%r$   c                 0    [         R                  " XX#5      $ )z
 compute c := a - b for vectors

c and a can overlap, c and b can overlap

:type a: float
:param a: size d
:type b: float
:param b: size d
:type c: float
:param c: size d
)r   fvec_sub)r  r  r  cs       r   r  r    s     qQ**r$   c           	      4    [         R                  " XX#XEU5      $ )a  
 compute the inner product between x and a subset y of ny vectors defined by
ids

ip(i, j) = inner_product(x(i, :), y(ids(i, j), :))

:type ip: float
:param ip:    output array, size nx * ny
:type x: float
:param x:     first-term vector, size nx * d
:type y: float
:param y:     second-term vector, size (max(ids) + 1) * d
:type ids: int
:param ids:   ids to sample from y, size nx * ny
)r   fvec_inner_products_by_idx)rd  rE   rG  idsr  rw  re  s          r   r  r    s      00rJJr$   c           	      4    [         R                  " XX#XEU5      $ )a  
 compute the squared L2 distances between x and a subset y of ny vectors
defined by ids

dis(i, j) = inner_product(x(i, :), y(ids(i, j), :))

:type dis: float
:param dis:   output array, size nx * ny
:type x: float
:param x:     first-term vector, size nx * d
:type y: float
:param y:     second-term vector, size (max(ids) + 1) * d
:type ids: int
:param ids:   ids to sample from y, size nx * ny
)r   fvec_L2sqr_by_idx)rF  rE   rG  r  r  rw  re  s          r   r  r    s      ''rBBr$   c           	      4    [         R                  " XX#XEU5      $ )a  
 compute dis[j] = L2sqr(x[ix[j]], y[iy[j]]) forall j=0..n-1

:type x: float
:param x:  size (max(ix) + 1, d)
:type y: float
:param y:  size (max(iy) + 1, d)
:type ix: int
:param ix: size n
:type iy: int
:param iy: size n
:type dis: float
:param dis: size n
)r   pairwise_indexed_L2sqrr  ra   rE   ixrG  iyrF  s          r   r  r    s     ,,Q1!EEr$   c           	      4    [         R                  " XX#XEU5      $ )a
  
 compute dis[j] = inner_product(x[ix[j]], y[iy[j]]) forall j=0..n-1

:type x: float
:param x:  size (max(ix) + 1, d)
:type y: float
:param y:  size (max(iy) + 1, d)
:type ix: int
:param ix: size n
:type iy: int
:param iy: size n
:type dis: float
:param dis: size n
)r   pairwise_indexed_inner_productr  s          r   r  r  
  s     44Q1!MMr$   c                  (    [         R                  " U 6 $ )ar  
*Overload 1:*
 Return the k nearest neighbors of each of the nx vectors x among the ny
 vector y, w.r.t to max inner product.

:type x: float
:param x:    query vectors, size nx * d
:type y: float
:param y:    database vectors, size ny * d
:type res: :py:class:`float_minheap_array_t`
:param res:  result heap structure, which also provides k. Sorted on output

|

*Overload 2:*
  Return the k nearest neighbors of each of the nx vectors x among the ny
 vector y, for the inner product metric.

:type x: float
:param x:    query vectors, size nx * d
:type y: float
:param y:    database vectors, size ny * d
:type distances: float
:param distances:  output distances, size nq * k
:type indexes: int
:param indexes:    output vector ids, size nq * k

|

*Overload 3:*
  Return the k nearest neighbors of each of the nx vectors x among the ny
 vector y, for the inner product metric.

:type x: float
:param x:    query vectors, size nx * d
:type y: float
:param y:    database vectors, size ny * d
:type distances: float
:param distances:  output distances, size nq * k
:type indexes: int
:param indexes:    output vector ids, size nq * k
)r   knn_inner_productrI  s    r   r  r    s    V ''..r$   c                  (    [         R                  " U 6 $ )ah  
*Overload 1:*
 Return the k nearest neighbors of each of the nx vectors x among the ny
 vector y, for the L2 distance
:type x: float
:param x:    query vectors, size nx * d
:type y: float
:param y:    database vectors, size ny * d
:type res: :py:class:`float_maxheap_array_t`
:param res:  result heap structure, which also provides k. Sorted on output
:type y_norm2: float, optional
:param y_norm2:    (optional) norms for the y vectors (nullptr or size ny)
:type sel: :py:class:`IDSelector`, optional
:param sel:  search in this subset of vectors

|

*Overload 2:*
  Return the k nearest neighbors of each of the nx vectors x among the ny
 vector y, for the L2 distance

:type x: float
:param x:    query vectors, size nx * d
:type y: float
:param y:    database vectors, size ny * d
:type distances: float
:param distances:  output distances, size nq * k
:type indexes: int
:param indexes:    output vector ids, size nq * k
:type y_norm2: float, optional
:param y_norm2:    (optional) norms for the y vectors (nullptr or size ny)
:type sel: :py:class:`IDSelector`, optional
:param sel:  search in this subset of vectors

|

*Overload 3:*
  Return the k nearest neighbors of each of the nx vectors x among the ny
 vector y, for the L2 distance

:type x: float
:param x:    query vectors, size nx * d
:type y: float
:param y:    database vectors, size ny * d
:type distances: float
:param distances:  output distances, size nq * k
:type indexes: int
:param indexes:    output vector ids, size nq * k
:type y_norm2: float, optional
:param y_norm2:    (optional) norms for the y vectors (nullptr or size ny)
:param sel:  search in this subset of vectors

|

*Overload 4:*
  Return the k nearest neighbors of each of the nx vectors x among the ny
 vector y, for the L2 distance

:type x: float
:param x:    query vectors, size nx * d
:type y: float
:param y:    database vectors, size ny * d
:type distances: float
:param distances:  output distances, size nq * k
:type indexes: int
:param indexes:    output vector ids, size nq * k
:param y_norm2:    (optional) norms for the y vectors (nullptr or size ny)
:param sel:  search in this subset of vectors
)r   	knn_L2sqrrI  s    r   r  r  H  s    L &&r$   c                 8    [         R                  " XX#XEXgXU
5      $ )a	  
 Find the max inner product neighbors for nx queries in a set of ny vectors
indexed by ids. May be useful for re-ranking a pre-selected vector list

:type x: float
:param x:    query vectors, size nx * d
:type y: float
:param y:    database vectors, size (max(ids) + 1) * d
:type ids: int
:param ids:  subset of database vectors to consider, size (nx, nsubset)
:param res:  result structure
:type ld_ids: int, optional
:param ld_ids: stride for the ids array. -1: use nsubset, 0: all queries
    process the same subset
)r   knn_inner_products_by_idx)rE   rG  subsetr  rw  re  nsubsetrQ  valsr  ld_idss              r   r  r    s!      //fUY`fggr$   c                 8    [         R                  " XX#XEXgXU
5      $ )a  
 Find the nearest neighbors for nx queries in a set of ny vectors
indexed by ids. May be useful for re-ranking a pre-selected vector list

:type x: float
:param x:    query vectors, size nx * d
:type y: float
:param y:    database vectors, size (max(ids) + 1) * d
:type subset: int
:param subset: subset of database vectors to consider, size (nx, nsubset)
:param res:  result structure
:type ld_subset: int, optional
:param ld_subset: stride for the subset array. -1: use nsubset, 0: all queries
    process the same subset
)r   knn_L2sqr_by_idx)rE   rG  r  r  rw  re  r  rQ  r  r  	ld_subsets              r   r  r    s       &&qVDW`aar$   c           
      4    [         R                  " XX#XEXg5      $ )ax  
 Return the k nearest neighbors of each of the nx vectors x among the ny
 vector y, w.r.t to max inner product

:type x: float
:param x:      query vectors, size nx * d
:type y: float
:param y:      database vectors, size ny * d
:type radius: float
:param radius: search radius around the x vectors
:type result: :py:class:`RangeSearchResult`
:param result: result structure
)r   range_search_L2sqrrE   rG  r  rw  re  rW  rX  rT  s           r   r  r    s     ((qb&NNr$   c           
      4    [         R                  " XX#XEXg5      $ )z;same as range_search_L2sqr for the inner product similarity)r   range_search_inner_productr  s           r   r  r    s    00qb&VVr$   c           	      4    [         R                  " XX#XEU5      $ )zspecialized function for PQ2)r   compute_PQ_dis_tables_dsub2)r  ksub	centroidsrw  rE   is_inner_product
dis_tabless          r   r  r    s    11!9!_ijjr$   c                 2    [         R                  " XX#U5      $ )z
 compute c := a + bf * b for a, b and c tables

:type n: int
:param n:   size of the tables
:type a: float
:param a:   size n
:type b: float
:param b:   size n
:type c: float
:param c:   result table, size n
)r   	fvec_maddra   r  bfr  r  s        r   r  r    s     bQ//r$   c                 2    [         R                  " XX#U5      $ )zw
 same as fvec_madd, also return index of the min of the result table
:rtype: int
:return: index of the min of table c
)r   fvec_madd_and_argminr  s        r   r  r    s     **1::r$   c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS rS	 rS
 rSS jr\	R$                  rSrg)RandomGeneratori  z;random generator that can be used in multithreaded contextsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   RandomGenerator.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 .    [         R                  " U 5      $ zrandom int64_t)r   RandomGenerator_rand_int64r[   s    r   
rand_int64RandomGenerator.rand_int64      44T::r$   c                 0    [         R                  " U /UQ76 $ ze
*Overload 1:*
random positive integer

|

*Overload 2:*
generate random integer between 0 and max-1
)r   RandomGenerator_rand_intr   s     r   rand_intRandomGenerator.rand_int  s     224?$??r$   c                 .    [         R                  " U 5      $ zbetween 0 and 1)r   RandomGenerator_rand_floatr[   s    r   
rand_floatRandomGenerator.rand_float  r  r$   c                 .    [         R                  " U 5      $ r/   )r   RandomGenerator_rand_doubler[   s    r   rand_doubleRandomGenerator.rand_double  r  r$   c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   RandomGenerator_swiginitnew_RandomGeneratorr   r  s     r   rV   RandomGenerator.__init__   s    ++D*2P2PQU2VWr$   r%   N  )r   r   r:   r;   r<   r   r   r   r   r   RandomGenerator_mt_getRandomGenerator_mt_setmtr  r  r  r  rV   delete_RandomGeneratorr   r>   r%   r$   r   r  r    sZ    F-/IOdeGH	*33Z5V5V	WB;
@;<X!88r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS rS	 rS
 rSS jrS r\	R&                  rSrg)SplitMix64RandomGeneratori  zi
fast random generator that cannot be used in multithreaded contexts.
based on https://prng.di.unimi.it/
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   "SplitMix64RandomGenerator.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 .    [         R                  " U 5      $ r  )r   $SplitMix64RandomGenerator_rand_int64r[   s    r   r  $SplitMix64RandomGenerator.rand_int64      >>tDDr$   c                 0    [         R                  " U /UQ76 $ r  )r   "SplitMix64RandomGenerator_rand_intr   s     r   r  "SplitMix64RandomGenerator.rand_int  s     <<TIDIIr$   c                 .    [         R                  " U 5      $ r  )r   $SplitMix64RandomGenerator_rand_floatr[   s    r   r  $SplitMix64RandomGenerator.rand_float   r  r$   c                 .    [         R                  " U 5      $ r/   )r   %SplitMix64RandomGenerator_rand_doubler[   s    r   r  %SplitMix64RandomGenerator.rand_double$      ??EEr$   c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   "SplitMix64RandomGenerator_swiginitnew_SplitMix64RandomGeneratorr  s     r   rV   "SplitMix64RandomGenerator.__init__'  s    55dJ<d<dei<jkr$   c                 .    [         R                  " U 5      $ r/   )r   SplitMix64RandomGenerator_nextr[   s    r   rz   SplitMix64RandomGenerator.next*      88>>r$   r%   Nr  )r   r   r:   r;   r<   r   r   r   r   r   #SplitMix64RandomGenerator_state_get#SplitMix64RandomGenerator_state_setstater  r  r  r  rV   rz    delete_SplitMix64RandomGeneratorr   r>   r%   r$   r   r  r    sf    
 -/IOdeGHZCCZEsEstEE
JEFl?!BBr$   r  c                 0    [         R                  " XU5      $ r/   )r   
float_randrE   ra   r  s      r   r  r  1        t,,r$   c                 0    [         R                  " XU5      $ r/   )r   float_randnr  s      r   r  r  4  s    !!!--r$   c                 0    [         R                  " XU5      $ r/   )r   
int64_randr  s      r   r  r  7  r  r$   c                 0    [         R                  " XU5      $ r/   )r   	byte_randr  s      r   r  r  :  s    d++r$   c                 0    [         R                  " XX#5      $ r/   )r   int64_rand_max)rE   ra   maxr  s       r   r  r  =  s    $$Q355r$   c                 0    [         R                  " XU5      $ r/   )r   	rand_permpermra   r  s      r   r   r   @  s    ..r$   c                 0    [         R                  " XU5      $ r/   )r   rand_perm_splitmix64r  s      r   r  r  C  s    **4D99r$   c                 0    [         R                  " XX#5      $ r/   )r   rand_smooth_vectors)ra   r  rE   r  s       r   r  r  F  s    ))!88r$   c                 0    [         R                  " XU5      $ )a  
 Indirect sort of a floating-point array

:type n: int
:param n:     size of the array
:type vals: float
:param vals:  array to sort, size n
:type perm: int
:param perm:  output: permutation of [0..n-1], st.
                 vals[perm[i + 1]] >= vals[perm[i]]
)r   fvec_argsortra   r  r  s      r   r  r  I  s     ""1D11r$   c                 0    [         R                  " XU5      $ )z"Same as fvec_argsort, parallelized)r   fvec_argsort_parallelr	  s      r   r  r  W  s    ++AT::r$   c                 2    [         R                  " XX#XE5      $ )a  
 Bucket sort of a list of values

:type vals: int
:param vals:     values to sort, size nval, max value nbucket - 1
:type lims: int
:param lims:     output limits of buckets, size nbucket + 1
:type perm: int
:param perm:     output buckets, the elements of bucket
                    i are in perm[lims[i]:lims[i + 1]]
:type nt: int, optional
:param nt:       number of threads (0 = pure sequential code)
)r   bucket_sort)nvalr  nbucketlimsr  nts         r   r  r  [  s     !!$gTFFr$   c                  (    [         R                  " U 6 $ )a  
*Overload 1:*
 in-place bucket sort (with attention to memory=>int32)
on input the values are in a nrow * col matrix
we want to store the row numbers in the output.

:type vals: int
:param vals:     positive values to sort, size nrow * ncol,
                    max value nbucket - 1
:type lims: int
:param lims:     output limits of buckets, size nbucket + 1
:type nt: int, optional
:param nt:       number of threads (0 = pure sequential code)

|

*Overload 2:*
 same with int64 elements

|

*Overload 3:*
 same with int64 elements
)r   matrix_bucket_sort_inplacerI  s    r   r  r  k  s    2 00$77r$   c                 .    [         R                  " X5      $ )aj  
 Hashtable implementation for int64 -> int64 with external storage
implemented for fast batch add and lookup.

tab is of size  2 * (1 << log2_capacity)
n is the number of elements to add or search

adding several values in a same batch: an arbitrary one gets added
in different batches: the newer batch overwrites.
raises an exception if capacity is exhausted.
)r   hashtable_int64_to_int64_init)log2_capacitytabs     r   r  r    s     33MGGr$   c                 2    [         R                  " XX#U5      $ r/   )r   hashtable_int64_to_int64_addr  r  ra   keysr  s        r   r  r    s    22=qPTUUr$   c                 2    [         R                  " XX#U5      $ r/   )r   hashtable_int64_to_int64_lookupr  s        r   r  r    s    55m!SWXXr$   c                 .    [         R                  " U 5      $ )z
this function is used to distinguish between min and max indexes since
we need to support similarity and dis-similarity metrics in a flexible way
)r   is_similarity_metric)metric_types    r   r  r    s    
 **;77r$   c                 .    [         R                  " U 5      $ r/   )r   get_numeric_type_size)numeric_types    r   r"  r"    s    ++L99r$   c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\	R                  rS rS	rg
)SearchParametersi  z
 Parent class for the optional search parameters.

Sub-classes with additional search parameters should inherit this class.
Ownership of the object fields is always to the caller.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   SearchParameters.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r'    rL   r$   rM   rN   z=if non-null, only these IDs will be considered during search.c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   SearchParameters_swiginitnew_SearchParametersr[   s    r   rV   SearchParameters.__init__      ,,T:3R3R3TUr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   SearchParameters_sel_getSearchParameters_sel_setrT  delete_SearchParametersr   rV   r>   r%   r$   r   r%  r%    sS     -/IOdeGH
:66
8[8[  bf  gC!99Vr$   r%  c                   L   \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  SS9r\" \
R                  \
R                  S	S9r\" \
R"                  \
R$                  S
S9r\" \
R(                  \
R*                  SS9r\" \
R.                  \
R0                  SS9r\" \
R4                  \
R6                  SS9r\
R:                  rS rS r S r!S r"S r#S r$S)S jr%S)S jr&S)S jr'S*S jr(S r)S r*S r+S r,S r-S)S jr.S r/S  r0S! r1S" r2S# r3S$ r4S+S% jr5S& r6S' r7S(r8g),Indexi  z
 Abstract structure for an index, supports adding vectors and searching
them.

All vectors provided at add or search time are 32-bit float arrays,
although the internal representation may vary.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Index.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r4    rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   Index.__init__  rX   r$   vector dimensiontotal nb of indexed vectorsverbosity levelzX
    set if the Index does not require training, or if training is
    done already
    )type of metric this index uses for searchzargument of the metric typec                 0    [         R                  " XU5      $ )z
 Perform training on a representative set of vectors

:type n: int
:param n:      nb of training vectors
:type x: float
:param x:      training vectors, size n * d
)r   Index_trainr   ra   rE   s      r   trainIndex.train  s     %%dq11r$   c                 0    [         R                  " XX#5      $ r/   )r   Index_train_exr   ra   rE   r#  s       r   train_exIndex.train_ex  s    ((!BBr$   c                 0    [         R                  " XU5      $ )a3  
 Add n vectors of dimension d to the index.

Vectors are implicitly assigned labels ntotal .. ntotal + n - 1
This function slices the input vectors in chunks smaller than
blocksize_add and calls add_core.
:type n: int
:param n:      number of vectors
:type x: float
:param x:      input matrix, size n * d
)r   	Index_addr>  s      r   add	Index.add  s     ##DQ//r$   c                 0    [         R                  " XX#5      $ r/   )r   Index_add_exrC  s       r   add_exIndex.add_ex  s    &&t@@r$   c                 0    [         R                  " XX#5      $ )aX  
 Same as add, but stores xids instead of sequential ids.

The default implementation fails with an assertion, as it is
not supported by all indexes.

:type n: int
:param n:         number of vectors
:type x: float
:param x:         input vectors, size n * d
:type xids: int
:param xids:      if non-null, ids to store for the vectors (size n)
)r   Index_add_with_idsr   ra   rE   xidss       r   add_with_idsIndex.add_with_ids  s     ,,Ta>>r$   c                 2    [         R                  " XX#U5      $ r/   )r   Index_add_with_ids_exr   ra   rE   r#  rQ  s        r   add_with_ids_exIndex.add_with_ids_ex  s    //$OOr$   Nc           	      4    [         R                  " XX#XEU5      $ )a  
 query n vectors of dimension d to the index.

return at most k vectors. If there are not enough results for a
query, the result array is padded with -1s.

:type n: int
:param n:           number of vectors
:type x: float
:param x:           input vectors to search, size n * d
:type k: int
:param k:           number of extracted vectors
:type distances: float
:param distances:   output pairwise distances, size n*k
:type labels: int
:param labels:      output labels of the NNs, size n*k
)r   Index_searchr   ra   rE   rQ  rR  rS  paramss          r   searchIndex.search"  s    $ &&tiPPr$   c           
      4    [         R                  " XX#XEXg5      $ r/   )r   Index_search_exr   ra   rE   r#  rQ  rR  rS  r\  s           r   	search_exIndex.search_ex6  s    ))$1ARXaar$   c                 2    [         R                  " XX#XE5      $ )a  
 query n vectors of dimension d to the index.

return all vectors with distance < radius. Note that many
indexes do not implement the range_search (only the k-NN search
is mandatory).

:type n: int
:param n:           number of vectors
:type x: float
:param x:           input vectors to search, size n * d
:type radius: float
:param radius:      search radius
:type result: :py:class:`RangeSearchResult`
:param result:      result table
)r   Index_range_searchr   ra   rE   rW  rX  r\  s         r   range_searchIndex.range_search9  s    " ,,TaPPr$   c                 2    [         R                  " XX#U5      $ )a  
 return the indexes of the k vectors closest to the query x.

This function is identical as search but only return labels of
neighbors.
:type n: int
:param n:           number of vectors
:type x: float
:param x:           input vectors to search, size n * d
:type labels: int
:param labels:      output labels of the NNs, size n*k
:type k: int, optional
:param k:           number of nearest neighbours
)r   Index_assignr   ra   rE   rS  rQ  s        r   assignIndex.assignL  s     &&t1==r$   c                 .    [         R                  " U 5      $ )z'removes all elements from the database.)r   Index_resetr[   s    r   r  Index.reset]  s    %%d++r$   c                 .    [         R                  " X5      $ )zd
 removes IDs from the index. Not supported by all
indexes. Returns the number of elements removed.
)r   Index_remove_idsr   rT  s     r   
remove_idsIndex.remove_idsa  s    
 **455r$   c                 0    [         R                  " XU5      $ )a   
 Reconstruct a stored vector (or an approximation if lossy coding)

this function may not be defined for some indexes
:type key: int
:param key:         id of the vector to reconstruct
:type recons: float
:param recons:      reconstructed vector (size d)
)r   Index_reconstructr   keyreconss      r   reconstructIndex.reconstructh  s     ++Dv>>r$   c                 0    [         R                  " XX#5      $ )aY  
 Reconstruct several stored vectors (or an approximation if lossy
coding)

this function may not be defined for some indexes
:type n: int
:param n:           number of vectors to reconstruct
:type keys: int
:param keys:        ids of the vectors to reconstruct (size n)
:type recons: float
:param recons:      reconstructed vector (size n * d)
)r   Index_reconstruct_batch)r   ra   r  rz  s       r   reconstruct_batchIndex.reconstruct_batcht  s     11$4HHr$   c                 0    [         R                  " XX#5      $ )a6  
 Reconstruct vectors i0 to i0 + ni - 1

this function may not be defined for some indexes
:type i0: int
:param i0:          index of the first vector in the sequence
:type ni: int
:param ni:          number of vectors in the sequence
:type recons: float
:param recons:      reconstructed vector (size ni * d)
)r   Index_reconstruct_nr   i0nirz  s       r   reconstruct_nIndex.reconstruct_n  s     --dCCr$   c           
      4    [         R                  " XX#XEXg5      $ )a|  
 Similar to search, but also reconstructs the stored vectors (or an
approximation in the case of lossy coding) for the search results.

If there are not enough results for a query, the resulting arrays
is padded with -1s.

:type n: int
:param n:           number of vectors
:type x: float
:param x:           input vectors to search, size n * d
:type k: int
:param k:           number of extracted vectors
:type distances: float
:param distances:   output pairwise distances, size n*k
:type labels: int
:param labels:      output labels of the NNs, size n*k
:type recons: float
:param recons:      reconstructed vectors size (n, k, d)
)r   Index_search_and_reconstructr   ra   rE   rQ  rR  rS  rz  r\  s           r   search_and_reconstructIndex.search_and_reconstruct  s    * 66tiY_hhr$   c                 0    [         R                  " XX#5      $ )a  
 Computes a residual vector after indexing encoding.

The residual vector is the difference between a vector and the
reconstruction that can be decoded from its representation in
the index. The residual can be used for multiple-stage indexing
methods, like IndexIVF's methods.

:type x: float
:param x:           input vector, size d
:type residual: float
:param residual:    output residual vector, size d
:type key: int
:param key:         encoded index, as returned by search and assign
)r   Index_compute_residual)r   rE   residualry  s       r   compute_residualIndex.compute_residual  s      00(HHr$   c                 2    [         R                  " XX#U5      $ )at  
 Computes a residual vector after indexing encoding (batch form).
Equivalent to calling compute_residual for each vector.

The residual vector is the difference between a vector and the
reconstruction that can be decoded from its representation in
the index. The residual can be used for multiple-stage indexing
methods, like IndexIVF's methods.

:type n: int
:param n:           number of vectors
:type xs: float
:param xs:          input vectors, size (n x d)
:type residuals: float
:param residuals:   output residual vectors, size (n x d)
:type keys: int
:param keys:        encoded index, as returned by search and assign
)r   Index_compute_residual_n)r   ra   xs	residualsr  s        r   compute_residual_nIndex.compute_residual_n  s    & 224B4PPr$   c                 .    [         R                  " U 5      $ )z
 Get a DistanceComputer (defined in AuxIndexStructures) object
for this kind of index.

DistanceComputer is implemented for indexes that support random
access of their vectors.
)r   Index_get_distance_computerr[   s    r   get_distance_computerIndex.get_distance_computer  s     55d;;r$   c                 .    [         R                  " U 5      $ z#size of the produced codes in bytes)r   Index_sa_code_sizer[   s    r   sa_code_sizeIndex.sa_code_size  s    ,,T22r$   c                 0    [         R                  " XX#5      $ )z
 encode a set of vectors

:type n: int
:param n:       number of vectors
:type x: float
:param x:       input vectors, size n * d
:type bytes: uint8_t
:param bytes:   output encoded vectors, size n * sa_code_size()
)r   Index_sa_encoder   ra   rE   r  s       r   	sa_encodeIndex.sa_encode  s     ))$1<<r$   c                 0    [         R                  " XX#5      $ )z
 decode a set of vectors

:type n: int
:param n:       number of vectors
:type bytes: uint8_t
:param bytes:   input encoded vectors, size n * sa_code_size()
:type x: float
:param x:       output vectors, size n * d
)r   Index_sa_decoder   ra   r  rE   s       r   	sa_decodeIndex.sa_decode  s     ))$5<<r$   c                 0    [         R                  " XU5      $ z
 moves the entries from another dataset to self.
On output, other is empty.
add_id is added to all moved ids
(for sequential ids, this would be this->ntotal)
)r   Index_merge_fromr   
otherIndexadd_ids      r   
merge_fromIndex.merge_from  s     **4VDDr$   c                 .    [         R                  " X5      $ z
 check that the two indexes are compatible (ie, they are
trained in the same way and have the same
parameters). Otherwise throw.
)r    Index_check_compatible_for_merger   r  s     r   check_compatible_for_merge Index.check_compatible_for_merge 	  s     ::4LLr$   c                 0    [         R                  " XX#5      $ z
 Add vectors that are computed with the standalone codec

:type codes: uint8_t
:param codes:  codes to add size n * sa_code_size()
:type xids: int
:param xids:   corresponding ids, size n
)r   Index_add_sa_codesr   ra   r  rQ  s       r   add_sa_codesIndex.add_sa_codes	  s     ,,TeBBr$   r%   r/   r   r   )9r   r   r:   r;   r<   r   r   rV   r   r   r   Index_d_getIndex_d_setr  Index_ntotal_getIndex_ntotal_setntotalIndex_verbose_getIndex_verbose_setr  Index_is_trained_getIndex_is_trained_set
is_trainedIndex_metric_type_getIndex_metric_type_setr   Index_metric_arg_getIndex_metric_arg_set
metric_argdelete_Indexr   r?  rD  rH  rL  rR  rW  r]  rb  rg  rl  r  rt  r{  r  r  r  r  r  r  r  r  r  r  r  r  r>   r%   r$   r   r2  r2    ss    -/IOdeGKH'')?)?E\]Aj11:3N3NTvwFz33Z5Q5QWmnG*99:;Z;Z a 	J :;;Z=]=]  dT  UK*99:;Z;Z  aC  DJ!..	2C0A? PQ(bQ&>",6
?IDi.I$Q*<3==EM	Cr$   r2  c                   b    \ rS rSr\" S S SS9rS r\rS r	S r
S	 rS
 r\R                  rSrg)DistanceComputeri	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   DistanceComputer.<lambda>	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  	  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   DistanceComputer.__init__	  rX   r$   c                 .    [         R                  " X5      $ )z^
called before computing distances. Pointer x should remain valid
while operator () is called
)r   DistanceComputer_set_queryrk   s     r   	set_queryDistanceComputer.set_query	  s    
 44T==r$   c                 .    [         R                  " X5      $ z-compute distance of vector i to current query)r   DistanceComputer___call__r   r+  s     r   __call__DistanceComputer.__call__#	  s    33D<<r$   c	                 6    [         R                  " XX#XEXgU5	      $ )z
compute distances of current query to 4 stored vectors.
certain DistanceComputer implementations may benefit
heavily from this.
)r   "DistanceComputer_distances_batch_4	r   idx0idx1idx2idx3rU  rV  rW  rX  s	            r   distances_batch_4"DistanceComputer.distances_batch_4'	  s      <<TUYaemqrrr$   c                 0    [         R                  " XU5      $ z+compute distance between two stored vectors)r   DistanceComputer_symmetric_disr   r+  js      r   symmetric_disDistanceComputer.symmetric_dis/	      88!DDr$   r%   N)r   r   r:   r;   r   r   rV   r   r   r  r  r  r  r   delete_DistanceComputerr   r>   r%   r$   r   r  r  	  sB    -/IOdeGKH>=sE "99r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9rS rS rS	 rS
 rS r\R"                  rSrg)NegativeDistanceComputeri6	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   !NegativeDistanceComputer.<lambda>7	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  7	  rL   r$   rM   rN   zowned by thisc                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   !NegativeDistanceComputer_swiginitnew_NegativeDistanceComputer)r   basediss     r   rV   !NegativeDistanceComputer.__init__;	  s    44T:;b;bcj;klr$   c                 .    [         R                  " X5      $ r/   )r   "NegativeDistanceComputer_set_queryrk   s     r   r  "NegativeDistanceComputer.set_query>	  r}  r$   c                 .    [         R                  " X5      $ r  )r   !NegativeDistanceComputer___call__r  s     r   r  !NegativeDistanceComputer.__call__A	  s    ;;DDDr$   c	                 6    [         R                  " XX#XEXgU5	      $ r/   )r   *NegativeDistanceComputer_distances_batch_4r  s	            r   r  *NegativeDistanceComputer.distances_batch_4E	  s    DDTQU]aimuyzzr$   c                 0    [         R                  " XU5      $ r  )r   &NegativeDistanceComputer_symmetric_disr  s      r   r  &NegativeDistanceComputer.symmetric_disH	  s    @@!LLr$   r%   N)r   r   r:   r;   r   r   r   r   r   $NegativeDistanceComputer_basedis_get$NegativeDistanceComputer_basedis_setr  rV   r  r  r  r  delete_NegativeDistanceComputerr   r>   r%   r$   r   r  r  6	  sf    -/IOdeGHzFF
HwHw  ~R  SGmFE{M "AAr$   r  c                       \ rS rSr\" S S SS9rS r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS r\	R$                  rS	rg
)FlatCodesDistanceComputeriO	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   "FlatCodesDistanceComputer.<lambda>P	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  P	  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   "FlatCodesDistanceComputer.__init__R	  rX   r$   c                 .    [         R                  " X5      $ r/   )r   "FlatCodesDistanceComputer___call__r  s     r   r  "FlatCodesDistanceComputer.__call__X	  r}  r$   c                 .    [         R                  " X5      $ )z6compute distance of current query to an encoded vector)r   *FlatCodesDistanceComputer_distance_to_coder   r  s     r   distance_to_code*FlatCodesDistanceComputer.distance_to_code[	      DDTPPr$   r%   N)r   r   r:   r;   r   r   rV   r   r   r   #FlatCodesDistanceComputer_codes_get#FlatCodesDistanceComputer_codes_setr  'FlatCodesDistanceComputer_code_size_get'FlatCodesDistanceComputer_code_size_setr  r  r   delete_FlatCodesDistanceComputerr   r>   r%   r$   r   r  r  O	  sk    -/IOdeGKHZCCZEsEstEKKZMM  AIFQ "BBr$   r  c                       \ rS rSr\" S S SS9rS r\r\" \	R                  \	R                  5      rS rS r\	R                  rS	rg
)IOReaderib	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IOReader.<lambda>c	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r$  c	  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   IOReader.__init__e	  rX   r$   c                 0    [         R                  " XX#5      $ r/   )r   IOReader___call__r   ptrr   nitemss       r   r  IOReader.__call__j	      ++DtDDr$   c                 .    [         R                  " U 5      $ r/   )r   IOReader_filedescriptorr[   s    r   filedescriptorIOReader.filedescriptorm	  r   r$   r%   N)r   r   r:   r;   r   r   rV   r   r   r   IOReader_name_getIOReader_name_setr   r  r1  delete_IOReaderr   r>   r%   r$   r   r"  r"  b	  M    -/IOdeGKHJ00*2N2NODE8!11r$   r"  c                       \ rS rSr\" S S SS9rS r\r\" \	R                  \	R                  5      rS rS r\	R                  rS	rg
)IOWriteris	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IOWriter.<lambda>t	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r:  t	  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   IOWriter.__init__v	  rX   r$   c                 0    [         R                  " XX#5      $ r/   )r   IOWriter___call__r*  s       r   r  IOWriter.__call__{	  r.  r$   c                 .    [         R                  " U 5      $ r/   )r   IOWriter_filedescriptorr[   s    r   r1  IOWriter.filedescriptor~	  r   r$   r%   N)r   r   r:   r;   r   r   rV   r   r   r   IOWriter_name_getIOWriter_name_setr   r  r1  delete_IOWriterr   r>   r%   r$   r   r8  r8  s	  r6  r$   r8  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS rS r\R"                  rSrg	)
VectorIOReaderi	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   VectorIOReader.<lambda>	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rJ  	  rL   r$   rM   rN   c                 0    [         R                  " XX#5      $ r/   )r   VectorIOReader___call__r*  s       r   r  VectorIOReader.__call__	      11$TJJr$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   VectorIOReader_swiginitnew_VectorIOReaderr[   s    r   rV   VectorIOReader.__init__	  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   VectorIOReader_data_getVectorIOReader_data_setr   VectorIOReader_rp_getVectorIOReader_rp_setrpr  rV   delete_VectorIOReaderr   r>   r%   r$   r   rH  rH  	  s`    -/IOdeGHJ66
8Z8Z[D	*22J4T4T	UBKR!77r$   rH  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS rS r\R                  rSrg	)
VectorIOWriteri	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   VectorIOWriter.<lambda>	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r]  	  rL   r$   rM   rN   c                 0    [         R                  " XX#5      $ r/   )r   VectorIOWriter___call__r*  s       r   r  VectorIOWriter.__call__	  rO  r$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   VectorIOWriter_swiginitnew_VectorIOWriterr[   s    r   rV   VectorIOWriter.__init__	  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   VectorIOWriter_data_getVectorIOWriter_data_setr   r  rV   delete_VectorIOWriterr   r>   r%   r$   r   r[  r[  	  sH    -/IOdeGHJ66
8Z8Z[DKR!77r$   r[  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS r\R                   rS rS rS	rg
)FileIOReaderi	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   FileIOReader.<lambda>	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rl  	  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   FileIOReader_swiginitnew_FileIOReaderr   s     r   rV   FileIOReader.__init__	      ((z/J/JD/QRr$   c                 0    [         R                  " XX#5      $ r/   )r   FileIOReader___call__r*  s       r   r  FileIOReader.__call__	      //4HHr$   c                 .    [         R                  " U 5      $ r/   )r   FileIOReader_filedescriptorr[   s    r   r1  FileIOReader.filedescriptor	  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   FileIOReader_f_getFileIOReader_f_setfFileIOReader_need_close_getFileIOReader_need_close_set
need_closerV   delete_FileIOReaderr   r  r1  r>   r%   r$   r   rj  rj  	  e    -/IOdeGH..
0M0MNA*@@*BhBhiJS!55I<r$   rj  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS r\R                   rS rS rS	rg
)FileIOWriteri	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   FileIOWriter.<lambda>	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  	  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   FileIOWriter_swiginitnew_FileIOWriterr   s     r   rV   FileIOWriter.__init__	  rr  r$   c                 0    [         R                  " XX#5      $ r/   )r   FileIOWriter___call__r*  s       r   r  FileIOWriter.__call__	  rv  r$   c                 .    [         R                  " U 5      $ r/   )r   FileIOWriter_filedescriptorr[   s    r   r1  FileIOWriter.filedescriptor	  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   FileIOWriter_f_getFileIOWriter_f_setr|  FileIOWriter_need_close_getFileIOWriter_need_close_setr  rV   delete_FileIOWriterr   r  r1  r>   r%   r$   r   r  r  	  r  r$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  SS9r\" \	R&                  \	R(                  SS9r\" \	R,                  \	R.                  S	S9r\" \	R2                  \	R4                  5      r\" \	R8                  \	R:                  5      rS
 rS r \	RB                  r"Sr#g)BufferedIOReaderi	  zAwraps an ioreader to make buffered reads to avoid too small readsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   BufferedIOReader.<lambda>	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  	  rL   r$   rM   rN   zoffset in input streamz"number of bytes returned to callerz&range of available bytes in the bufferc                 T    [         R                  " U [         R                  " U6 5        g)z{
:type bsz: int, optional
:param bsz:    buffer size (bytes). Reads will be done by batched of
                  this size
N)r   BufferedIOReader_swiginitnew_BufferedIOReaderr   s     r   rV   BufferedIOReader.__init__	  s      	,,T:3R3RTX3YZr$   c                 0    [         R                  " XX#5      $ r/   )r   BufferedIOReader___call__r*  s       r   r  BufferedIOReader.__call__	      33DtLLr$   r%   N)$r   r   r:   r;   r<   r   r   r   r   r   BufferedIOReader_reader_getBufferedIOReader_reader_setreaderBufferedIOReader_bsz_getBufferedIOReader_bsz_setbszBufferedIOReader_ofs_getBufferedIOReader_ofs_setofsBufferedIOReader_ofs2_getBufferedIOReader_ofs2_setofs2BufferedIOReader_b0_getBufferedIOReader_b0_setb0BufferedIOReader_b1_getBufferedIOReader_b1_setb1BufferedIOReader_buffer_getBufferedIOReader_buffer_setbufferrV   r  delete_BufferedIOReaderr   r>   r%   r$   r   r  r  	  s    L-/IOdeGHj<<j>d>deF
:66
8[8[
\C
:66
8[8[a~
CJ88*:^:^  eN  OD	*44j6X6X  _L  
MB	*44j6X6X	YBj<<j>d>deF[M!99r$   r  c                      \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  SS9r\" \R*                  \R,                  SS9r\" \R0                  \R2                  5      rS rS	 r\R:                  rS
rg)BufferedIOWriteri	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   BufferedIOWriter.<lambda>	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  	  rL   r$   rM   rN   z$number of bytes received from callerzamount of data in bufferc                 T    [         R                  " U [         R                  " U6 5        g r/   )r   BufferedIOWriter_swiginitnew_BufferedIOWriterr   s     r   rV   BufferedIOWriter.__init__	      ,,T:3R3RTX3YZr$   c                 0    [         R                  " XX#5      $ r/   )r   BufferedIOWriter___call__r*  s       r   r  BufferedIOWriter.__call__	  r  r$   r%   N) r   r   r:   r;   r   r   r   r   r   BufferedIOWriter_writer_getBufferedIOWriter_writer_setwriterBufferedIOWriter_bsz_getBufferedIOWriter_bsz_setr  BufferedIOWriter_ofs_getBufferedIOWriter_ofs_setr  BufferedIOWriter_ofs2_getBufferedIOWriter_ofs2_setr  BufferedIOWriter_b0_getBufferedIOWriter_b0_setr  BufferedIOWriter_buffer_getBufferedIOWriter_buffer_setr  rV   r  delete_BufferedIOWriterr   r>   r%   r$   r   r  r  	  s    -/IOdeGHj<<j>d>deF
:66
8[8[
\C
:66
8[8[
\CJ88*:^:^  eP  QD	*44j6X6X^}	~Bj<<j>d>deF[M!99r$   r  c                  (    [         R                  " U 6 $ )zKcast a 4-character string to a uint32_t that can be written and read easily)r   fourccrI  s    r   r  r  	  s    d##r$   c                  (    [         R                  " U 6 $ r/   )r   
fourcc_invrI  s    r   r  r  	        $''r$   c                 .    [         R                  " U 5      $ r/   )r   fourcc_inv_printablerD   s    r   r  r  	  s    **1--r$   c                   J    \ rS rSr\" S S SS9r\r\R                  r
S rSrg)	MaybeOwnedVectorOwneri	  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   MaybeOwnedVectorOwner.<lambda>	  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  	  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   MaybeOwnedVectorOwner_swiginitnew_MaybeOwnedVectorOwnerr[   s    r   rV   MaybeOwnedVectorOwner.__init__
  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   delete_MaybeOwnedVectorOwnerr   rV   r>   r%   r$   r   r  r  	  s*    -/IOdeGH!>>`r$   r  c                   V    \ rS rSr\" S S SS9r\rS r\	R                  rS rS rS	rg
)MmappedFileMappingOwneri
  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF    MmappedFileMappingOwner.<lambda>
  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  
  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r    MmappedFileMappingOwner_swiginitnew_MmappedFileMappingOwnerr   s     r   rV    MmappedFileMappingOwner.__init__
      33D*:`:`bf:ghr$   c                 .    [         R                  " U 5      $ r/   )r   MmappedFileMappingOwner_datar[   s    r   r   MmappedFileMappingOwner.data
  r  r$   c                 .    [         R                  " U 5      $ r/   )r   MmappedFileMappingOwner_sizer[   s    r   r   MmappedFileMappingOwner.size
  r  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   delete_MmappedFileMappingOwnerr   r   r   r>   r%   r$   r   r  r  
  s4    -/IOdeGHi!@@==r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS rS rS rS	 r\R&                  rS
rg)MappedFileIOReaderi
  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   MappedFileIOReader.<lambda>
  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  
  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   MappedFileIOReader_swiginitnew_MappedFileIOReader)r   owners     r   rV   MappedFileIOReader.__init__
  s    ..tZ5V5VW\5]^r$   c                 0    [         R                  " XX#5      $ r/   )r   MappedFileIOReader___call__r*  s       r   r  MappedFileIOReader.__call__ 
  s    55dNNr$   c                 0    [         R                  " XX#5      $ r/   )r   MappedFileIOReader_mmapr*  s       r   mmapMappedFileIOReader.mmap#
  rO  r$   c                 .    [         R                  " U 5      $ r/   )r   !MappedFileIOReader_filedescriptorr[   s    r   r1  !MappedFileIOReader.filedescriptor&
  rn  r$   r%   N)r   r   r:   r;   r   r   r   r   r   !MappedFileIOReader_mmap_owner_get!MappedFileIOReader_mmap_owner_set
mmap_ownerMappedFileIOReader_pos_getMappedFileIOReader_pos_setposrV   r  r  r1  delete_MappedFileIOReaderr   r>   r%   r$   r   r  r  
  sl    -/IOdeGH*FF
HtHtuJ
:88*:_:_
`C_OKB!;;r$   r  c                      \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      rS r\R&                  rS rS rS	 rS
 rSrg)ZeroCopyIOReaderi,
  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ZeroCopyIOReader.<lambda>-
  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  -
  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   ZeroCopyIOReader_swiginitnew_ZeroCopyIOReader)r   r   r   s      r   rV   ZeroCopyIOReader.__init__3
  s    ,,T:3R3RSW3^_r$   c                 .    [         R                  " U 5      $ r/   )r   ZeroCopyIOReader_resetr[   s    r   r  ZeroCopyIOReader.reset7
  rB  r$   c                 0    [         R                  " XX#5      $ r/   )r   ZeroCopyIOReader_get_data_viewr*  s       r   get_data_viewZeroCopyIOReader.get_data_view:
  s    88DQQr$   c                 0    [         R                  " XX#5      $ r/   )r   ZeroCopyIOReader___call__r*  s       r   r  ZeroCopyIOReader.__call__=
  r  r$   c                 .    [         R                  " U 5      $ r/   )r   ZeroCopyIOReader_filedescriptorr[   s    r   r1  ZeroCopyIOReader.filedescriptor@
      99$??r$   r%   N)r   r   r:   r;   r   r   r   r   r   ZeroCopyIOReader_data__getZeroCopyIOReader_data__setdata_ZeroCopyIOReader_rp__getZeroCopyIOReader_rp__setrp_ZeroCopyIOReader_total__getZeroCopyIOReader_total__settotal_rV   delete_ZeroCopyIOReaderr   r  r  r  r1  r>   r%   r$   r   r  r  ,
  s    -/IOdeGHZ::J<a<abE
:66
8[8[
\Cj<<j>d>deF`!997RM@r$   r  c                   &   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9rS rS	 rS
 rS rS rS rS rS rS rSS jrSS jrS rS rSS jrS rS r\	R@                  r!Sr"g)IndexFlatCodesiE
  zf
 Index that encodes all vectors as fixed-size codes (size code_size). Storage
is in the codes vector
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexFlatCodes.<lambda>K
  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r5  K
  rL   r$   rM   rN   z(encoded dataset, size ntotal * code_sizec                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexFlatCodes_swiginitnew_IndexFlatCodesr   s     r   rV   IndexFlatCodes.__init__P
      **41N1NPT1UVr$   c                 0    [         R                  " XU5      $ )zdefault add uses sa_encode)r   IndexFlatCodes_addr>  s      r   rH  IndexFlatCodes.addS
  s    ,,Ta88r$   c                 .    [         R                  " U 5      $ r/   )r   IndexFlatCodes_resetr[   s    r   r  IndexFlatCodes.resetW
  r]   r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexFlatCodes_reconstruct_nr  s       r   r  IndexFlatCodes.reconstruct_nZ
  s    66tLLr$   c                 0    [         R                  " XU5      $ r/   )r   IndexFlatCodes_reconstructrx  s      r   r{  IndexFlatCodes.reconstruct]
      44TGGr$   c                 .    [         R                  " U 5      $ r/   )r   IndexFlatCodes_sa_code_sizer[   s    r   r  IndexFlatCodes.sa_code_size`
  r  r$   c                 .    [         R                  " X5      $ )z
 remove some ids. NB that because of the structure of the
index, the semantics of this operation are
different from the usual ones: the new ids are shifted
)r   IndexFlatCodes_remove_idsrs  s     r   rt  IndexFlatCodes.remove_idsc
  s     33D>>r$   c                 .    [         R                  " U 5      $ )z
 a FlatCodesDistanceComputer offers a distance_to_code method

The default implementation explicitly decodes the vector with sa_decode.
)r   ,IndexFlatCodes_get_FlatCodesDistanceComputerr[   s    r   get_FlatCodesDistanceComputer,IndexFlatCodes.get_FlatCodesDistanceComputerk
  s     FFtLLr$   c                 .    [         R                  " U 5      $ r/   )r   $IndexFlatCodes_get_distance_computerr[   s    r   r  $IndexFlatCodes.get_distance_computers
  r+  r$   Nc           	      4    [         R                  " XX#XEU5      $ )zSearch implemented by decoding)r   IndexFlatCodes_searchr[  s          r   r]  IndexFlatCodes.searchv
      //yRXYYr$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexFlatCodes_range_searchrf  s         r   rg  IndexFlatCodes.range_searchz
      55dq&YYr$   c                 .    [         R                  " U 5      $ r/   )r   IndexFlatCodes_get_CodePackerr[   s    r   get_CodePackerIndexFlatCodes.get_CodePacker}
      77==r$   c                 .    [         R                  " X5      $ r/   )r   )IndexFlatCodes_check_compatible_for_merger  s     r   r  )IndexFlatCodes.check_compatible_for_merge
      CCDUUr$   c                 0    [         R                  " XU5      $ r/   )r   IndexFlatCodes_merge_fromr  s      r   r  IndexFlatCodes.merge_from
  s    33DfMMr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexFlatCodes_add_sa_codesrP  s       r   r  IndexFlatCodes.add_sa_codes
      55dqGGr$   c                 .    [         R                  " X5      $ r/   )r   IndexFlatCodes_permute_entriesr   r  s     r   permute_entriesIndexFlatCodes.permute_entries
  r  r$   r%   r/   r  )#r   r   r:   r;   r<   r   r   r   r   r   IndexFlatCodes_code_size_getIndexFlatCodes_code_size_setr  IndexFlatCodes_codes_getIndexFlatCodes_codes_setr  rV   rH  r  r  r{  r  rt  rQ  r  r]  rg  r`  r  r  r  rq  delete_IndexFlatCodesr   r>   r%   r$   r   r3  r3  E
  s    
 -/IOdeGH@@*BiBijIZ88*:]:]  dS  TEW95MH<?MEZZ>VNHE!77r$   r3  c                       \ rS rSrSr\" S S SS9r\rSS jr	SS	 jr
S
 rS rS rS rS rS rS r\R&                  rSrg)	IndexFlati
  zAIndex that stores the full vectors and performs exhaustive searchc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexFlat.<lambda>
  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r{  
  rL   r$   rM   rN   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexFlat_searchr[  s          r   r]  IndexFlat.search
  s    **4A)VTTr$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexFlat_range_searchrf  s         r   rg  IndexFlat.range_search
      00!VTTr$   c                 0    [         R                  " XU5      $ r/   )r   IndexFlat_reconstructrx  s      r   r{  IndexFlat.reconstruct
      //6BBr$   c                 2    [         R                  " XX#XE5      $ )aS  
 compute distance with a subset of vectors

:type x: float
:param x:       query vectors, size n * d
:type labels: int
:param labels:  indices of the vectors that should be compared
                   for each query vector, size n * k
:type distances: float
:param distances:
                   corresponding output distances, size n * k
)r   !IndexFlat_compute_distance_subset)r   ra   rE   rQ  rR  rS  s         r   compute_distance_subset!IndexFlat.compute_distance_subset
  s     ;;DQ9]]r$   c                 0    [         R                  " U /UQ76 $ r/   )r   IndexFlat_get_xbr   s     r   get_xbIndexFlat.get_xb
      **47$77r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexFlat_swiginitnew_IndexFlatr   s     r   rV   IndexFlat.__init__
      %%dJ,D,Dd,KLr$   c                 .    [         R                  " U 5      $ r/   )r   'IndexFlat_get_FlatCodesDistanceComputerr[   s    r   rQ  'IndexFlat.get_FlatCodesDistanceComputer
      AA$GGr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexFlat_sa_encoder  s       r   r  IndexFlat.sa_encode
  s    --dq@@r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexFlat_sa_decoder  s       r   r  IndexFlat.sa_decode
  s    --du@@r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r]  rg  r{  r  r  rV   rQ  r  r  r   delete_IndexFlatr   r>   r%   r$   r   ry  ry  
  s\    L-/IOdeGHUUC^8MHAA!22r$   ry  c                   J    \ rS rSr\" S S SS9r\rS r\	R                  rSrg)	IndexFlatIPi
  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexFlatIP.<lambda>
  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  
  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexFlatIP_swiginitnew_IndexFlatIPr   s     r   rV   IndexFlatIP.__init__
      ''j.H.H$.OPr$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   delete_IndexFlatIPr   r>   r%   r$   r   r  r  
  s*    -/IOdeGHQ!44r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS rS rS rS	 r\R                   rS
rg)IndexFlatL2i
  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexFlatL2.<lambda>
  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  
  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g)z<
:type d: int
:param d: dimensionality of the input vectors
N)r   IndexFlatL2_swiginitnew_IndexFlatL2r   s     r   rV   IndexFlatL2.__init__
  s    
 	''j.H.H$.OPr$   c                 .    [         R                  " U 5      $ r/   )r   )IndexFlatL2_get_FlatCodesDistanceComputerr[   s    r   rQ  )IndexFlatL2.get_FlatCodesDistanceComputer
      CCDIIr$   c                 .    [         R                  " U 5      $ r/   )r   IndexFlatL2_sync_l2normsr[   s    r   sync_l2normsIndexFlatL2.sync_l2norms
  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexFlatL2_clear_l2normsr[   s    r   clear_l2normsIndexFlatL2.clear_l2norms
  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   IndexFlatL2_cached_l2norms_getIndexFlatL2_cached_l2norms_setcached_l2normsrV   rQ  r  r  delete_IndexFlatL2r   r>   r%   r$   r   r  r  
  sR    -/IOdeGHjGGIrIrsNQJ9:!44r$   r  c                      \ rS rSr\" S S SS9r\r\" \R                  5      r
\" \R                  5      r\" \R                  \R                  5      rS rS rSS	 jrSS
 jrS rS rS rS rS rS rS r\R6                  rSrg)IndexFlatPanoramai
  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexFlatPanorama.<lambda>
  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  
  rL   r$   rM   rN   c           	      \    [         R                  " U [         R                  " XX45      5        g)z
:type d: int
:param d: dimensionality of the input vectors
:type metric: int
:param metric: metric type
:type n_levels: int
:param n_levels: number of Panorama levels
:type batch_size: int
:param batch_size: batch size for Panorama storage
N)r   IndexFlatPanorama_swiginitnew_IndexFlatPanorama)r   r  metricn_levels
batch_sizes        r   rV   IndexFlatPanorama.__init__
  s#     	--dJ4T4TUV`h4uvr$   c                 0    [         R                  " XU5      $ r/   )r   IndexFlatPanorama_addr>  s      r   rH  IndexFlatPanorama.add
      //;;r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexFlatPanorama_searchr[  s          r   r]  IndexFlatPanorama.search
      224A)U[\\r$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexFlatPanorama_range_searchrf  s         r   rg  IndexFlatPanorama.range_search
      88!V\\r$   c                 .    [         R                  " U 5      $ r/   )r   IndexFlatPanorama_resetr[   s    r   r  IndexFlatPanorama.reset
  r   r$   c                 0    [         R                  " XU5      $ r/   )r   IndexFlatPanorama_reconstructrx  s      r   r{  IndexFlatPanorama.reconstruct      776JJr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexFlatPanorama_reconstruct_n)r   r+  ra   rz  s       r   r  IndexFlatPanorama.reconstruct_n  s    99$1MMr$   c                 .    [         R                  " X5      $ r/   )r   IndexFlatPanorama_remove_idsrs  s     r   rt  IndexFlatPanorama.remove_ids      66tAAr$   c                 0    [         R                  " XU5      $ r/   )r   IndexFlatPanorama_merge_fromr  s      r   r  IndexFlatPanorama.merge_from
      66tPPr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexFlatPanorama_add_sa_codes)r   ra   codes_inrQ  s       r   r  IndexFlatPanorama.add_sa_codes  s    88(QQr$   c                 .    [         R                  " X5      $ r/   )r   !IndexFlatPanorama_permute_entriesrp  s     r   rq  !IndexFlatPanorama.permute_entries      ;;DGGr$   r%   r/   )r   r   r:   r;   r   r   r   r   r    IndexFlatPanorama_batch_size_getr  IndexFlatPanorama_n_levels_getr  IndexFlatPanorama_cum_sums_getIndexFlatPanorama_cum_sums_setcum_sumsrV   rH  r]  rg  r  r{  r  rt  r  r  rq  delete_IndexFlatPanoramar   r>   r%   r$   r   r  r  
  s    -/IOdeGH*EEFJ
AABH
AA:ClClmHw<]]8KNBQRH!::r$   r  c                   N    \ rS rSr\" S S SS9r\rS	S jr\	R                  rSrg)
IndexFlatL2Panoramai  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexFlatL2Panorama.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r 	    rL   r$   rM   rN   c                 \    [         R                  " U [         R                  " XU5      5        g)z
:type d: int
:param d: dimensionality of the input vectors
:type n_levels: int
:param n_levels: number of Panorama levels
:type batch_size: int, optional
:param batch_size: batch size for Panorama storage
N)r   IndexFlatL2Panorama_swiginitnew_IndexFlatL2Panorama)r   r  r  r  s       r   rV   IndexFlatL2Panorama.__init__  s#     	//j6X6XYZfp6qrr$   r%   N)i   )r   r   r:   r;   r   r   r   r   rV   r   delete_IndexFlatL2Panoramar   r>   r%   r$   r   r  r    s,    -/IOdeGH	s "<<r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9rSS	 jrS
 rS rS rSS jr\	R*                  rSrg)IndexFlat1Di(  z#optimized version for 1D "vectors".c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexFlat1D.<lambda>+  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r
	  +  rL   r$   rM   rN   z(is the permutation updated continuously?zsorted database indicesc                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   IndexFlat1D_swiginitnew_IndexFlat1D)r   continuous_updates     r   rV   IndexFlat1D.__init__0  s    ''j.H.HIZ.[\r$   c                 .    [         R                  " U 5      $ )zO
if not continuous_update, call this between the last add and
the first search
)r   IndexFlat1D_update_permutationr[   s    r   update_permutationIndexFlat1D.update_permutation3      
 88>>r$   c                 0    [         R                  " XU5      $ r/   )r   IndexFlat1D_addr>  s      r   rH  IndexFlat1D.add:      ))$155r$   c                 .    [         R                  " U 5      $ r/   )r   IndexFlat1D_resetr[   s    r   r  IndexFlat1D.reset=  r3  r$   Nc           	      4    [         R                  " XX#XEU5      $ )z*Warn: the distances returned are L1 not L2)r   IndexFlat1D_searchr[  s          r   r]  IndexFlat1D.search@      ,,TaIvVVr$   r%   Tr/   )r   r   r:   r;   r<   r   r   r   r   r   !IndexFlat1D_continuous_update_get!IndexFlat1D_continuous_update_setr	  IndexFlat1D_perm_getIndexFlat1D_perm_setr  rV   r	  rH  r  r]  delete_IndexFlat1Dr   r>   r%   r$   r   r	  r	  (  s    .-/IOdeGH !M!MzO{O{  Bq  rJ33Z5T5TZxyD]?62W "44r$   r	  c                   (   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  S	S9r\" \	R,                  \	R.                  S
S9r\" \	R2                  \	R4                  SS9r\" \	R8                  \	R:                  SS9r\" \	R>                  \	R@                  SS9r!\" \	RD                  \	RF                  SS9r$\" \	RJ                  \	RL                  SS9r'\" \	RP                  \	RR                  SS9r*\" \	RV                  \	RX                  SS9r-\" \	R\                  \	R^                  SS9r0S r1\	Rd                  r3Sr4g)ClusteringParametersiG  zb
 Class for the clustering parameters. Can be passed to the
constructor of the Clustering object.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ClusteringParameters.<lambda>M  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r*	  M  rL   r$   rM   rN   znumber of clustering iterationsz[
    redo clustering this many times and keep the clusters with the best
    objective
    zg
    whether to normalize centroids after each iteration (useful for inner
    product clustering)
    z<round centroids coordinates to integer after each iteration?z$re-train index after each iteration?zd
    Use the subset of centroids provided as input and do not change them
    during iterations
    z
    If fewer than this number of training vectors per centroid are provided,
    writes a warning. Note that fewer than 1 point per centroid raises an
    exception.
    zBto limit size of dataset, otherwise the training set is subsampledz
    seed for the random number generator.
    negative values lead to seeding an internal rng with
    std::high_resolution_clock.
    zAwhen the training set is encoded, batch size of the codec decoderz*whether to check for NaNs in an input dataz
    Whether to use splitmix64-based random number generator for subsampling,
    which is faster, but may pick duplicate points.
    c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   ClusteringParameters_swiginitnew_ClusteringParametersr[   s    r   rV   ClusteringParameters.__init__q  r  r$   r%   N)5r   r   r:   r;   r<   r   r   r   r   r   ClusteringParameters_niter_getClusteringParameters_niter_setniterClusteringParameters_nredo_getClusteringParameters_nredo_setnredo ClusteringParameters_verbose_get ClusteringParameters_verbose_setr  "ClusteringParameters_spherical_get"ClusteringParameters_spherical_set	spherical&ClusteringParameters_int_centroids_get&ClusteringParameters_int_centroids_setint_centroids%ClusteringParameters_update_index_get%ClusteringParameters_update_index_setupdate_index)ClusteringParameters_frozen_centroids_get)ClusteringParameters_frozen_centroids_setfrozen_centroids0ClusteringParameters_min_points_per_centroid_get0ClusteringParameters_min_points_per_centroid_setmin_points_per_centroid0ClusteringParameters_max_points_per_centroid_get0ClusteringParameters_max_points_per_centroid_setmax_points_per_centroidClusteringParameters_seed_getClusteringParameters_seed_setr  *ClusteringParameters_decode_block_size_get*ClusteringParameters_decode_block_size_setdecode_block_size2ClusteringParameters_check_input_data_for_NaNs_get2ClusteringParameters_check_input_data_for_NaNs_setcheck_input_data_for_NaNs/ClusteringParameters_use_faster_subsampling_get/ClusteringParameters_use_faster_subsampling_setuse_faster_subsamplingrV   delete_ClusteringParametersr   r>   r%   r$   r   r(	  r(	  G  s$   
 -/IOdeGHZ>>
@i@i  pV  WEZ>>
@i@i p 	E zBBJDoDopGFF
HuHu | 	I ZNNPZ  QB  QB  HK  LMJLLjN~N~  Ep  qL
 T TV`  WK  WK Q 	 'z'b'bdn  e`  e` f 	
 'z'b'bdn  e`  e`  fo  pJ<<j>f>f m 	D
 !!V!VXb  YN  YN  T\  ] ()f)fhr  if  if  l]  !^%j&`&`bl  c]  c] c 	
^!==r$   r(	  c                   b   \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9r\" \R                  \R                  SS9r\" \R                  \R                   SS9r\" \R$                  \R&                  S	S9r\" \R*                  \R,                  S
S9rS r\R2                  rSrg)ClusteringIterationStatsiw  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   !ClusteringIterationStats.<lambda>x  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rY	  x  rL   r$   rM   rN   z5objective values (sum of distances reported by index)zseconds for iterationzseconds for just searchzimbalance factor of iterationznumber of cluster splitsc                 X    [         R                  " U [         R                  " 5       5        g r/   )r   !ClusteringIterationStats_swiginitnew_ClusteringIterationStatsr[   s    r   rV   !ClusteringIterationStats.__init__  s    44T:;b;b;der$   r%   N)r   r   r:   r;   r   r   r   r   r    ClusteringIterationStats_obj_get ClusteringIterationStats_obj_setobj!ClusteringIterationStats_time_get!ClusteringIterationStats_time_settime(ClusteringIterationStats_time_search_get(ClusteringIterationStats_time_search_settime_search-ClusteringIterationStats_imbalance_factor_get-ClusteringIterationStats_imbalance_factor_setr  #ClusteringIterationStats_nsplit_get#ClusteringIterationStats_nsplit_setnsplitrV   delete_ClusteringIterationStatsr   r>   r%   r$   r   rW	  rW	  w  s    -/IOdeGH
:>>
@k@k  rn  oCJ@@*BnBn  uQ  RD:NNPZ  QD  QD  Jh  iK
 X XZd  [S  [S  Y}  ~jDDjFtFt  {Z  [Ff!AAr$   rW	  c                   H   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9rS rSS jrSS jrS r\	R4                  rSrg)
Clusteringi  a  
 K-means clustering based on assignment - centroid update iterations

The clustering is based on an Index object that assigns training
points to the centroids. Therefore, at each iteration the centroids
are added to the index.

On output, the centroids table is set to the latest version
of the centroids and they are also added to the index. If the
centroids table it is not empty on input, it is also used for
initialization.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Clustering.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rq	    rL   r$   rM   rN   dimension of the vectorsnb of centroidszp
     centroids (k * d)
    if centroids are set on input to train, they will be used as
    initialization
    &stats at every iteration of clusteringc                 T    [         R                  " U [         R                  " U6 5        g r/   )r   Clustering_swiginitnew_Clusteringr   s     r   rV   Clustering.__init__      &&tZ-F-F-MNr$   Nc                 2    [         R                  " XX#U5      $ )a  
 run k-means training

:type x: float
:param x:          training vectors, size n * d
:type index: :py:class:`Index`
:param index:      index used for assignment
:type x_weights: float, optional
:param x_weights:  weight associated to each vector: NULL or size n
)r   Clustering_train)r   ra   rE   index	x_weightss        r   r?  Clustering.train  s     **4AiHHr$   c                 2    [         R                  " XX#XE5      $ )a	  
 run with encoded vectors

in addition to train()'s parameters takes a codec as parameter
to decode the input vectors.

:type codec: :py:class:`Index`
:param codec:      codec used to decode the vectors (nullptr =
                      vectors are in fact floats)
)r   Clustering_train_encoded)r   rw  r  codecr}	  weightss         r   train_encodedClustering.train_encoded  s     224T%YYr$   c                 .    [         R                  " U 5      $ )zx
Post-process the centroids after each centroid update.
includes optional L2 normalization and nearest integer rounding
)r   !Clustering_post_process_centroidsr[   s    r   post_process_centroids!Clustering.post_process_centroids  s    
 ;;DAAr$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   Clustering_d_getClustering_d_setr  Clustering_k_getClustering_k_setrQ  Clustering_centroids_getClustering_centroids_setr  Clustering_iteration_stats_getClustering_iteration_stats_setiteration_statsrV   r?  r	  r	  delete_Clusteringr   r>   r%   r$   r   ro	  ro	    s     -/IOdeGH,,j.I.IOnoA,,j.I.IOefA<<j>a>a h 	I
 zHH*JsJs  zg  hOOIZB "33r$   ro	  c                   T    \ rS rSrSr\" S S SS9r\rS r	S r
\R                  rS	rg
)Clustering1Di  zk
 Exact 1D clustering algorithm

Since it does not use an index, it does not overload the train() function
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Clustering1D.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r	    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   Clustering1D_swiginitnew_Clustering1Dr   s     r   rV   Clustering1D.__init__  rr  r$   c                 0    [         R                  " XU5      $ r/   )r   Clustering1D_train_exactr>  s      r   train_exactClustering1D.train_exact      224A>>r$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r	  r   delete_Clustering1Dr   r>   r%   r$   r   r	  r	    s6     -/IOdeGHS?!55r$   r	  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9r\" \R                  \R                  SS9rS r\R                   rS	rg
)"ProgressiveDimClusteringParametersi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   +ProgressiveDimClusteringParameters.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r	    rL   r$   rM   rN   znumber of incremental stepszapply PCA on inputc                 X    [         R                  " U [         R                  " 5       5        g r/   )r   +ProgressiveDimClusteringParameters_swiginit&new_ProgressiveDimClusteringParametersr[   s    r   rV   +ProgressiveDimClusteringParameters.__init__  s    >>tZEvEvExyr$   r%   N)r   r   r:   r;   r   r   r   r   r   <ProgressiveDimClusteringParameters_progressive_dim_steps_get<ProgressiveDimClusteringParameters_progressive_dim_steps_setprogressive_dim_steps0ProgressiveDimClusteringParameters_apply_pca_get0ProgressiveDimClusteringParameters_apply_pca_set	apply_pcarV   )delete_ProgressiveDimClusteringParametersr   r>   r%   r$   r   r	  r	    s    -/IOdeGH$Z%l%lnx  ov  ov  |^  _TTV`  WR  WR  Xq  rIz!KKr$   r	  c                   T    \ rS rSrSr\" S S SS9r\rS r	\
R                  rS rS	rg
)ProgressiveDimIndexFactoryi  z6generates an index suitable for clustering when calledc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   #ProgressiveDimIndexFactory.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r	    rL   r$   rM   rN   c                 .    [         R                  " X5      $ )zownership transferred to caller)r   #ProgressiveDimIndexFactory___call__)r   dims     r   r  #ProgressiveDimIndexFactory.__call__      ==dHHr$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   #ProgressiveDimIndexFactory_swiginitnew_ProgressiveDimIndexFactoryr[   s    r   rV   #ProgressiveDimIndexFactory.__init__  s    66tZ=f=f=hir$   r%   N)r   r   r:   r;   r<   r   r   r   r   r  r   !delete_ProgressiveDimIndexFactoryr   rV   r>   r%   r$   r   r	  r	    s5    A-/IOdeGHI "CCjr$   r	  c                   4   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9rS rS r\	R0                  rSrg)ProgressiveDimClusteringi  a  
 K-means clustering with progressive dimensions used

The clustering first happens in dim 1, then with exponentially increasing
dimension until d (I steps). This is typically applied after a PCA
transformation (optional). Reference:

"Improved Residual Vector Quantization for High-dimensional Approximate
Nearest Neighbor Search"

Shicong Liu, Hongtao Lu, Junru Shao, AAAI'15

https://arxiv.org/abs/1509.05195
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   !ProgressiveDimClustering.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r	    rL   r$   rM   rN   rs	  rt	  zcentroids (k * d)ru	  c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   !ProgressiveDimClustering_swiginitnew_ProgressiveDimClusteringr   s     r   rV   !ProgressiveDimClustering.__init__  s    44T:;b;bdh;ijr$   c                 0    [         R                  " XX#5      $ r/   )r   ProgressiveDimClustering_train)r   ra   rE   factorys       r   r?  ProgressiveDimClustering.train  s    88!MMr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   ProgressiveDimClustering_d_getProgressiveDimClustering_d_setr  ProgressiveDimClustering_k_getProgressiveDimClustering_k_setrQ  &ProgressiveDimClustering_centroids_get&ProgressiveDimClustering_centroids_setr  ,ProgressiveDimClustering_iteration_stats_get,ProgressiveDimClustering_iteration_stats_setr	  rV   r?  delete_ProgressiveDimClusteringr   r>   r%   r$   r   r	  r	    s     -/IOdeGH::J<e<e  lK  	LA::J<e<e  lB  	CAJJJL}L}  D\  ]IzVVXb  YP  YP  VC  DOkN!AAr$   r	  c                 2    [         R                  " XX#U5      $ )aK  
 simplified interface

:type d: int
:param d: dimension of the data
:type n: int
:param n: nb of training vectors
:type k: int
:param k: nb of output centroids
:type x: float
:param x: training set (size n * d)
:type centroids: float
:param centroids: output centroids (size k * d)
:rtype: float
:return: final quantization error
)r   kmeans_clustering)r  ra   rQ  rE   r  s        r   r	  r	    s    " ''aI>>r$   c                 8    [         R                  " XX#XEXgXU
5      $ r/   )r   pairwise_extra_distances)r  r  r]  rD  r^  r  r  rF  r_  r`  ra  s              r   r	  r	  )  s    ..qbbjWZadeer$   c
                 6    [         R                  " XX#XEXgX5
      $ r/   )r   knn_extra_metrics)
rE   rG  r  rw  re  r  r  rQ  rR  indexess
             r   r	  r	  ,  s    ''aRZI__r$   c                 2    [         R                  " XX#U5      $ )za
get a DistanceComputer that refers to this type of distance and
indexes a flat array of size nb
)r   get_extra_distance_computer)r  r  r  rD  r^  s        r   r	  r	  /  s    
 11!LLr$   c                       \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  SS9r\" \
R                  \
R                  S	S9rS
 rS rS r\
R(                  rSrg)	Quantizeri5  z'General interface for quantizer objectsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Quantizer.<lambda>8  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r	  8  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   Quantizer.__init__:  rX   r$   zsize of the input vectorszbytes per indexed vectorc                 0    [         R                  " XU5      $ )zS
 Train the quantizer

:type x: float
:param x:       training vectors, size n * d
)r   Quantizer_trainr>  s      r   r?  Quantizer.train@  s     ))$155r$   c                 0    [         R                  " XX#5      $ )z
 Quantize a set of vectors

:type x: float
:param x:        input vectors, size n * d
:type codes: uint8_t
:param codes:    output codes, size n * code_size
)r   Quantizer_compute_codesr   rE   r  ra   s       r   compute_codesQuantizer.compute_codesI  s     11$5DDr$   c                 0    [         R                  " XX#5      $ )z
 Decode a set of vectors

:param codes:    input codes, size n * code_size
:type x: float
:param x:        output vectors, size n * d
)r   Quantizer_decoder   r  rE   ra   s       r   decodeQuantizer.decodeT  s     **4q<<r$   r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r   Quantizer_d_getQuantizer_d_setr  Quantizer_code_size_getQuantizer_code_size_setr  r?  r	  r	  delete_Quantizerr   r>   r%   r$   r   r	  r	  5  s|    2-/IOdeGKH++Z-G-GMmnA;;Z=_=_  fE  FI6	E= "22r$   r	  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9r\	R2                  r\	R6                  r \	R:                  r \	R>                  r  \	RB                  r" \" \	RF                  \	RH                  5      r%\" \	RL                  \	RN                  SS9r(\" \	RR                  \	RT                  SS9r+\" \	RX                  \	RZ                  SS9r.\" \	R^                  \	R`                  SS9r1\" \	Rd                  \	Rf                  SS9r4S r5S r6S r7S r8S r9S r:S r;S r<S r=S r>S r?S r@S rAS rBS(S jrCS(S  jrD\" \	R                  \	R                  S!S9rGS" rHS(S# jrIS$ rJS% rK\	R                  rMS&rNg'))ProductQuantizeria  z
 Product Quantizer.
PQ is trained using k-means, minimizing the L2 distance to centroids.
PQ supports L2 and Inner Product search, however the quantization error is
biased towards L2 distance.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ProductQuantizer.<lambda>i  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r	  i  rL   r$   rM   rN   znumber of subquantizersz%number of bits per quantization indexz dimensionality of each subvectorz)number of centroids for each subquantizerverbose during training?z!parameters used during clusteringzR
    if non-NULL, use this index for assignment (should be of size
    d / M)
    zK
    Centroid table, size M * ksub * dsub.
    Layout: (M, ksub, dsub)
    zV
    Transposed centroid table, size M * ksub * dsub.
    Layout: (dsub, M, ksub)
    zK
    Squared lengths of centroids, size M * ksub
    Layout: (M, ksub)
    c                 0    [         R                  " XU5      $ )z0return the centroids associated with subvector m)r   ProductQuantizer_get_centroids)r   r  r+  s      r   get_centroidsProductQuantizer.get_centroids  r  r$   c                 0    [         R                  " XU5      $ r/   )r   ProductQuantizer_trainr>  s      r   r?  ProductQuantizer.train      00!<<r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   ProductQuantizer_swiginitnew_ProductQuantizerr   s     r   rV   ProductQuantizer.__init__  r  r$   c                 .    [         R                  " U 5      $ )z8compute derived values when d, M and nbits have been set)r   #ProductQuantizer_set_derived_valuesr[   s    r   set_derived_values#ProductQuantizer.set_derived_values      ==dCCr$   c                 0    [         R                  " XU5      $ )z'Define the centroids for subquantizer m)r   ProductQuantizer_set_params)r   r  r  s      r   
set_paramsProductQuantizer.set_params  s    55dqIIr$   c                 0    [         R                  " XU5      $ )z.Quantize one vector with the product quantizer)r   ProductQuantizer_compute_code)r   rE   r  s      r   compute_codeProductQuantizer.compute_code  s    77FFr$   c                 0    [         R                  " XX#5      $ )z(same as compute_code for several vectors)r   ProductQuantizer_compute_codesr	  s       r   r	  ProductQuantizer.compute_codes  s    88%KKr$   c                 0    [         R                  " XX#5      $ )zV
speed up code assignment using assign_index
(non-const because the index is changed)
)r   0ProductQuantizer_compute_codes_with_assign_indexr	  s       r   compute_codes_with_assign_index0ProductQuantizer.compute_codes_with_assign_index  s    
 JJ4TY]]r$   c                 0    [         R                  " U /UQ76 $ )zBdecode a vector from a given code (or n vectors if third argument))r   ProductQuantizer_decoder   s     r   r	  ProductQuantizer.decode  s    11$>>>r$   c                 0    [         R                  " XU5      $ )zd
If we happen to have the distance tables precomputed, this is
more efficient to compute the codes.
)r   1ProductQuantizer_compute_code_from_distance_table)r   r  r  s      r    compute_code_from_distance_table1ProductQuantizer.compute_code_from_distance_table  s    
 KKDW[\\r$   c                 0    [         R                  " XU5      $ )a  
 Compute distance table for one vector.

The distance table for x = [x_0 x_1 .. x_(M-1)] is a M * ksub
matrix that contains

  dis_table (m, j) = || x_m - c_(m, j)||^2
  for m = 0..M-1 and j = 0 .. ksub - 1

where c_(m, j) is the centroid no j of sub-quantizer m.

:type x: float
:param x:         input vector size d
:type dis_table: float
:param dis_table: output table, size M * ksub
)r   'ProductQuantizer_compute_distance_tabler   rE   	dis_tables      r   compute_distance_table'ProductQuantizer.compute_distance_table  s    " AA$9UUr$   c                 0    [         R                  " XU5      $ r/   )r   )ProductQuantizer_compute_inner_prod_tabler)
  s      r   compute_inner_prod_table)ProductQuantizer.compute_inner_prod_table  s    CCDYWWr$   c                 0    [         R                  " XX#5      $ )z
 compute distance table for several vectors
:type nx: int
:param nx:        nb of input vectors
:type x: float
:param x:         input vector size nx * d
:param dis_table: output table, size nx * M * ksub
)r   (ProductQuantizer_compute_distance_tablesr   rw  rE   r  s       r   compute_distance_tables(ProductQuantizer.compute_distance_tables  s     BB4Q[[r$   c                 0    [         R                  " XX#5      $ r/   )r   *ProductQuantizer_compute_inner_prod_tablesr3
  s       r   compute_inner_prod_tables*ProductQuantizer.compute_inner_prod_tables  s    DDTq]]r$   c           	      4    [         R                  " XX#XEU5      $ )a  
 perform a search (L2 distance)
:type x: float
:param x:        query vectors, size nx * d
:type nx: int
:param nx:       nb of queries
:type codes: uint8_t
:param codes:    database codes, size ncodes * code_size
:type ncodes: int
:param ncodes:   nb of nb vectors
:type res: :py:class:`float_maxheap_array_t`
:param res:      heap array to store results (nh == nx)
:type init_finalize_heap: boolean, optional
:param init_finalize_heap:  initialize heap (input) and sort (output)?
)r   ProductQuantizer_searchr   rE   rw  r  rM  resinit_finalize_heaps          r   r]  ProductQuantizer.search  s      11$2fSeffr$   c           	      4    [         R                  " XX#XEU5      $ )z1same as search, but with inner product similarity)r   ProductQuantizer_search_ipr<
  s          r   	search_ipProductQuantizer.search_ip  s    44TbVhiir$   zSymmetric Distance Tablec                 .    [         R                  " U 5      $ r/   )r   "ProductQuantizer_compute_sdc_tabler[   s    r   compute_sdc_table"ProductQuantizer.compute_sdc_table  r  r$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   ProductQuantizer_search_sdc)r   qcodesr  bcodesrM  r=
  r>
  s          r   
search_sdcProductQuantizer.search_sdc  s    55dBPV]oppr$   c                 .    [         R                  " U 5      $ )zj
Sync transposed centroids with regular centroids. This call
is needed if centroids were edited directly.
)r   *ProductQuantizer_sync_transposed_centroidsr[   s    r   sync_transposed_centroids*ProductQuantizer.sync_transposed_centroids  s    
 DDTJJr$   c                 .    [         R                  " U 5      $ )z<Clear transposed centroids table so ones are no longer used.)r   +ProductQuantizer_clear_transposed_centroidsr[   s    r   clear_transposed_centroids+ProductQuantizer.clear_transposed_centroids   s    EEdKKr$   r%   Nr!	  )Or   r   r:   r;   r<   r   r   r   r   r   ProductQuantizer_M_getProductQuantizer_M_setMProductQuantizer_nbits_getProductQuantizer_nbits_setr  ProductQuantizer_dsub_getProductQuantizer_dsub_setdsubProductQuantizer_ksub_getProductQuantizer_ksub_setr  ProductQuantizer_verbose_getProductQuantizer_verbose_setr  ProductQuantizer_Train_defaultTrain_default ProductQuantizer_Train_hot_startTrain_hot_startProductQuantizer_Train_sharedTrain_shared ProductQuantizer_Train_hypercubeTrain_hypercube$ProductQuantizer_Train_hypercube_pcaTrain_hypercube_pcaProductQuantizer_train_type_getProductQuantizer_train_type_set
train_typeProductQuantizer_cp_getProductQuantizer_cp_setcp!ProductQuantizer_assign_index_get!ProductQuantizer_assign_index_setassign_indexProductQuantizer_centroids_getProductQuantizer_centroids_setr  )ProductQuantizer_transposed_centroids_get)ProductQuantizer_transposed_centroids_settransposed_centroids)ProductQuantizer_centroids_sq_lengths_get)ProductQuantizer_centroids_sq_lengths_setcentroids_sq_lengthsr
  r?  rV   r
  r
  r
  r	  r
  r	  r%
  r+
  r/
  r4
  r8
  r]  rB
  ProductQuantizer_sdc_table_getProductQuantizer_sdc_table_set	sdc_tablerF
  rL
  rP
  rT
  delete_ProductQuantizerr   r>   r%   r$   r   r	  r	  a  s    -/IOdeGH22J4U4U[yzAZ::J<a<a  hT  UEJ88*:^:^  eL  MDJ88*:^:^  eU  VDz>>
@g@g  nM  NG==M AAO0;;L. AAO6$II6*DDjFpFpqJ	*44j6X6X  _G  
HBJHH*JvJv } 	L BBJDmDm t 	I $J$X$XZd  [O  [O U 	 $J$X$XZd  [O  [O U 	
E=[DJGL^?]V&X	\^g$j BBJDmDm  tS  TICqKL "99r$   r	  c                   "   \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9r\" \R                  \R                  5      r\" \R                  SS9r\" \R"                  \R$                  5      rSS jrS	 r\R,                  rS
rg)PQEncoderGenerici  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PQEncoderGeneric.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r
    rL   r$   rM   rN   zcode for this vectorz%number of bits per subquantizer indexc                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   PQEncoderGeneric_swiginitnew_PQEncoderGeneric)r   r  r  offsets       r   rV   PQEncoderGeneric.__init__  s!    ,,T:3R3RSW`f3ghr$   c                 .    [         R                  " X5      $ r/   )r   PQEncoderGeneric_encoderk   s     r   encodePQEncoderGeneric.encode  rn   r$   r%   Nr  )r   r   r:   r;   r   r   r   r   r   PQEncoderGeneric_code_getPQEncoderGeneric_code_setr  PQEncoderGeneric_offset_getPQEncoderGeneric_offset_setr
  PQEncoderGeneric_nbits_getr  PQEncoderGeneric_reg_getPQEncoderGeneric_reg_setregrV   r
  delete_PQEncoderGenericr   r>   r%   r$   r   r
  r
    s    -/IOdeGHJ88*:^:^d  ADj<<j>d>deFZ::@lmE
:66
8[8[
\Ci;!99r$   r
  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS rS r\R                  rSrg	)

PQEncoder8i  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PQEncoder8.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r
    rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   PQEncoder8_swiginitnew_PQEncoder8r   r  r  s      r   rV   PQEncoder8.__init__      &&tZ-F-Ft-STr$   c                 .    [         R                  " X5      $ r/   )r   PQEncoder8_encoderk   s     r   r
  PQEncoder8.encode   r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   PQEncoder8_code_getPQEncoder8_code_setr  rV   r
  delete_PQEncoder8r   r>   r%   r$   r   r
  r
    sG    -/IOdeGHJ22J4R4RSDU5!33r$   r
  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS rS r\R                  rSrg	)
PQEncoder16i&  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PQEncoder16.<lambda>'  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r
  '  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   PQEncoder16_swiginitnew_PQEncoder16r
  s      r   rV   PQEncoder16.__init__+      ''j.H.H.UVr$   c                 .    [         R                  " X5      $ r/   )r   PQEncoder16_encoderk   s     r   r
  PQEncoder16.encode.  rA  r$   r%   N)r   r   r:   r;   r   r   r   r   r   PQEncoder16_code_getPQEncoder16_code_setr  rV   r
  delete_PQEncoder16r   r>   r%   r$   r   r
  r
  &  sG    -/IOdeGHJ33Z5T5TUDW6!44r$   r
  c                   F   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  5      r\" \R"                  5      r\" \R&                  \R(                  5      rS rS r\R0                  rSrg	)
PQDecoderGenerici4  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PQDecoderGeneric.<lambda>5  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r
  5  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   PQDecoderGeneric_swiginitnew_PQDecoderGenericr
  s      r   rV   PQDecoderGeneric.__init__=  s    ,,T:3R3RSW3_`r$   c                 .    [         R                  " U 5      $ r/   )r   PQDecoderGeneric_decoder[   s    r   r	  PQDecoderGeneric.decode@  r   r$   r%   N)r   r   r:   r;   r   r   r   r   r   PQDecoderGeneric_code_getPQDecoderGeneric_code_setr  PQDecoderGeneric_offset_getPQDecoderGeneric_offset_setr
  PQDecoderGeneric_nbits_getr  PQDecoderGeneric_mask_getr  PQDecoderGeneric_reg_getPQDecoderGeneric_reg_setr
  rV   r	  delete_PQDecoderGenericr   r>   r%   r$   r   r
  r
  4  s    -/IOdeGHJ88*:^:^_Dj<<j>d>deFZ::;EJ889D
:66
8[8[
\Ca8!99r$   r
  c                       \ rS rSr\" S S SS9r\r\R                  r
\" \R                  \R                  5      rS rS r\R                   rSrg	)

PQDecoder8iF  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PQDecoder8.<lambda>G  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r
  G  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   PQDecoder8_swiginitnew_PQDecoder8r
  s      r   rV   PQDecoder8.__init__L  r
  r$   c                 .    [         R                  " U 5      $ r/   )r   PQDecoder8_decoder[   s    r   r	  PQDecoder8.decodeO  r3  r$   r%   N)r   r   r:   r;   r   r   r   r   r   PQDecoder8_nbitsr  PQDecoder8_code_getPQDecoder8_code_setr  rV   r	  delete_PQDecoder8r   r>   r%   r$   r   r
  r
  F  sR    -/IOdeGH''EJ22J4R4RSDU2!33r$   r
  c                       \ rS rSr\" S S SS9r\r\R                  r
\" \R                  \R                  5      rS rS r\R                   rSrg	)
PQDecoder16iU  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PQDecoder16.<lambda>V  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r
  V  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   PQDecoder16_swiginitnew_PQDecoder16r
  s      r   rV   PQDecoder16.__init__[  r
  r$   c                 .    [         R                  " U 5      $ r/   )r   PQDecoder16_decoder[   s    r   r	  PQDecoder16.decode^  r   r$   r%   N)r   r   r:   r;   r   r   r   r   r   PQDecoder16_nbitsr  PQDecoder16_code_getPQDecoder16_code_setr  rV   r	  delete_PQDecoder16r   r>   r%   r$   r   r
  r
  U  sR    -/IOdeGH((EJ33Z5T5TUDW3!44r$   r
  c                      \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  SS9r\" \
R                  \
R                  S	S9r\" \
R"                  \
R$                  S
S9r\" \
R(                  \
R*                  SS9r\" \
R.                  \
R0                  SS9r\" \
R4                  \
R6                  SS9r\" \
R:                  \
R<                  SS9r\" \
R@                  \
RB                  SS9r"\" \
RF                  \
RH                  SS9r%\" \
RL                  \
RN                  SS9r(\" \
RR                  \
RT                  SS9r+\" \
RX                  \
RZ                  SS9r.S r/\" \
R`                  \
Rb                  SS9r2\" \
Rf                  \
Rh                  SS9r5\" \
Rl                  \
Rn                  SS9r8S r9S r:S r;\
Rx                  r= \
R|                  r? \
R                  rA \
R                  rC \
R                  rE \
R                  rG\
R                  rI \
R                  rK\
R                  rM \
R                  rO S rPS rQS rRS+S jrSS,S  jrTS! rUS-S" jrV\" \
R                  \
R                  S#S9rY\" \
R                  \
R                  S$S9r\\" \
R                  \
R                  5      r_S% r`S.S& jraS' rbS( rcS) rd\
R                  rfS*rgg)/AdditiveQuantizerid  z
 Abstract structure for additive quantizers

Different from the product quantizer in which the decoded vector is the
concatenation of M sub-vectors, additive quantizers sum M sub-vectors
to get the decoded vector.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   AdditiveQuantizer.<lambda>m  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r
  m  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   AdditiveQuantizer.__init__o  rX   r$   znumber of codebookszbits for each step	codebooksz
    codebook #1 is stored in rows codebook_offsets[i]:codebook_offsets[i+1]
    in the codebooks table of size total_codebook_size by d
    z&total number of bits (indexes + norms)zbits allocated for the normszsize of the codebook in vectorsz&are all nbits = 8 (use faster decoder)r	  zis trained or notzt
    auxiliary data for ST_norm_lsq2x4 and ST_norm_rq2x4
    store norms of codebook entries for 4-bit fastscan
    zstore and search normsc                 .    [         R                  " U 5      $ r/   )r   )AdditiveQuantizer_compute_codebook_tablesr[   s    r   compute_codebook_tables)AdditiveQuantizer.compute_codebook_tables  r  r$   z8norms of all codebook entries (size total_codebook_size)z
    dot products of all codebook entries with the previous codebooks
    size sum(codebook_offsets[m] * 2^nbits[m], m=0..M-1)
    z
    norms and distance matrixes with beam search can get large, so use this
    to control for the amount of memory that can be allocated
    c                 .    [         R                  " X5      $ )z!encode a norm into norm_bits bits)r   AdditiveQuantizer_encode_norm)r   norms     r   encode_normAdditiveQuantizer.encode_norm  s    77CCr$   c                 .    [         R                  " X5      $ )z.encode norm by non-uniform scalar quantization)r   AdditiveQuantizer_encode_qcintrk   s     r   encode_qcintAdditiveQuantizer.encode_qcint      88AAr$   c                 .    [         R                  " X5      $ )z.decode norm by non-uniform scalar quantization)r   AdditiveQuantizer_decode_qcintr   r  s     r   decode_qcintAdditiveQuantizer.decode_qcint  r  r$   c                 .    [         R                  " U 5      $ )zTrain the norm quantizer)r   $AdditiveQuantizer_set_derived_valuesr[   s    r   r
  $AdditiveQuantizer.set_derived_values  r  r$   c                 0    [         R                  " XU5      $ r/   )r   AdditiveQuantizer_train_norm)r   ra   rv  s      r   
train_normAdditiveQuantizer.train_norm  s    66tFFr$   c                 0    [         R                  " XX#5      $ r/   )r   AdditiveQuantizer_compute_codesr	  s       r   r	  AdditiveQuantizer.compute_codes  s    99$5LLr$   Nc                 2    [         R                  " XX#U5      $ z
 Encode a set of vectors

:type x: float
:param x:      vectors to encode, size n * d
:type codes: uint8_t
:param codes:  output codes, size n * code_size
:type centroids: float, optional
:param centroids:  centroids to be added to x, size n * d
)r   -AdditiveQuantizer_compute_codes_add_centroidsr   rE   r  ra   r  s        r   compute_codes_add_centroids-AdditiveQuantizer.compute_codes_add_centroids       GGQV[deer$   c           	      4    [         R                  " XX#XEU5      $ )a  
 pack a series of code to bit-compact format

:type codes: int
:param codes:        codes to be packed, size n * code_size
:type packed_codes: uint8_t
:param packed_codes: output bit-compact codes
:type ld_codes: int, optional
:param ld_codes:     leading dimension of codes
:type norms: float, optional
:param norms:        norms of the vectors (size n). Will be computed if
                        needed but not provided
:type centroids: float, optional
:param centroids:    centroids to be added to x, size n * d
)r   AdditiveQuantizer_pack_codes)r   ra   r  packed_codesld_codesrv  r  s          r   
pack_codesAdditiveQuantizer.pack_codes  s      66tU]foppr$   c                 0    [         R                  " XX#5      $ z
 Decode a set of vectors

:type codes: uint8_t
:param codes:  codes to decode, size n * code_size
:type x: float
:param x:      output vectors, size n * d
)r   AdditiveQuantizer_decoder   r  rE   ra   s       r   r	  AdditiveQuantizer.decode  s     224EEr$   c                 2    [         R                  " XX#U5      $ z
 Decode a set of vectors in non-packed format

:type codes: int
:param codes:  codes to decode, size n * ld_codes
:type x: float
:param x:      output vectors, size n * d
)r   !AdditiveQuantizer_decode_unpackedr   r  rE   ra   r  s        r   decode_unpacked!AdditiveQuantizer.decode_unpacked  s     ;;DxXXr$   z#Also determines what's in the codesz!min/max for quantization of normsc                 0    [         R                  " XU5      $ )z-decoding function for a code in a 64-bit word)r   AdditiveQuantizer_decode_64bitr>  s      r   decode_64bitAdditiveQuantizer.decode_64bit  r  r$   c                 2    [         R                  " XX#XE5      $ )ae  
 Compute inner-product look-up tables. Used in the centroid search
functions.

:type xq: float
:param xq:     query vector, size (n, d)
:type LUT: float
:param LUT:    look-up table, size (n, total_codebook_size)
:type alpha: float, optional
:param alpha:  compute alpha * inner-product
:type ld_lut: int, optional
:param ld_lut:  leading dimension of LUT
)r   AdditiveQuantizer_compute_LUTr   ra   r]  LUTalphald_luts         r   compute_LUTAdditiveQuantizer.compute_LUT  s     77%XXr$   c                 2    [         R                  " XX#XE5      $ )zexact IP search)r   -AdditiveQuantizer_knn_centroids_inner_product)r   ra   r]  rQ  rR  rS  s         r   knn_centroids_inner_product-AdditiveQuantizer.knn_centroids_inner_product  s    GGQSXajjr$   c                 .    [         R                  " X5      $ )z
 For L2 search we need the L2 norms of the centroids

:type norms: float
:param norms:    output norms table, size total_codebook_size
)r   (AdditiveQuantizer_compute_centroid_normsr   rv  s     r   compute_centroid_norms(AdditiveQuantizer.compute_centroid_norms  s     BB4OOr$   c           	      4    [         R                  " XX#XEU5      $ )z'Exact L2 search, with precomputed norms)r   "AdditiveQuantizer_knn_centroids_L2)r   ra   r]  rQ  rR  rS  centroid_normss          r   knn_centroids_L2"AdditiveQuantizer.knn_centroids_L2  s    <<TbY`noor$   r%   r/   )NNrE  g      ?rE  )hr   r   r:   r;   r<   r   r   rV   r   r   r   AdditiveQuantizer_M_getAdditiveQuantizer_M_setrX
  AdditiveQuantizer_nbits_getAdditiveQuantizer_nbits_setr  AdditiveQuantizer_codebooks_getAdditiveQuantizer_codebooks_setr
  &AdditiveQuantizer_codebook_offsets_get&AdditiveQuantizer_codebook_offsets_setcodebook_offsetsAdditiveQuantizer_tot_bits_getAdditiveQuantizer_tot_bits_settot_bitsAdditiveQuantizer_norm_bits_getAdditiveQuantizer_norm_bits_set	norm_bits)AdditiveQuantizer_total_codebook_size_get)AdditiveQuantizer_total_codebook_size_settotal_codebook_sizeAdditiveQuantizer_only_8bit_getAdditiveQuantizer_only_8bit_set	only_8bitAdditiveQuantizer_verbose_getAdditiveQuantizer_verbose_setr   AdditiveQuantizer_is_trained_get AdditiveQuantizer_is_trained_setr  AdditiveQuantizer_norm_tabs_getAdditiveQuantizer_norm_tabs_set	norm_tabsAdditiveQuantizer_qnorm_getAdditiveQuantizer_qnorm_setqnormr
  $AdditiveQuantizer_centroid_norms_get$AdditiveQuantizer_centroid_norms_setrB  -AdditiveQuantizer_codebook_cross_products_get-AdditiveQuantizer_codebook_cross_products_setcodebook_cross_products'AdditiveQuantizer_max_mem_distances_get'AdditiveQuantizer_max_mem_distances_setmax_mem_distancesr
  r  r  AdditiveQuantizer_ST_decompressST_decompressAdditiveQuantizer_ST_LUT_nonormST_LUT_nonorm"AdditiveQuantizer_ST_norm_from_LUTST_norm_from_LUTAdditiveQuantizer_ST_norm_floatST_norm_floatAdditiveQuantizer_ST_norm_qint8ST_norm_qint8AdditiveQuantizer_ST_norm_qint4ST_norm_qint4 AdditiveQuantizer_ST_norm_cqint8ST_norm_cqint8 AdditiveQuantizer_ST_norm_cqint4ST_norm_cqint4 AdditiveQuantizer_ST_norm_lsq2x4ST_norm_lsq2x4AdditiveQuantizer_ST_norm_rq2x4ST_norm_rq2x4r
  r  r	  r  r  r	  r)  !AdditiveQuantizer_search_type_get!AdditiveQuantizer_search_type_setsearch_typeAdditiveQuantizer_norm_min_getAdditiveQuantizer_norm_min_setnorm_minAdditiveQuantizer_norm_max_getAdditiveQuantizer_norm_max_setnorm_maxr-  r5  r9  r>  rC  delete_AdditiveQuantizerr   r>   r%   r$   r   r
  r
  d  s    -/IOdeGKH33Z5W5W]wxAZ;;Z=c=c  jC  DECCZEoEo  vF  GI
 Q QS]  TE  TE K 	 
AA:ClCl  s`  aHCCZEoEo  vY  ZI":#W#WYc  ZN  ZN  Tz  {CCZEoEo  vc  dIz??AiAi  pO  PG*EEzGrGr  yQ  RJCCZEoEo v 	I Z;;Z=c=c  jG  HEJjMMzO~O~  ED  EN&z'_'_ak  bZ  bZ ` 	 !!S!SU_  VH  VH N 	
DBB >>M%>>M "DD >>M=>>M3>>M@@N:@@N@@N >>M>EGMfq$	F	Y :GGIuIu  |f  gK
AA:ClCl  s[  \H
AA:ClClmHEY kPp "::r$   r
  c                  (    [         R                  " U 6 $ )a  
 Encode a residual by sampling from a centroid table.

This is a single encoding step the residual quantizer.
It allows low-level access to the encoding function, exposed mainly for unit
tests.

:type n: int
:param n:              number of vectors to handle
:type residuals: float
:param residuals:      vectors to encode, size (n, beam_size, d)
:type cent: float
:param cent:           centroids, size (K, d)
:type beam_size: int
:param beam_size:      input beam size
:type m: int
:param m:              size of the codes for the previous encoding steps
:type codes: int
:param codes:          code array for the previous steps of the beam (n,
    beam_size, m)
:type new_beam_size: int
:param new_beam_size:  output beam size (should be <= K * beam_size)
:type new_codes: int
:param new_codes:      output codes, size (n, new_beam_size, m + 1)
:type new_residuals: float
:param new_residuals:  output residuals, size (n, new_beam_size, d)
:type new_distances: float
:param new_distances:  output distances, size (n, new_beam_size)
:type assign_index: :py:class:`Index`, optional
:param assign_index:   if non-NULL, will be used to perform assignment
)r   beam_search_encode_steprI  s    r   r  r  #  s    @ --t44r$   c                  (    [         R                  " U 6 $ )a  
 Encode a set of vectors using their dot products with the codebooks

:type K: int
:param K:           number of vectors in the codebook
:type n: int
:param n:           nb of vectors to encode
:type beam_size: int
:param beam_size:   input beam size
:type codebook_cross_norms: float
:param codebook_cross_norms: inner product of this codebook with the m
                                previously encoded codebooks
:type codebook_offsets: int
:param codebook_offsets:     offsets into codebook_cross_norms for each
                                previous codebook
:type query_cp: float
:param query_cp:    dot products of query vectors with ???
:type cent_norms_i: float
:param cent_norms_i:  norms of centroids
)r   beam_search_encode_step_tabrI  s    r   r  r  E  s    * 11488r$   c                   l   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      r\" \R*                  \R,                  5      rS r\R2                  rSrg)	RefineBeamMemoryPooli[  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   RefineBeamMemoryPool.<lambda>\  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  \  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   RefineBeamMemoryPool_swiginitnew_RefineBeamMemoryPoolr[   s    r   rV   RefineBeamMemoryPool.__init__d  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   "RefineBeamMemoryPool_new_codes_get"RefineBeamMemoryPool_new_codes_set	new_codes&RefineBeamMemoryPool_new_residuals_get&RefineBeamMemoryPool_new_residuals_setnew_residuals"RefineBeamMemoryPool_residuals_get"RefineBeamMemoryPool_residuals_setr  RefineBeamMemoryPool_codes_getRefineBeamMemoryPool_codes_setr  "RefineBeamMemoryPool_distances_get"RefineBeamMemoryPool_distances_setrR  rV   delete_RefineBeamMemoryPoolr   r>   r%   r$   r   r  r  [  s    -/IOdeGHFF
HuHuvIZNNPZ  QB  QB  CMFF
HuHuvIZ>>
@i@ijEFF
HuHuvI^!==r$   r  c	                 6    [         R                  " XX#XEXgU5	      $ r/   )r   refine_beam_mp)	rqra   	beam_sizerE   out_beam_size	out_codesout_residualsout_distancespools	            r   r  r  k  s    $$RI-Tarvwwr$   c                   2   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      rS r\R,                  rSrg)	RefineBeamLUTMemoryPoolim  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF    RefineBeamLUTMemoryPool.<lambda>n  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  n  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r    RefineBeamLUTMemoryPool_swiginitnew_RefineBeamLUTMemoryPoolr[   s    r   rV    RefineBeamLUTMemoryPool.__init__u      33D*:`:`:bcr$   r%   N)r   r   r:   r;   r   r   r   r   r   %RefineBeamLUTMemoryPool_new_codes_get%RefineBeamLUTMemoryPool_new_codes_setr  )RefineBeamLUTMemoryPool_new_distances_get)RefineBeamLUTMemoryPool_new_distances_setnew_distances!RefineBeamLUTMemoryPool_codes_get!RefineBeamLUTMemoryPool_codes_setr  %RefineBeamLUTMemoryPool_distances_get%RefineBeamLUTMemoryPool_distances_setrR  rV   delete_RefineBeamLUTMemoryPoolr   r>   r%   r$   r   r  r  m  s    -/IOdeGHII:K{K{|IZQQS]  TH  TH  IMZAA:CoCopEII:K{K{|Id!@@r$   r  c           
      4    [         R                  " XX#XEXg5      $ r/   )r   refine_beam_LUT_mp)r  ra   query_normsquery_cpr  r  r  r  s           r   r  r  |  s    ((}anuur$   c                   l   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      r\" \R*                  \R,                  5      rS r\R2                  rSrg)	&ComputeCodesAddCentroidsLUT0MemoryPooli~  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   /ComputeCodesAddCentroidsLUT0MemoryPool.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   /ComputeCodesAddCentroidsLUT0MemoryPool_swiginit*new_ComputeCodesAddCentroidsLUT0MemoryPoolr[   s    r   rV   /ComputeCodesAddCentroidsLUT0MemoryPool.__init__  "    BB4I~I~  JA  	Br$   r%   N)r   r   r:   r;   r   r   r   r   r   0ComputeCodesAddCentroidsLUT0MemoryPool_codes_get0ComputeCodesAddCentroidsLUT0MemoryPool_codes_setr  0ComputeCodesAddCentroidsLUT0MemoryPool_norms_get0ComputeCodesAddCentroidsLUT0MemoryPool_norms_setrv  4ComputeCodesAddCentroidsLUT0MemoryPool_distances_get4ComputeCodesAddCentroidsLUT0MemoryPool_distances_setrR  4ComputeCodesAddCentroidsLUT0MemoryPool_residuals_get4ComputeCodesAddCentroidsLUT0MemoryPool_residuals_setr  ;ComputeCodesAddCentroidsLUT0MemoryPool_refine_beam_pool_get;ComputeCodesAddCentroidsLUT0MemoryPool_refine_beam_pool_setrefine_beam_poolrV   -delete_ComputeCodesAddCentroidsLUT0MemoryPoolr   r>   r%   r$   r   r  r  ~  s    -/IOdeGHZPPR\  SN  SN  OEZPPR\  SN  SN  OEXXZd  [Z  [Z  [IXXZd  [Z  [Z  [I
 f fhr  io  io  pB!OOr$   r  c                 2    [         R                  " XX#XE5      $ r/   )r   #compute_codes_add_centroids_mp_lut0r  rE   	codes_outra   r  r  s         r   r  r        99"y__r$   c                      \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      r\" \R*                  \R,                  5      r\" \R0                  \R2                  5      rS r\R8                  rSrg)	&ComputeCodesAddCentroidsLUT1MemoryPooli  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   /ComputeCodesAddCentroidsLUT1MemoryPool.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   /ComputeCodesAddCentroidsLUT1MemoryPool_swiginit*new_ComputeCodesAddCentroidsLUT1MemoryPoolr[   s    r   rV   /ComputeCodesAddCentroidsLUT1MemoryPool.__init__  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   0ComputeCodesAddCentroidsLUT1MemoryPool_codes_get0ComputeCodesAddCentroidsLUT1MemoryPool_codes_setr  4ComputeCodesAddCentroidsLUT1MemoryPool_distances_get4ComputeCodesAddCentroidsLUT1MemoryPool_distances_setrR  6ComputeCodesAddCentroidsLUT1MemoryPool_query_norms_get6ComputeCodesAddCentroidsLUT1MemoryPool_query_norms_setr  3ComputeCodesAddCentroidsLUT1MemoryPool_query_cp_get3ComputeCodesAddCentroidsLUT1MemoryPool_query_cp_setr  4ComputeCodesAddCentroidsLUT1MemoryPool_residuals_get4ComputeCodesAddCentroidsLUT1MemoryPool_residuals_setr  ?ComputeCodesAddCentroidsLUT1MemoryPool_refine_beam_lut_pool_get?ComputeCodesAddCentroidsLUT1MemoryPool_refine_beam_lut_pool_setrefine_beam_lut_poolrV   -delete_ComputeCodesAddCentroidsLUT1MemoryPoolr   r>   r%   r$   r   r  r    s   -/IOdeGHZPPR\  SN  SN  OEXXZd  [Z  [Z  [I:\\^h  _`  _`  aK
VVXb  YW  YW  XHXXZd  [Z  [Z  [I#J$n$npz  q{  q{  |B!OOr$   r  c                 2    [         R                  " XX#XE5      $ r/   )r   #compute_codes_add_centroids_mp_lut1r  s         r   r  r    r  r$   c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\	R                  r \	R                  r \	R"                  r \" \	R&                  \	R(                  SS9r\	R,                  r \	R0                  r \" \	R4                  \	R6                  S	S9r\" \	R:                  \	R<                  S
S9r\" \	R@                  \	RB                  SS9r"\" \	RF                  \	RH                  SS9r%\" \	RL                  \	RN                  SS9r(S r)S r*SS jr+S r,SS jr-SS jr.SS jr/SS jr0\	Rb                  r2Sr3g)ResidualQuantizeri  z
 Residual quantizer with variable number of bits per sub-quantizer

The residual centroids are stored in a big cumulative centroid table.
The codes are represented either as a non-compact table of size (n, M) or
as the compact output (n, code_size).
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ResidualQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   z$Binary or of the Train_* flags belowz-number of iterations for codebook refinement.z,beam size used for training and for encodingzuse LUT for beam searchza
    Currently used mode of approximate min-k computations.
    Default value is EXACT_TOPK.
    zclustering parametersz*if non-NULL, use this index for assignmentc                 T    [         R                  " U [         R                  " U6 5        g r/   )r   ResidualQuantizer_swiginitnew_ResidualQuantizerr   s     r   rV   ResidualQuantizer.__init__      --dJ4T4TVZ4[\r$   c                 0    [         R                  " XU5      $ )zTrain the residual quantizer)r   ResidualQuantizer_trainr>  s      r   r?  ResidualQuantizer.train      11$1==r$   c                 0    [         R                  " XU5      $ )z;Copy the M codebook levels from other, starting from skip_M)r   !ResidualQuantizer_initialize_from)r   r   skip_Ms      r   initialize_from!ResidualQuantizer.initialize_from  s    ;;DPPr$   c                 0    [         R                  " XU5      $ )aB  
 Encode the vectors and compute codebook that minimizes the quantization
error on these codes

:type x: float
:param x:      training vectors, size n * d
:type n: int
:param n:      nb of training vectors, n >= total_codebook_size
:rtype: float
:return: returns quantization error for the new codebook with old
    codes
)r   %ResidualQuantizer_retrain_AQ_codebookr>  s      r   retrain_AQ_codebook%ResidualQuantizer.retrain_AQ_codebook  s     ??KKr$   Nc                 2    [         R                  " XX#U5      $ r  )r   -ResidualQuantizer_compute_codes_add_centroidsr  s        r   r  -ResidualQuantizer.compute_codes_add_centroids  r  r$   c           
      4    [         R                  " XX#XEXg5      $ )ay  
 lower-level encode function

:type n: int
:param n:              number of vectors to handle
:type residuals: float
:param residuals:      vectors to encode, size (n, beam_size, d)
:type beam_size: int
:param beam_size:      input beam size
:type new_beam_size: int
:param new_beam_size:  output beam size (should be <= K * beam_size)
:type new_codes: int
:param new_codes:      output codes, size (n, new_beam_size, m + 1)
:type new_residuals: float, optional
:param new_residuals:  output residuals, size (n, new_beam_size, d)
:type new_distances: float, optional
:param new_distances:  output distances, size (n, new_beam_size)
)r   ResidualQuantizer_refine_beam)r   ra   r  r  new_beam_sizer  r  r  s           r   refine_beamResidualQuantizer.refine_beam  s#    & 77Wdq~  O  	Or$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   !ResidualQuantizer_refine_beam_LUT)r   ra   r  r  r  r  r  s          r   refine_beam_LUT!ResidualQuantizer.refine_beam_LUT  s%    ;;D[\i  wD  E  	Er$   c                 .    [         R                  " X5      $ )z
 Beam search can consume a lot of memory. This function estimates the
amount of mem used by refine_beam to adjust the batch size

:type beam_size: int, optional
:param beam_size:  if != -1, override the beam size
)r   "ResidualQuantizer_memory_per_point)r   r  s     r   memory_per_point"ResidualQuantizer.memory_per_point  s     <<TMMr$   r%   r  r/   NNrF  )4r   r   r:   r;   r<   r   r   r   r   r    ResidualQuantizer_train_type_get ResidualQuantizer_train_type_setrn
  ResidualQuantizer_Train_defaultrc
  'ResidualQuantizer_Train_progressive_dimTrain_progressive_dim'ResidualQuantizer_Train_refine_codebookTrain_refine_codebook+ResidualQuantizer_niter_codebook_refine_get+ResidualQuantizer_niter_codebook_refine_setniter_codebook_refine ResidualQuantizer_Train_top_beamTrain_top_beam&ResidualQuantizer_Skip_codebook_tablesSkip_codebook_tables#ResidualQuantizer_max_beam_size_get#ResidualQuantizer_max_beam_size_setmax_beam_size"ResidualQuantizer_use_beam_LUT_get"ResidualQuantizer_use_beam_LUT_setuse_beam_LUT&ResidualQuantizer_approx_topk_mode_get&ResidualQuantizer_approx_topk_mode_setapprox_topk_modeResidualQuantizer_cp_getResidualQuantizer_cp_setrq
  *ResidualQuantizer_assign_index_factory_get*ResidualQuantizer_assign_index_factory_setassign_index_factoryrV   r?  r  r  r  r  r  r!  delete_ResidualQuantizerr   r>   r%   r$   r   r  r    s    -/IOdeGH*EEzGrGr  yd  eJ>>M:&NN6&NNR$Z%[%[]g  ^T  ^T  ZN  O@@N &LL ZKKZM{M{  Bu  vMJII:KxKx  ]  ^L
 Q QS]  TE  TE K 	 
*55z7Z7Z`|	}B#J$Y$Y[e  \Q  \Q  WH  I]>QLfO*EN "::r$   r  c                   <   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9r\" \	R2                  \	R4                  SS9r\" \	R8                  \	R:                  SS9r\" \	R>                  \	R@                  SS9r!\" \	RD                  \	RF                  SS9r$\" \	RJ                  \	RL                  SS9r'\" \	RP                  \	RR                  5      r*\" \	RV                  \	RX                  5      r-S r.\	R^                  r0S r1SS jr2S r3S r4S r5S r6S r7S r8S r9S r:SS jr;Sr<g) LocalSearchQuantizeri  a  
 Implementation of LSQ/LSQ++ described in the following two papers:

Revisiting additive quantization
Julieta Martinez, et al. ECCV 2016

LSQ++: Lower running time and higher recall in multi-codebook quantization
Julieta Martinez, et al. ECCV 2018

This implementation is mostly translated from the Julia implementations
by Julieta Martinez:
(https://github.com/una-dinosauria/local-search-quantization,
 https://github.com/una-dinosauria/Rayuela.jl)

The trained codes are stored in `codebooks` which is called
`centroids` in PQ and RQ.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   LocalSearchQuantizer.<lambda>(  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rD  (  rL   r$   rM   rN   znumber of codes per codebookz number of iterations in trainingz&iterations of local search in encodingz&iterations of local search in trainingznumber of iterations in icmztemperature factorzregularization factorz!nb of vectors to encode at a timezseed for random generatorzo
    number of perturbation in each code
    if non-NULL, use this encoder to encode (owned by the object)
    c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   LocalSearchQuantizer_swiginitnew_LocalSearchQuantizerr   s     r   rV   LocalSearchQuantizer.__init__:      00z7Z7Z\`7abr$   c                 0    [         R                  " XU5      $ r/   )r   LocalSearchQuantizer_trainr>  s      r   r?  LocalSearchQuantizer.train>      44Ta@@r$   Nc                 2    [         R                  " XX#U5      $ )a%  
 Encode a set of vectors

:type x: float
:param x:      vectors to encode, size n * d
:type codes: uint8_t
:param codes:  output codes, size n * code_size
:type n: int
:param n:      number of vectors
:type centroids: float, optional
:param centroids:  centroids to be added to x, size n * d
)r   0LocalSearchQuantizer_compute_codes_add_centroidsr  s        r   r  0LocalSearchQuantizer.compute_codes_add_centroidsA  s     JJ4TY^ghhr$   c                 0    [         R                  " XX#5      $ )z
 Update codebooks given encodings

:type x: float
:param x:      training vectors, size n * d
:type codes: int
:param codes:  encoded training vectors, size n * M
:type n: int
:param n:      number of vectors
)r   %LocalSearchQuantizer_update_codebooksr	  s       r   update_codebooks%LocalSearchQuantizer.update_codebooksP  s     ??RRr$   c                 2    [         R                  " XX#XE5      $ )aL  
 Encode vectors given codebooks using iterative conditional mode (icm).

:type codes: int
:param codes:     output codes, size n * M
:type x: float
:param x:         vectors to encode, size n * d
:type n: int
:param n:         number of vectors
:type ils_iters: int
:param ils_iters: number of iterations of iterative local search
)r   LocalSearchQuantizer_icm_encode)r   r  rE   ra   	ils_itersgens         r   
icm_encodeLocalSearchQuantizer.icm_encode]  s     99$qY\\r$   c           
      4    [         R                  " XX#XEXg5      $ r/   )r   $LocalSearchQuantizer_icm_encode_impl)r   r  rE   unariesrY  ra   rX  r  s           r   icm_encode_impl$LocalSearchQuantizer.icm_encode_impll  s    >>tAX[`issr$   c                 2    [         R                  " XX#XE5      $ r/   )r   $LocalSearchQuantizer_icm_encode_step)r   r  r^  binariesra   n_iterss         r   icm_encode_step$LocalSearchQuantizer.icm_encode_stepo  s    >>tG_`jjr$   c                 0    [         R                  " XX#5      $ )z
 Add some perturbation to codes

:type codes: int
:param codes: codes to be perturbed, size n * M
:type n: int
:param n:     number of vectors
)r   "LocalSearchQuantizer_perturb_codes)r   r  ra   rY  s       r   perturb_codes"LocalSearchQuantizer.perturb_codesr  s     <<T!QQr$   c                 0    [         R                  " XX#5      $ )z
 Add some perturbation to codebooks

:type T: float
:param T:         temperature of simulated annealing
:type stddev: std::vector< float >
:param stddev:    standard deviations of each dimension in training data
)r   &LocalSearchQuantizer_perturb_codebooks)r   TstddevrY  s       r   perturb_codebooks&LocalSearchQuantizer.perturb_codebooks}  s     @@&VVr$   c                 .    [         R                  " X5      $ )z`
 Compute binary terms

:type binaries: float
:param binaries: binary terms, size M * M * K * K
)r   )LocalSearchQuantizer_compute_binary_terms)r   rc  s     r   compute_binary_terms)LocalSearchQuantizer.compute_binary_terms  s     CCDSSr$   c                 0    [         R                  " XX#5      $ )z
 Compute unary terms

:type n: int
:param n:       number of vectors
:type x: float
:param x:       vectors to encode, size n * d
:type unaries: float
:param unaries: unary terms, size n * M * K
)r   (LocalSearchQuantizer_compute_unary_terms)r   rE   r^  ra   s       r   compute_unary_terms(LocalSearchQuantizer.compute_unary_terms  s     BB4GWWr$   c                 2    [         R                  " XX#U5      $ )ac  
 Helper function to compute reconstruction error

:type codes: int
:param codes: encoded codes, size n * M
:type x: float
:param x:     vectors to encode, size n * d
:type n: int
:param n:     number of vectors
:type objs: float, optional
:param objs:  if it is not null, store reconstruction
                        error of each vector into it, size n
)r   LocalSearchQuantizer_evaluate)r   r  rE   ra   objss        r   evaluateLocalSearchQuantizer.evaluate  s     77Q4PPr$   r%   r/   )=r   r   r:   r;   r<   r   r   r   r   r   LocalSearchQuantizer_K_getLocalSearchQuantizer_K_setK$LocalSearchQuantizer_train_iters_get$LocalSearchQuantizer_train_iters_settrain_iters)LocalSearchQuantizer_encode_ils_iters_get)LocalSearchQuantizer_encode_ils_iters_setencode_ils_iters(LocalSearchQuantizer_train_ils_iters_get(LocalSearchQuantizer_train_ils_iters_settrain_ils_iters"LocalSearchQuantizer_icm_iters_get"LocalSearchQuantizer_icm_iters_set	icm_itersLocalSearchQuantizer_p_getLocalSearchQuantizer_p_setpLocalSearchQuantizer_lambd_getLocalSearchQuantizer_lambd_setlambd#LocalSearchQuantizer_chunk_size_get#LocalSearchQuantizer_chunk_size_set
chunk_size$LocalSearchQuantizer_random_seed_get$LocalSearchQuantizer_random_seed_setrandom_seedLocalSearchQuantizer_nperts_getLocalSearchQuantizer_nperts_setnperts,LocalSearchQuantizer_icm_encoder_factory_get,LocalSearchQuantizer_icm_encoder_factory_seticm_encoder_factory5LocalSearchQuantizer_update_codebooks_with_double_get5LocalSearchQuantizer_update_codebooks_with_double_setupdate_codebooks_with_doublerV   delete_LocalSearchQuantizerr   r?  r  rT  rZ  r_  re  ri  ro  rs  rw  r|  r>   r%   r$   r   rB  rB    s   $ -/IOdeGH66
8]8]  dG  	HA:JJJL{L{  Bi  jK
 T TV`  WK  WK  Q~  zRRT^  UH  UH  N{  |OFF
HuHu  |^  _I66
8]8]c|}AZ>>
@i@i  pL  ME*HH*JxJx  g  hJ:JJJL{L{  Bb  cKj@@*BlBl s 	F #:#Z#Z\f  ]T  ]T  U#+J,l,lnx  oo  oo  $p c!==AiS]tk	R	WTXQr$   rB  c                      \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      rS r\R&                  rS rS rS	rg
)
IcmEncoderi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IcmEncoder.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   IcmEncoder_swiginitnew_IcmEncoderr   lsqs     r   rV   IcmEncoder.__init__  s    &&tZ-F-Fs-KLr$   c                 .    [         R                  " U 5      $ r/   )r   IcmEncoder_set_binary_termr[   s    r   set_binary_termIcmEncoder.set_binary_term  r  r$   c                 2    [         R                  " XX#XE5      $ )a_  
 Encode vectors given codebooks

:type codes: int
:param codes:     output codes, size n * M
:type x: float
:param x:         vectors to encode, size n * d
:type gen: std::mt19937
:param gen:       random generator
:type n: int
:param n:         number of vectors
:type ils_iters: int
:param ils_iters: number of iterations of iterative local search
)r   IcmEncoder_encode)r   r  rE   rY  ra   rX  s         r   r
  IcmEncoder.encode  s     ++DNNr$   r%   N)r   r   r:   r;   r   r   r   r   r   IcmEncoder_binaries_getIcmEncoder_binaries_setrc  IcmEncoder_verbose_getIcmEncoder_verbose_setr  IcmEncoder_lsq_getIcmEncoder_lsq_setr  rV   delete_IcmEncoderr   r  r
  r>   r%   r$   r   r  r    s}    -/IOdeGH
::J<^<^_Hz88*:[:[\G
:00*2O2O
PCM!33;Or$   r  c                   P    \ rS rSr\" S S SS9r\rS r\	R                  rS rSrg	)
IcmEncoderFactoryi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IcmEncoderFactory.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 .    [         R                  " X5      $ r/   )r   IcmEncoderFactory_getr  s     r   getIcmEncoderFactory.get  s    //::r$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   IcmEncoderFactory_swiginitnew_IcmEncoderFactoryr[   s    r   rV   IcmEncoderFactory.__init__  r7  r$   r%   N)r   r   r:   r;   r   r   r   r   r  r   delete_IcmEncoderFactoryr   rV   r>   r%   r$   r   r  r    s/    -/IOdeGH;!::Xr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS rS	 rS
 r\	R"                  rSrg)LSQTimeri  zQ
A helper struct to count consuming time during training.
It is NOT thread-safe.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   LSQTimer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   LSQTimer_swiginitnew_LSQTimerr[   s    r   rV   LSQTimer.__init__  s    $$T:+B+B+DEr$   c                 .    [         R                  " X5      $ r/   )r   LSQTimer_getr   r   s     r   r  LSQTimer.get  s    &&t22r$   c                 0    [         R                  " XU5      $ r/   )r   LSQTimer_add)r   r   deltas      r   rH  LSQTimer.add  s    &&t599r$   c                 .    [         R                  " U 5      $ r/   )r   LSQTimer_resetr[   s    r   r  LSQTimer.reset      ((..r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   LSQTimer_t_getLSQTimer_t_settrV   r  rH  r  delete_LSQTimerr   r>   r%   r$   r   r  r    sX    
 -/IOdeGH**J,E,EFAF3:/!11r$   r  c                   8   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      rS rS r\R.                  rSrg	)
LSQTimerScopei  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   LSQTimerScope.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   LSQTimerScope_swiginitnew_LSQTimerScope)r   timerr   s      r   rV   LSQTimerScope.__init__  s    ))$
0L0LU0YZr$   c                 .    [         R                  " U 5      $ r/   )r   LSQTimerScope_finishr[   s    r   finishLSQTimerScope.finish  r]   r$   r%   N)r   r   r:   r;   r   r   r   r   r   LSQTimerScope_t0_getLSQTimerScope_t0_sett0LSQTimerScope_timer_getLSQTimerScope_timer_setr  LSQTimerScope_name_getLSQTimerScope_name_setr   LSQTimerScope_finished_getLSQTimerScope_finished_setfinishedrV   r  delete_LSQTimerScoper   r>   r%   r$   r   r  r    s    -/IOdeGH	*11:3R3R	SBZ779[9[\EJ55z7X7XYD
==z?d?deH[5!66r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  5      rS r\	R"                  rS	 rS
 rS rSS jrSS jrSS jrS rSS jrSrg)ProductAdditiveQuantizeri  z
 Product Additive Quantizers

The product additive quantizer is a variant of AQ and PQ.
It first splits the vector space into multiple orthogonal sub-spaces
just like PQ does. And then it quantizes each sub-space by an independent
additive quantizer.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   !ProductAdditiveQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   z,number of sub-vectors we split a vector intoc                 T    [         R                  " U [         R                  " U6 5        g)ah  
 Construct a product additive quantizer.

The additive quantizers passed in will be cloned into the
ProductAdditiveQuantizer object.

:type d: int
:param d:      dimensionality of the input vectors
:type aqs: std::vector< faiss::AdditiveQuantizer * >
:param aqs:    sub-additive quantizers
:type search_type: int, optional
:param search_type:  AQ search type
N)r   !ProductAdditiveQuantizer_swiginitnew_ProductAdditiveQuantizerr   s     r   rV   !ProductAdditiveQuantizer.__init__        	44T:;b;bdh;ijr$   c                 0    [         R                  " XX#5      $ r/   )r   ProductAdditiveQuantizer_init)r   r  aqsr  s       r   initProductAdditiveQuantizer.init(  s    77RRr$   c                 .    [         R                  " X5      $ )z$Train the product additive quantizer)r   %ProductAdditiveQuantizer_subquantizer)r   r  s     r   subquantizer%ProductAdditiveQuantizer.subquantizer+  s    ??HHr$   c                 0    [         R                  " XU5      $ r/   )r   ProductAdditiveQuantizer_trainr>  s      r   r?  ProductAdditiveQuantizer.train/      88!DDr$   Nc                 2    [         R                  " XX#U5      $ r  )r   4ProductAdditiveQuantizer_compute_codes_add_centroidsr  s        r   r  4ProductAdditiveQuantizer.compute_codes_add_centroids2  s     NNtX]bkllr$   c                 2    [         R                  " XX#U5      $ r/   )r   /ProductAdditiveQuantizer_compute_unpacked_codesr  s        r   compute_unpacked_codes/ProductAdditiveQuantizer.compute_unpacked_codes?  s    II$SX]fggr$   c                 2    [         R                  " XX#U5      $ r&  )r   (ProductAdditiveQuantizer_decode_unpackedr(  s        r   r)  (ProductAdditiveQuantizer.decode_unpackedB  s     BB4PQV^__r$   c                 0    [         R                  " XX#5      $ r!  )r   ProductAdditiveQuantizer_decoder#  s       r   r	  ProductAdditiveQuantizer.decodeM  s     99$qLLr$   c                 2    [         R                  " XX#XE5      $ )a\  
 Compute inner-product look-up tables. Used in the search functions.

:type xq: float
:param xq:     query vector, size (n, d)
:type LUT: float
:param LUT:    look-up table, size (n, total_codebook_size)
:type alpha: float, optional
:param alpha:  compute alpha * inner-product
:type ld_lut: int, optional
:param ld_lut:  leading dimension of LUT
)r   $ProductAdditiveQuantizer_compute_LUTr1  s         r   r5  $ProductAdditiveQuantizer.compute_LUTX  s     >>tQV__r$   r%   r/   rF  rG  )r   r   r:   r;   r<   r   r   r   r   r   $ProductAdditiveQuantizer_nsplits_get$ProductAdditiveQuantizer_nsplits_setnsplits'ProductAdditiveQuantizer_quantizers_get'ProductAdditiveQuantizer_quantizers_set
quantizersrV   delete_ProductAdditiveQuantizerr   r	  r  r?  r  r  r)  r	  r5  r>   r%   r$   r   r  r    s     -/IOdeGHzFF
HwHw  ~q  rG*LLj  OA  OA  BJk "AASIEmh	`	M`r$   r  c                   N    \ rS rSrSr\" S S SS9r\rS r	\
R                  rSrg	)
ProductLocalSearchQuantizerii  zProduct Local Search Quantizerc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   $ProductLocalSearchQuantizer.<lambda>l  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r-  l  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g)al  
 Construct a product LSQ object.

:type d: int
:param d:   dimensionality of the input vectors
:type nsplits: int
:param nsplits:  number of sub-vectors we split a vector into
:type Msub: int
:param Msub:     number of codebooks of each LSQ
:type nbits: int
:param nbits:    bits for each step
:type search_type: int, optional
:param search_type:  AQ search type
N)r   $ProductLocalSearchQuantizer_swiginitnew_ProductLocalSearchQuantizerr   s     r   rV   $ProductLocalSearchQuantizer.__init__o  s      	77j>h>hjn>opr$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r   "delete_ProductLocalSearchQuantizerr   r>   r%   r$   r   r+  r+  i  s/    )-/IOdeGHq  "DDr$   r+  c                   N    \ rS rSrSr\" S S SS9r\rS r	\
R                  rSrg	)
ProductResidualQuantizeri  zProduct Residual Quantizerc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   !ProductResidualQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r7    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g)aj  
 Construct a product RQ object.

:type d: int
:param d:   dimensionality of the input vectors
:type nsplits: int
:param nsplits:  number of sub-vectors we split a vector into
:type Msub: int
:param Msub:     number of codebooks of each RQ
:type nbits: int
:param nbits:    bits for each step
:type search_type: int, optional
:param search_type:  AQ search type
N)r   !ProductResidualQuantizer_swiginitnew_ProductResidualQuantizerr   s     r   rV   !ProductResidualQuantizer.__init__  s      	44T:;b;bdh;ijr$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r   delete_ProductResidualQuantizerr   r>   r%   r$   r   r5  r5    s/    %-/IOdeGHk  "AAr$   r5  c                      \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  5      r\" \
R                  \
R                  5      r\" \
R"                  \
R$                  5      rS rS	 rS
 rS r\
R0                  rSrg)
CodePackeri  a  
Packing consists in combining a fixed number of codes of constant size
(code_size) into a block of data where they may (or may not) be interleaved
for efficient consumption by distance computation kernels. This exists for
the "fast_scan" indexes on CPU and for some GPU kernels.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   CodePacker.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rA    rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   CodePacker.__init__  rX   r$   c                 0    [         R                  " XX#5      $ r/   )r   CodePacker_pack_1r   	flat_coder
  blocks       r   pack_1CodePacker.pack_1  s    ++DVKKr$   c                 0    [         R                  " XX#5      $ r/   )r   CodePacker_unpack_1r   rI  r
  rH  s       r   unpack_1CodePacker.unpack_1  s    --d6MMr$   c                 0    [         R                  " XU5      $ r/   )r   CodePacker_pack_allr   
flat_codesrI  s      r   pack_allCodePacker.pack_all  s    --dFFr$   c                 0    [         R                  " XU5      $ r/   )r   CodePacker_unpack_allr   rI  rT  s      r   
unpack_allCodePacker.unpack_all  s    //ZHHr$   r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r   CodePacker_code_size_getCodePacker_code_size_setr  CodePacker_nvec_getCodePacker_nvec_setnvecCodePacker_block_size_getCodePacker_block_size_set
block_sizerJ  rO  rU  rZ  delete_CodePackerr   r>   r%   r$   r   r?  r?    s     -/IOdeGKH<<j>a>abIJ22J4R4RSD*>>
@d@deJLNGI!33r$   r?  c                   f    \ rS rSrSr\" S S SS9r\rS r	S r
S	 rS
 rS r\R                  rSrg)CodePackerFlati  z5Trivial code packer where codes are stored one by onec                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   CodePackerFlat.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rh    rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   CodePackerFlat_swiginitnew_CodePackerFlat)r   r  s     r   rV   CodePackerFlat.__init__  s    **41N1Ny1YZr$   c                 0    [         R                  " XX#5      $ r/   )r   CodePackerFlat_pack_1rG  s       r   rJ  CodePackerFlat.pack_1  s    //OOr$   c                 0    [         R                  " XX#5      $ r/   )r   CodePackerFlat_unpack_1rN  s       r   rO  CodePackerFlat.unpack_1  s    11$vQQr$   c                 0    [         R                  " XU5      $ r/   )r   CodePackerFlat_pack_allrS  s      r   rU  CodePackerFlat.pack_all  s    11$EJJr$   c                 0    [         R                  " XU5      $ r/   )r   CodePackerFlat_unpack_allrY  s      r   rZ  CodePackerFlat.unpack_all  s    33DLLr$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   rJ  rO  rU  rZ  r   delete_CodePackerFlatr   r>   r%   r$   r   rf  rf    sE    @-/IOdeGH[PRKM!77r$   rf  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      r\" \	R,                  \	R.                  5      r\" \	R2                  \	R4                  5      rS rS rS	 rS
 rS r S r!\	RD                  r#Sr$g)Panoramai  az  
Implements the core logic of Panorama-based refinement.
arXiv: https://arxiv.org/abs/2510.00566

Panorama partitions the dimensions of all vectors into L contiguous levels.
During the refinement stage of ANNS, it computes distances between the query
and its candidates level-by-level. After processing each level, it prunes the
candidates whose lower bound exceeds the k-th best distance.

In order to enable speedups, the dimensions (or codes) of each vector are
stored in a batched, level-major manner. Within each batch of b vectors, the
dimensions corresponding to level 1 will be stored first (for all elements in
that batch), followed by level 2, and so on. This allows for efficient memory
access patterns.

Coupled with the appropriate orthogonal PreTransform (e.g. PCA, Cayley,
etc.), Panorama can prune the vast majority of dimensions, greatly
accelerating the refinement stage.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Panorama.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r~    rL   r$   rM   rN   c                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   Panorama_swiginitnew_Panorama)r   r  r  r  s       r   rV   Panorama.__init__  s     $$T:+B+B9Xb+cdr$   c                 .    [         R                  " U 5      $ r/   )r   Panorama_set_derived_valuesr[   s    r   r
  Panorama.set_derived_values  r  r$   c                 2    [         R                  " XX#U5      $ )z]
Helper method to copy codes into level-oriented batch layout at a given
offset in the list.
)r   #Panorama_copy_codes_to_level_layout)r   r  r
  n_entryr  s        r   copy_codes_to_level_layout#Panorama.copy_codes_to_level_layout  s    
 ==d6\`aar$   c                 2    [         R                  " XX#U5      $ )z
Helper method to compute the cumulative sums of the codes.
The cumsums also follow the level-oriented batch layout to minimize the
number of random memory accesses.
)r    Panorama_compute_cumulative_sums)r   cumsum_baser
  r  vectorss        r   compute_cumulative_sums Panorama.compute_cumulative_sums   s     ::4f_fggr$   c                 0    [         R                  " XU5      $ )z0Compute the cumulative sums of the query vector.)r   Panorama_compute_query_cum_sums)r   queryquery_cum_sumss      r   compute_query_cum_sumsPanorama.compute_query_cum_sums  s    99$~VVr$   c                 0    [         R                  " XX#5      $ r/   )r   Panorama_reconstruct)r   ry  rz  
codes_bases       r   r{  Panorama.reconstruct  s    ..t&MMr$   r%   N)%r   r   r:   r;   r<   r   r   r   r   r   Panorama_d_getPanorama_d_setr  Panorama_code_size_getPanorama_code_size_setr  Panorama_n_levels_getPanorama_n_levels_setr  Panorama_level_width_getPanorama_level_width_setlevel_widthPanorama_level_width_floats_getPanorama_level_width_floats_setlevel_width_floatsPanorama_batch_size_getPanorama_batch_size_setr  rV   r
  r  r  r  r{  delete_Panoramar   r>   r%   r$   r   r|  r|    s    ( -/IOdeGH**J,E,EFA::J<]<]^I
88*:Z:Z[H:>>
@c@cdK!*"L"LjNxNxy*<<j>`>`aJe<bhWN!11r$   r|  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      rS rS rS	 r\	R,                  rS
rg)PanoramaStatsi  z
Statistics are not robust to internal threading nor to
concurrent Panorama searches. Use these values in a
single-threaded context to accurately gauge Panorama's
pruning effectiveness.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PanoramaStats.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   PanoramaStats_swiginitnew_PanoramaStatsr[   s    r   rV   PanoramaStats.__init__   r   r$   c                 .    [         R                  " U 5      $ r/   )r   PanoramaStats_resetr[   s    r   r  PanoramaStats.reset#  rw   r$   c                 .    [         R                  " X5      $ r/   )r   PanoramaStats_addr   s     r   rH  PanoramaStats.add&  r  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   $PanoramaStats_total_dims_scanned_get$PanoramaStats_total_dims_scanned_settotal_dims_scannedPanoramaStats_total_dims_getPanoramaStats_total_dims_set
total_dims$PanoramaStats_ratio_dims_scanned_get$PanoramaStats_ratio_dims_scanned_setratio_dims_scannedrV   r  rH  delete_PanoramaStatsr   r>   r%   r$   r   r  r    s     -/IOdeGH!*"Q"QS]  TC  TC  D*AA:CjCjkJ!*"Q"QS]  TC  TC  DP49!66r$   r  c                      \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  5      r\" \
R                  \
R                  SS9r\" \
R"                  \
R$                  S	S9rS
 rS rS rS rS r\
R2                  rSrg)VectorTransformi,  z.Any transformation applied on a set of vectorsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   VectorTransform.<lambda>/  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  /  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   VectorTransform.__init__1  rX   r$   zinput dimensionzb
    set if the VectorTransform does not require training, or if
    training is done already
    c                 0    [         R                  " XU5      $ )z
 Perform training on a representative set of vectors. Does
nothing by default.

:type n: int
:param n:      nb of training vectors
:type x: float
:param x:      training vectors, size n * d
)r   VectorTransform_trainr>  s      r   r?  VectorTransform.train;       //;;r$   c                 0    [         R                  " XU5      $ )z
 apply the transformation and return the result in an allocated pointer
:type n: int
:param n: number of vectors to transform
:type x: float
:param x: input vectors, size n * d_in
:rtype: float
:return: output vectors, size n * d_out
)r   VectorTransform_applyr>  s      r   applyVectorTransform.applyG  r  r$   c                 0    [         R                  " XX#5      $ )z
 apply the transformation and return the result in a provided matrix
:type n: int
:param n: number of vectors to transform
:type x: float
:param x: input vectors, size n * d_in
:type xt: float
:param xt: output vectors, size n * d_out
)r   VectorTransform_apply_noallocr   ra   rE   xts       r   apply_noallocVectorTransform.apply_noallocS  s     77GGr$   c                 0    [         R                  " XX#5      $ )zQ
reverse transformation. May not be implemented or may return
approximate result
)r   !VectorTransform_reverse_transformr   ra   r  rE   s       r   reverse_transform!VectorTransform.reverse_transform_  s    
 ;;DRKKr$   c                 .    [         R                  " X5      $ r/   )r   VectorTransform_check_identicalr   s     r   check_identicalVectorTransform.check_identicalf      99$FFr$   r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r   VectorTransform_d_in_getVectorTransform_d_in_setd_inVectorTransform_d_out_getVectorTransform_d_out_setd_outVectorTransform_is_trained_getVectorTransform_is_trained_setr  r?  r  r  r  r  delete_VectorTransformr   r>   r%   r$   r   r  r  ,  s    9-/IOdeGKHJ779\9\]DZ99:;_;_e{|E*CCZEnEn u 	J

<
<
HLG!88r$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  SS9r\" \	R&                  \	R(                  S	S9rSS
 jrS rS rS rS r\" \	R6                  \	R8                  5      rS rS r\	R@                  r!Sr"g)LinearTransformil  zP
 Generic linear transformation, with bias term applied on output
y = A * x + b
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   LinearTransform.<lambda>r  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  r  rL   r$   rM   rN   zh
    whether to use the bias term
     check if matrix A is orthonormal (enables reverse_transform)
    z(Transformation matrix, size d_out * d_inzbias vector, size d_outc                 \    [         R                  " U [         R                  " XU5      5        gz0both d_in > d_out and d_out < d_in are supportedN)r   LinearTransform_swiginitnew_LinearTransform)r   r  r  	have_biass       r   rV   LinearTransform.__init__|  s!    ++D*2P2PQU^g2hir$   c                 0    [         R                  " XX#5      $ )z*same as apply, but result is pre-allocated)r   LinearTransform_apply_noallocr  s       r   r  LinearTransform.apply_noalloc  s    77GGr$   c                 0    [         R                  " XX#5      $ )zK
compute x = A^T * (x - b)
is reverse transform if A has orthonormal lines
)r   #LinearTransform_transform_transpose)r   ra   rG  rE   s       r   transform_transpose#LinearTransform.transform_transpose  s    
 ==dqLLr$   c                 0    [         R                  " XX#5      $ )zworks only if is_orthonormal)r   !LinearTransform_reverse_transformr  s       r   r  !LinearTransform.reverse_transform  s    ;;DRKKr$   c                 .    [         R                  " U 5      $ )z.compute A^T * A to set the is_orthonormal flag)r   "LinearTransform_set_is_orthonormalr[   s    r   set_is_orthonormal"LinearTransform.set_is_orthonormal  s    <<TBBr$   c                 2    [         R                  " XX#U5      $ r/   )r    LinearTransform_print_if_verbose)r   r   matra   r  s        r   print_if_verbose LinearTransform.print_if_verbose  s    ::4sqQQr$   c                 .    [         R                  " X5      $ r/   )r   LinearTransform_check_identicalr   s     r   r  LinearTransform.check_identical  r  r$   r%   Nr   r   F)#r   r   r:   r;   r<   r   r   r   r   r   LinearTransform_have_bias_getLinearTransform_have_bias_setr  "LinearTransform_is_orthonormal_get"LinearTransform_is_orthonormal_setis_orthonormalLinearTransform_A_getLinearTransform_A_setALinearTransform_b_getLinearTransform_b_setr  rV   r  r  r  r  LinearTransform_verbose_getLinearTransform_verbose_setr  r  r  delete_LinearTransformr   r>   r%   r$   r   r  r  l  s    
 -/IOdeGHAA:CkCklIjKKZMzMz A 	N 	11:3S3S  ZI  	JA11:3S3SYwxAjHMLC z==z?e?efGRG!88r$   r  c                   Z    \ rS rSrSr\" S S SS9r\rS r	S r
S	 r\R                  rS
rg)RandomRotationMatrixi  z Randomly rotate a set of vectorsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   RandomRotationMatrix.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 .    [         R                  " X5      $ )z+must be called before the transform is used)r   RandomRotationMatrix_initr  s     r   r	  RandomRotationMatrix.init  s    33D??r$   c                 0    [         R                  " XU5      $ r/   )r   RandomRotationMatrix_trainr>  s      r   r?  RandomRotationMatrix.train  rN  r$   c                 T    [         R                  " U [         R                  " U6 5        gr  )r   RandomRotationMatrix_swiginitnew_RandomRotationMatrixr   s     r   rV   RandomRotationMatrix.__init__  s    00z7Z7Z\`7abr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r	  r?  rV   r   delete_RandomRotationMatrixr   r>   r%   r$   r   r  r    s;    +-/IOdeGH@Ac "==r$   r  c                   $   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9r\" \	R2                  \	R4                  SS9r\" \	R8                  \	R:                  SS9r\" \	R>                  \	R@                  SS9r!SS jr"S r#S r$S r%\	RL                  r'Sr(g)	PCAMatrixi  zl
Applies a principal component analysis on a set of vectors,
with optionally whitening and random rotation.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PCAMatrix.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r.    rL   r$   rM   rN   z
     after transformation the components are multiplied by
    eigenvalues^eigen_power

    =0: no whitening
    =-0.5: full whitening
    z@value added to eigenvalues to avoid division by 0 when whiteningzrandom rotation after PCAz.ratio between # training vectors and dimensionz7try to distribute output eigenvectors in this many binszMean, size d_inz<eigenvalues of covariance matrix (= squared singular values)zPCA matrix, size d_in * d_inc           	      \    [         R                  " U [         R                  " XX45      5        g r/   )r   PCAMatrix_swiginitnew_PCAMatrix)r   r  r  eigen_powerrandom_rotations        r   rV   PCAMatrix.__init__  s     %%dJ,D,DTR],opr$   c                 0    [         R                  " XU5      $ )zW
train on n vectors. If n < d_in then the eigenvector matrix
will be completed with 0s
)r   PCAMatrix_trainr>  s      r   r?  PCAMatrix.train  s    
 ))$155r$   c                 .    [         R                  " X5      $ )zcopy pre-trained PCA matrix)r   PCAMatrix_copy_fromr   s     r   	copy_fromPCAMatrix.copy_from  s    --d::r$   c                 .    [         R                  " U 5      $ )z6called after mean, PCAMat and eigenvalues are computed)r   PCAMatrix_prepare_Abr[   s    r   
prepare_AbPCAMatrix.prepare_Ab      ..t44r$   r%   N)r   r   r   F))r   r   r:   r;   r<   r   r   r   r   r   PCAMatrix_eigen_power_getPCAMatrix_eigen_power_setr3  PCAMatrix_epsilon_getPCAMatrix_epsilon_setepsilonPCAMatrix_random_rotation_getPCAMatrix_random_rotation_setr4  PCAMatrix_max_points_per_d_getPCAMatrix_max_points_per_d_setmax_points_per_dPCAMatrix_balanced_bins_getPCAMatrix_balanced_bins_setbalanced_binsPCAMatrix_mean_getPCAMatrix_mean_setmeanPCAMatrix_eigenvalues_getPCAMatrix_eigenvalues_seteigenvaluesPCAMatrix_PCAMat_getPCAMatrix_PCAMat_setPCAMatrV   r?  r;  r?  delete_PCAMatrixr   r>   r%   r$   r   r,  r,    sH   
 -/IOdeGH:??AeAe l 	K z779Y9Y  `g  hGzGGIqIq  xX  YO
 I I:KtKt  {p  qZCCZEkEk  rp  qMJ11:3P3PVlmD:??AeAe  lo  pKj55z7V7V\  AFq6;5 "22r$   r,  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      rSS jrS r\	R*                  rS	rg
)	ITQMatrixi  z
 ITQ implementation from

    Iterative quantization: A procrustean approach to learning binary codes
    for large-scale image retrieval,

Yunchao Gong, Svetlana Lazebnik, Albert Gordo, Florent Perronnin,
PAMI'12.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ITQMatrix.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r\    rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   ITQMatrix_swiginitnew_ITQMatrixr  s     r   rV   ITQMatrix.__init__  s    %%dJ,D,DQ,GHr$   c                 0    [         R                  " XU5      $ r/   )r   ITQMatrix_trainr>  s      r   r?  ITQMatrix.train  r	  r$   r%   Nr  )r   r   r:   r;   r<   r   r   r   r   r   ITQMatrix_max_iter_getITQMatrix_max_iter_setmax_iterITQMatrix_seed_getITQMatrix_seed_setr  ITQMatrix_init_rotation_getITQMatrix_init_rotation_setinit_rotationrV   r?  delete_ITQMatrixr   r>   r%   r$   r   rZ  rZ    s~     -/IOdeGH
99:;\;\]HJ11:3P3PQDZCCZEkEklMI6!22r$   rZ  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  SS9r\" \	R,                  \	R.                  5      rSS jrS	 rS
 rS r\	R:                  rSrg)ITQTransformi  zGThe full ITQ transform, including normalizations and PCA transformationc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ITQTransform.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rq    rL   r$   rM   rN   z!max training points per dimensionc                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   ITQTransform_swiginitnew_ITQTransform)r   r  r  do_pcas       r   rV   ITQTransform.__init__  s     ((z/J/J4X^/_`r$   c                 0    [         R                  " XU5      $ r/   )r   ITQTransform_trainr>  s      r   r?  ITQTransform.train      ,,Ta88r$   c                 0    [         R                  " XX#5      $ r/   )r   ITQTransform_apply_noallocr  s       r   r  ITQTransform.apply_noalloc  s    44TaDDr$   c                 .    [         R                  " X5      $ r/   )r   ITQTransform_check_identicalr   s     r   r  ITQTransform.check_identical  s    66tCCr$   r%   Nr  ) r   r   r:   r;   r<   r   r   r   r   r   ITQTransform_mean_getITQTransform_mean_setrQ  ITQTransform_do_pca_getITQTransform_do_pca_setrv  ITQTransform_itq_getITQTransform_itq_setitq"ITQTransform_max_train_per_dim_get"ITQTransform_max_train_per_dim_setmax_train_per_dimITQTransform_pca_then_itq_getITQTransform_pca_then_itq_setpca_then_itqrV   r?  r  r  delete_ITQTransformr   r>   r%   r$   r   ro  ro    s    R-/IOdeGHJ44j6V6VWDj88*:\:\]F
:22J4S4S
TC !N!NPZP}P}  Dl  mJDDjFnFnoLa9ED!55r$   ro  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9r\" \	R2                  \	R4                  5      r\" \	R8                  \	R:                  SS9rSS jrS r \	RB                  r"Sr#g)	OPQMatrixi  aD  
 Applies a rotation to align the dimensions with a PQ to minimize
 the reconstruction error. Can be used before an IndexPQ or an
 IndexIVFPQ. The method is the non-parametric version described in:

"Optimized Product Quantization for Approximate Nearest Neighbor Search"
Tiezheng Ge, Kaiming He, Qifa Ke, Jian Sun, CVPR'13
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   OPQMatrix.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   znb of subquantizersz#Number of outer training iterationsz(Number of training iterations for the PQz#same, for the first outer iterationz/if there are too many training points, resamplezk
    if non-NULL, use this product quantizer for training
    should be constructed with (d_out, M, _)
    c                 \    [         R                  " U [         R                  " XU5      5        g)z-if d2 != -1, output vectors of this dimensionN)r   OPQMatrix_swiginitnew_OPQMatrix)r   r  rX
  d2s       r   rV   OPQMatrix.__init__(  s    %%dJ,D,DQ2,NOr$   c                 0    [         R                  " XU5      $ r/   )r   OPQMatrix_trainr>  s      r   r?  OPQMatrix.train,  r	  r$   r%   N)r   r   rE  )$r   r   r:   r;   r<   r   r   r   r   r   OPQMatrix_M_getOPQMatrix_M_setrX
  OPQMatrix_niter_getOPQMatrix_niter_setr2	  OPQMatrix_niter_pq_getOPQMatrix_niter_pq_setniter_pqOPQMatrix_niter_pq_0_getOPQMatrix_niter_pq_0_set
niter_pq_0OPQMatrix_max_train_points_getOPQMatrix_max_train_points_setmax_train_pointsOPQMatrix_verbose_getOPQMatrix_verbose_setr  OPQMatrix_pq_getOPQMatrix_pq_setpqrV   r?  delete_OPQMatrixr   r>   r%   r$   r   r  r    s    -/IOdeGH++Z-G-GMghAZ33Z5S5S  ZD  EE
99:;\;\  cR  SH*==z?b?b  iS  TJ
 I I:KtKt  {q  rz779Y9YZG	*--z/J/J Q 
	B
P6!22r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS rS	 rS
 rS r\	R"                  rSrg)RemapDimensionsTransformi2  z
 remap dimensions for input vectors, possibly inserting 0s
strictly speaking this is also a linear transform but we don't want
to compute it with matrix multiplies
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   !RemapDimensionsTransform.<lambda>9  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  9  rL   r$   rM   rN   zR
    map from output dimension to input, size d_out
    -1 -> set output to 0
    c                 0    [         R                  " XX#5      $ r/   )r   &RemapDimensionsTransform_apply_noallocr  s       r   r  &RemapDimensionsTransform.apply_noalloc@  s    @@!PPr$   c                 0    [         R                  " XX#5      $ )z@reverse transform correct only when the mapping is a permutation)r   *RemapDimensionsTransform_reverse_transformr  s       r   r  *RemapDimensionsTransform.reverse_transformC  s    DDTbTTr$   c                 T    [         R                  " U [         R                  " U6 5        g)aQ  
*Overload 1:*
remap input to output, skipping or inserting dimensions as needed
if uniform: distribute dimensions uniformly
otherwise just take the d_out first ones.

|

*Overload 2:*
remap input to output, skipping or inserting dimensions as needed
if uniform: distribute dimensions uniformly
otherwise just take the d_out first ones.
N)r   !RemapDimensionsTransform_swiginitnew_RemapDimensionsTransformr   s     r   rV   !RemapDimensionsTransform.__init__G  r  r$   c                 .    [         R                  " X5      $ r/   )r   (RemapDimensionsTransform_check_identicalr   s     r   r  (RemapDimensionsTransform.check_identicalW  s    BB4OOr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r    RemapDimensionsTransform_map_get RemapDimensionsTransform_map_setmapr  r  rV   r  delete_RemapDimensionsTransformr   r>   r%   r$   r   r  r  2  sc     -/IOdeGH
:>>
@k@k r 	C
QUk P!AAr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS rS	 rS
 r\	R"                  rSrg)NormalizationTransformi]  zper-vector normalizationc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   NormalizationTransform.<lambda>`  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  `  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   NormalizationTransform_swiginitnew_NormalizationTransformr   s     r   rV   NormalizationTransform.__init__d      2249^9^`d9efr$   c                 0    [         R                  " XX#5      $ r/   )r   $NormalizationTransform_apply_noallocr  s       r   r  $NormalizationTransform.apply_noallocg  s    >>tNNr$   c                 0    [         R                  " XX#5      $ )z/Identity transform since norm is not revertible)r   (NormalizationTransform_reverse_transformr  s       r   r  (NormalizationTransform.reverse_transformj  s    BB4BRRr$   c                 .    [         R                  " X5      $ r/   )r   &NormalizationTransform_check_identicalr   s     r   r  &NormalizationTransform.check_identicaln  s    @@MMr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   NormalizationTransform_norm_getNormalizationTransform_norm_setr
  rV   r  r  r  delete_NormalizationTransformr   r>   r%   r$   r   r  r  ]  sW    #-/IOdeGHJ>>
@j@jkDgOSN!??r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rSS jrS	 rS
 rS rS r\	R$                  rSrg)CenteringTransformit  z5Subtract the mean of each component from the vectors.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   CenteringTransform.<lambda>w  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  w  rL   r$   rM   rN   zMean, size d_in = d_outc                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   CenteringTransform_swiginitnew_CenteringTransformr  s     r   rV   CenteringTransform.__init__{  s    ..tZ5V5VWX5YZr$   c                 0    [         R                  " XU5      $ )ztrain on n vectors.)r   CenteringTransform_trainr>  s      r   r?  CenteringTransform.train~  s    224A>>r$   c                 0    [         R                  " XX#5      $ )zsubtract the mean)r    CenteringTransform_apply_noallocr  s       r   r   CenteringTransform.apply_noalloc  s    ::4AJJr$   c                 0    [         R                  " XX#5      $ )zadd the mean)r   $CenteringTransform_reverse_transformr  s       r   r  $CenteringTransform.reverse_transform  s    >>tNNr$   c                 .    [         R                  " X5      $ r/   )r   "CenteringTransform_check_identicalr   s     r   r  "CenteringTransform.check_identical  r  r$   r%   Nr  )r   r   r:   r;   r<   r   r   r   r   r   CenteringTransform_mean_getCenteringTransform_mean_setrQ  rV   r?  r  r  r  delete_CenteringTransformr   r>   r%   r$   r   r  r  t  sf    @-/IOdeGHJ::J<b<b  iG  HD[?KOJ!;;r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS r\R                  rSrg)	SearchParametersPreTransformi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   %SearchParametersPreTransform.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   %SearchParametersPreTransform_swiginit new_SearchParametersPreTransformr[   s    r   rV   %SearchParametersPreTransform.__init__      88z?j?j?lmr$   r%   N)r   r   r:   r;   r   r   r   r   r   -SearchParametersPreTransform_index_params_get-SearchParametersPreTransform_index_params_setindex_paramsrV   #delete_SearchParametersPreTransformr   r>   r%   r$   r   r  r    sN    -/IOdeGHJTTV`  WO  WO  PLn!EEr$   r  c                   z   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  SS9rS	 rS
 rS rS rS rS rS rSS jrSS jrS rS rSS jrS rS r S r!S r"S r#S r$S S jr%S r&\	RN                  r(Sr)g)!IndexPreTransformi  zc
Index that applies a LinearTransform transform on vectors before
handing them over to a sub-index
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexPreTransform.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   zchain of transformsthe sub-indexc                 T    [         R                  " U [         R                  " U6 5        g)z{
*Overload 1:*
whether pointers are deleted in destructor

|

*Overload 2:*
 ltrans is the last transform before the index
N)r   IndexPreTransform_swiginitnew_IndexPreTransformr   s     r   rV   IndexPreTransform.__init__  s      	--dJ4T4TVZ4[\r$   c                 .    [         R                  " X5      $ r/   )r   #IndexPreTransform_prepend_transform)r   ltranss     r   prepend_transform#IndexPreTransform.prepend_transform  s    ==dKKr$   c                 0    [         R                  " XU5      $ r/   )r   IndexPreTransform_trainr>  s      r   r?  IndexPreTransform.train      11$1==r$   c                 0    [         R                  " XU5      $ r/   )r   IndexPreTransform_addr>  s      r   rH  IndexPreTransform.add  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexPreTransform_add_with_idsrP  s       r   rR  IndexPreTransform.add_with_ids      88!JJr$   c                 .    [         R                  " U 5      $ r/   )r   IndexPreTransform_resetr[   s    r   r  IndexPreTransform.reset  r   r$   c                 .    [         R                  " X5      $ )z9removes IDs from the index. Not supported by all indexes.)r   IndexPreTransform_remove_idsrs  s     r   rt  IndexPreTransform.remove_ids  s    66tAAr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexPreTransform_searchr[  s          r   r]  IndexPreTransform.search  r  r$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexPreTransform_range_searchrf  s         r   rg  IndexPreTransform.range_search  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexPreTransform_reconstructrx  s      r   r{  IndexPreTransform.reconstruct  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexPreTransform_reconstruct_nr  s       r   r  IndexPreTransform.reconstruct_n  s    99$BOOr$   c           
      4    [         R                  " XX#XEXg5      $ r/   )r   (IndexPreTransform_search_and_reconstructr  s           r   r  (IndexPreTransform.search_and_reconstruct  s    BB4AR[ekttr$   c                 0    [         R                  " XU5      $ )zp
apply the transforms in the chain. The returned float * may be
equal to x, otherwise it should be deallocated.
)r   IndexPreTransform_apply_chainr>  s      r   apply_chainIndexPreTransform.apply_chain  s    
 77CCr$   c                 0    [         R                  " XX#5      $ )z
Reverse the transforms in the chain. May not be implemented for
all transforms in the chain or may return approximate results.
)r   IndexPreTransform_reverse_chainr  s       r   reverse_chainIndexPreTransform.reverse_chain  s    
 99$2IIr$   c                 .    [         R                  " U 5      $ r/   )r   'IndexPreTransform_get_distance_computerr[   s    r   r  'IndexPreTransform.get_distance_computer  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexPreTransform_sa_code_sizer[   s    r   r  IndexPreTransform.sa_code_size  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexPreTransform_sa_encoder  s       r   r  IndexPreTransform.sa_encode  s    55dqHHr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexPreTransform_sa_decoder  s       r   r  IndexPreTransform.sa_decode  s    55duHHr$   c                 0    [         R                  " XU5      $ r/   )r   IndexPreTransform_merge_fromr  s      r   r  IndexPreTransform.merge_from  r  r$   c                 .    [         R                  " X5      $ r/   )r   ,IndexPreTransform_check_compatible_for_merger  s     r   r  ,IndexPreTransform.check_compatible_for_merge  s    FFtXXr$   r%   r/   r  )*r   r   r:   r;   r<   r   r   r   r   r   IndexPreTransform_chain_getIndexPreTransform_chain_setchainIndexPreTransform_index_getIndexPreTransform_index_setr}	   IndexPreTransform_own_fields_get IndexPreTransform_own_fields_set
own_fieldsrV   r  r?  rH  rR  r  rt  r]  rg  r{  r  r  r3  r7  r  r  r  r  r  r  delete_IndexPreTransformr   r>   r%   r$   r   r  r    s    
 -/IOdeGHZ;;Z=c=cdEZ;;Z=c=c  jD  EE*EEzGrGr  yM  NJ
]L><K8B]]KPuDJH?IIQY!::r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\R                  rS rSrg)	IndexRefineSearchParametersi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   $IndexRefineSearchParameters.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rW    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   $IndexRefineSearchParameters_swiginitnew_IndexRefineSearchParametersr[   s    r   rV   $IndexRefineSearchParameters.__init__  rf  r$   r%   N)r   r   r:   r;   r   r   r   r   r   (IndexRefineSearchParameters_k_factor_get(IndexRefineSearchParameters_k_factor_setk_factor1IndexRefineSearchParameters_base_index_params_get1IndexRefineSearchParameters_base_index_params_setbase_index_params"delete_IndexRefineSearchParametersr   rV   r>   r%   r$   r   rU  rU    sr    -/IOdeGH
KKZ  NA  NA  BH !]!]_i  `\  `\  ]!DDlr$   rU  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9rS rS rS rS rSS jrSS jrS rS r S r!S r"\	RF                  r$Sr%g)IndexRefinei  z
Index that queries in a base_index (a fast one) and refines the
results with an exact search, hopefully improving the results.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexRefine.<lambda>
  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rg  
  rL   r$   rM   rN   z>faster index to pre-select the vectors that should be filteredzrefinement indexz%should the base index be deallocated?zsame with the refinement indexzk
    factor between k requested in search and the k requested from
    the base_index (should be >= 1)
    c                 T    [         R                  " U [         R                  " U6 5        g)zinitialize from empty indexN)r   IndexRefine_swiginitnew_IndexRefiner   s     r   rV   IndexRefine.__init__  s    ''j.H.H$.OPr$   c                 0    [         R                  " XU5      $ r/   )r   IndexRefine_trainr>  s      r   r?  IndexRefine.train      ++DQ77r$   c                 0    [         R                  " XU5      $ r/   )r   IndexRefine_addr>  s      r   rH  IndexRefine.add  r	  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexRefine_resetr[   s    r   r  IndexRefine.reset  r3  r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexRefine_searchr[  s          r   r]  IndexRefine.search"      ,,TaIvVVr$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexRefine_range_searchrf  s         r   rg  IndexRefine.range_search%      224AvVVr$   c                 0    [         R                  " XU5      $ r/   )r   IndexRefine_reconstructrx  s      r   r{  IndexRefine.reconstruct(      11$VDDr$   c                 .    [         R                  " U 5      $ r/   )r   IndexRefine_sa_code_sizer[   s    r   r  IndexRefine.sa_code_size+  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexRefine_sa_encoder  s       r   r  IndexRefine.sa_encode.      //BBr$   c                 0    [         R                  " XX#5      $ )zS
The sa_decode decodes from the index_refine, which is assumed to be more
accurate
)r   IndexRefine_sa_decoder  s       r   r  IndexRefine.sa_decode1  s    
 //BBr$   r%   r/   )&r   r   r:   r;   r<   r   r   r   r   r   IndexRefine_base_index_getIndexRefine_base_index_set
base_indexIndexRefine_refine_index_getIndexRefine_refine_index_setrefine_indexIndexRefine_own_fields_getIndexRefine_own_fields_setrR   IndexRefine_own_refine_index_get IndexRefine_own_refine_index_setown_refine_indexIndexRefine_k_factor_getIndexRefine_k_factor_setr_  rV   r?  rH  r  r]  rg  r{  r  r  r  delete_IndexRefiner   r>   r%   r$   r   re  re    s   
 -/IOdeGH*??AfAf  mr  sJJCCZElEl  sJ  KL*??AfAf  mY  ZJ
 K KZMxMx  d  e
;;Z=`=` g 	H
Q862WWE9CC "44r$   re  c                   X    \ rS rSrSr\" S S SS9r\rS r	SS	 jr
\R                  rS
rg)IndexRefineFlati;  z
 Version where the refinement index is an IndexFlat. It has one additional
constructor that takes a table of elements to add to the flat refinement
index
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexRefineFlat.<lambda>B  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  B  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexRefineFlat_swiginitnew_IndexRefineFlatr   s     r   rV   IndexRefineFlat.__init__E      ++D*2P2PRV2WXr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexRefineFlat_searchr[  s          r   r]  IndexRefineFlat.searchH      00!	SYZZr$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   rV   r]  r   delete_IndexRefineFlatr   r>   r%   r$   r   r  r  ;  s7     -/IOdeGHY[!88r$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9rS rS rSS jrS r\	R:                  rS rS r S r!Sr"g)IndexLSHiN  z>The sign of each vector component is put in a binary signaturec                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexLSH.<lambda>Q  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  Q  rL   r$   rM   rN   znb of bits per vectorz+whether to apply a random rotation to inputz$whether we train thresholds or use 0zoptional random rotationzthresholds to compare withc                 0    [         R                  " XU5      $ )a  
 Preprocesses and resizes the input to the size required to
binarize the data

:type x: float
:param x: input vectors, size n * d
:rtype: float
:return: output vectors, size n * bits. May be the same pointer
            as x, otherwise it should be deleted by the caller
)r   IndexLSH_apply_preprocessr>  s      r   apply_preprocessIndexLSH.apply_preprocessY  s     33DQ??r$   c                 0    [         R                  " XU5      $ r/   )r   IndexLSH_trainr>  s      r   r?  IndexLSH.trainf  s    ((!44r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexLSH_searchr[  s          r   r]  IndexLSH.searchi  s    ))$1FSSr$   c                 .    [         R                  " X5      $ )zP
transfer the thresholds to a pre-processing stage (and unset
train_thresholds)
)r   IndexLSH_transfer_thresholds)r   vts     r   transfer_thresholdsIndexLSH.transfer_thresholdsl  s    
 66t@@r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexLSH_swiginitnew_IndexLSHr   s     r   rV   IndexLSH.__init__t      $$T:+B+BD+IJr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexLSH_sa_encoder  s       r   r  IndexLSH.sa_encodew  s    ,,Ta??r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexLSH_sa_decoder  s       r   r  IndexLSH.sa_decodez  s    ,,Te??r$   r%   r/   )#r   r   r:   r;   r<   r   r   r   r   r   IndexLSH_nbits_getIndexLSH_nbits_setr  IndexLSH_rotate_data_getIndexLSH_rotate_data_setrotate_dataIndexLSH_train_thresholds_getIndexLSH_train_thresholds_settrain_thresholdsIndexLSH_rrot_getIndexLSH_rrot_setrrotIndexLSH_thresholds_getIndexLSH_thresholds_set
thresholdsr  r?  r]  r  delete_IndexLSHr   rV   r  r  r>   r%   r$   r   r  r  N  s    I-/IOdeGHZ22J4Q4QWstE:>>
@c@c  j\  ]K
 H H*JrJr  yd  eJ00*2N2NTstD*<<j>`>`  gH  IJ@5TA "11K@@r$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      r\" \	R,                  \	R.                  5      r\" \	R2                  \	R4                  5      r\" \	R8                  \	R:                  5      r\" \	R>                  \	R@                  5      r!S r"\	RF                  r$Sr%g	)
SimulatedAnnealingParametersi  z2parameters used for the simulated annealing methodc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   %SimulatedAnnealingParameters.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   %SimulatedAnnealingParameters_swiginit new_SimulatedAnnealingParametersr[   s    r   rV   %SimulatedAnnealingParameters.__init__  r  r$   r%   N)&r   r   r:   r;   r<   r   r   r   r   r   1SimulatedAnnealingParameters_init_temperature_get1SimulatedAnnealingParameters_init_temperature_setinit_temperature2SimulatedAnnealingParameters_temperature_decay_get2SimulatedAnnealingParameters_temperature_decay_settemperature_decay'SimulatedAnnealingParameters_n_iter_get'SimulatedAnnealingParameters_n_iter_setn_iter'SimulatedAnnealingParameters_n_redo_get'SimulatedAnnealingParameters_n_redo_setn_redo%SimulatedAnnealingParameters_seed_get%SimulatedAnnealingParameters_seed_setr  (SimulatedAnnealingParameters_verbose_get(SimulatedAnnealingParameters_verbose_setr  /SimulatedAnnealingParameters_only_bit_flips_get/SimulatedAnnealingParameters_only_bit_flips_setonly_bit_flips,SimulatedAnnealingParameters_init_random_get,SimulatedAnnealingParameters_init_random_setinit_randomrV   #delete_SimulatedAnnealingParametersr   r>   r%   r$   r   r  r    s"   =-/IOdeGH
 \ \^h  _[  _[  \ !^!^`j  a^  a^  _jHH*J|J|}FjHH*J|J|}FJDDjFvFvwDzJJJLL  AGjXXZd  [U  [U  VN:RRT^  UL  UL  MKn!EEr$   r  c                       \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  5      rS rS	 r\
R                   rS
rg)PermutationObjectivei  z$abstract class for the loss functionc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PermutationObjective.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   PermutationObjective.__init__  rX   r$   c                 .    [         R                  " X5      $ r/   )r   !PermutationObjective_compute_costrp  s     r   compute_cost!PermutationObjective.compute_cost  r  r$   c                 0    [         R                  " XX#5      $ r/   )r    PermutationObjective_cost_updater   r  iwjws       r   cost_update PermutationObjective.cost_update  s    ::4rNNr$   r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r   PermutationObjective_n_getPermutationObjective_n_setra   r  r  delete_PermutationObjectiver   r>   r%   r$   r   r  r    sQ    /-/IOdeGKH66
8]8]^AHO!==r$   r  c                   j   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\S 5       rS r\" \R                  \R                   SS9r\" \R$                  \R&                  S	S9r\" \R*                  \R,                  S
S9rS rS rS rS r\S 5       rS r\R<                  rSr g)ReproduceDistancesObjectivei  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   $ReproduceDistancesObjective.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 .    [         R                  " U 5      $ r/   )r   ReproduceDistancesObjective_sqrrD   s    r   sqrReproduceDistancesObjective.sqr  s    99!<<r$   c                 .    [         R                  " X5      $ r/   )r   &ReproduceDistancesObjective_dis_weightrk   s     r   
dis_weight&ReproduceDistancesObjective.dis_weight  s    @@IIr$   z%"real" corrected distances (size n^2)zwanted distances (size n^2)z$weights for each distance (size n^2)c                 0    [         R                  " XU5      $ r/   )r   *ReproduceDistancesObjective_get_source_disr  s      r   get_source_dis*ReproduceDistancesObjective.get_source_dis  s    DDTaPPr$   c                 .    [         R                  " X5      $ r/   )r   (ReproduceDistancesObjective_compute_costrp  s     r   r  (ReproduceDistancesObjective.compute_cost  r'  r$   c                 0    [         R                  " XX#5      $ r/   )r   'ReproduceDistancesObjective_cost_updater  s       r   r  'ReproduceDistancesObjective.cost_update  s    AA$bUUr$   c           	      \    [         R                  " U [         R                  " XX45      5        g r/   )r   $ReproduceDistancesObjective_swiginitnew_ReproduceDistancesObjective)r   ra   source_dis_intarget_dis_indis_weight_factors        r   rV   $ReproduceDistancesObjective.__init__  s+    77j>h>hij  |I  ?]  	^r$   c                 0    [         R                  " XX#5      $ r/   )r   .ReproduceDistancesObjective_compute_mean_stdev)r  r^  mean_out
stddev_outs       r   compute_mean_stdev.ReproduceDistancesObjective.compute_mean_stdev  s    HHRZggr$   c                 .    [         R                  " X5      $ r/   )r   1ReproduceDistancesObjective_set_affine_target_dis)r   r'  s     r   set_affine_target_dis1ReproduceDistancesObjective.set_affine_target_dis  s    KKD``r$   r%   N)!r   r   r:   r;   r   r   r   r   r   1ReproduceDistancesObjective_dis_weight_factor_get1ReproduceDistancesObjective_dis_weight_factor_setr)  staticmethodr  r  *ReproduceDistancesObjective_source_dis_get*ReproduceDistancesObjective_source_dis_set
source_dis*ReproduceDistancesObjective_target_dis_get*ReproduceDistancesObjective_target_dis_set
target_dis'ReproduceDistancesObjective_weights_get'ReproduceDistancesObjective_weights_setr	  r  r  r  rV   r/  r3  "delete_ReproduceDistancesObjectiver   r>   r%   r$   r   r  r    s   -/IOdeGH !]!]_i  `\  `\  ]= =J*OOQ[  RG  RG  My  zJ*OOQ[  RG  RG  Mo  pJzII:K}K}  Do  pGQOV^ h ha!DDr$   r  c                   x   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  5      rS r\" \	R(                  \	R*                  5      r\" \	R.                  \	R0                  S	S9rS
 rS r\	R8                  rSrg)SimulatedAnnealingOptimizeri  z<Simulated annealing optimization algorithm for permutations.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   $SimulatedAnnealingOptimizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rD    rL   r$   rM   rN   zsize of the permutationc                 Z    [         R                  " U [         R                  " X5      5        g)z logs values of the cost functionN)r   $SimulatedAnnealingOptimizer_swiginitnew_SimulatedAnnealingOptimizer)r   ra	  r  s      r   rV   $SimulatedAnnealingOptimizer.__init__  s    77j>h>hil>pqr$   z%remember initial cost of optimizationc                 .    [         R                  " X5      $ r/   )r   $SimulatedAnnealingOptimizer_optimizerp  s     r   optimize$SimulatedAnnealingOptimizer.optimize  s    >>tJJr$   c                 .    [         R                  " X5      $ r/   )r   ,SimulatedAnnealingOptimizer_run_optimization)r   	best_perms     r   run_optimization,SimulatedAnnealingOptimizer.run_optimization  s    FFtWWr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   #SimulatedAnnealingOptimizer_obj_get#SimulatedAnnealingOptimizer_obj_setra	  !SimulatedAnnealingOptimizer_n_get!SimulatedAnnealingOptimizer_n_setra   'SimulatedAnnealingOptimizer_logfile_get'SimulatedAnnealingOptimizer_logfile_setlogfilerV   #SimulatedAnnealingOptimizer_rnd_get#SimulatedAnnealingOptimizer_rnd_setrnd)SimulatedAnnealingOptimizer_init_cost_get)SimulatedAnnealingOptimizer_init_cost_set	init_costrL  rQ  "delete_SimulatedAnnealingOptimizerr   r>   r%   r$   r   rB  rB    s    G-/IOdeGH
:AA:CqCq
rC==z?k?k  rP  	QAzII:K}K}~Gr :AA:CqCq
rCMMz  PD  PD  Jv  wIKX!DDr$   rB  c                      \ rS rSrSr\" S S SS9r\r\	R                  r\	R                  r \	R                  r \" \	R                   \	R"                  5      r\" \	R&                  \	R(                  SS9r\" \	R,                  \	R.                  SS9r\" \	R2                  \	R4                  S	S9r\" \	R8                  \	R:                  5      rS
 rS r S r!S r"S r#\	RH                  r%Sr&g)PolysemousTrainingi  z4optimizes the order of indices in a ProductQuantizerc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PolysemousTraining.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rd    rL   r$   rM   rN   z
     use 1/4 of the training points for the optimization, with
    max. ntrain_permutation. If ntrain_permutation == 0: train on
    centroids
    z'decay of exp that weights distance lossz@refuse to train if it would require more than that amount of RAMc                 X    [         R                  " U [         R                  " 5       5        g r/   )r   PolysemousTraining_swiginitnew_PolysemousTrainingr[   s    r   rV   PolysemousTraining.__init__      ..tZ5V5V5XYr$   c                 0    [         R                  " XX#5      $ )zw
reorder the centroids so that the Hamming distance becomes a
good approximation of the SDC distance (called by train)
)r   *PolysemousTraining_optimize_pq_for_hammingr   r  ra   rE   s       r   optimize_pq_for_hamming*PolysemousTraining.optimize_pq_for_hamming  s    
 DDTqTTr$   c                 0    [         R                  " XX#5      $ z!called by optimize_pq_for_hamming)r   #PolysemousTraining_optimize_rankingrm  s       r   optimize_ranking#PolysemousTraining.optimize_ranking  s    ==dMMr$   c                 .    [         R                  " X5      $ rq  )r   /PolysemousTraining_optimize_reproduce_distancesr   r  s     r   optimize_reproduce_distances/PolysemousTraining.optimize_reproduce_distances  s    II$SSr$   c                 .    [         R                  " X5      $ )z%make sure we don't blow up the memory)r   *PolysemousTraining_memory_usage_per_threadrw  s     r   memory_usage_per_thread*PolysemousTraining.memory_usage_per_thread  s    DDTNNr$   r%   N)'r   r   r:   r;   r<   r   r   r   r   r   PolysemousTraining_OT_NoneOT_None/PolysemousTraining_OT_ReproduceDistances_affineOT_ReproduceDistances_affine+PolysemousTraining_OT_Ranking_weighted_diffOT_Ranking_weighted_diff(PolysemousTraining_optimization_type_get(PolysemousTraining_optimization_type_setoptimization_type)PolysemousTraining_ntrain_permutation_get)PolysemousTraining_ntrain_permutation_setntrain_permutation(PolysemousTraining_dis_weight_factor_get(PolysemousTraining_dis_weight_factor_setr)  !PolysemousTraining_max_memory_get!PolysemousTraining_max_memory_set
max_memory"PolysemousTraining_log_pattern_get"PolysemousTraining_log_pattern_setlog_patternrV   rn  rs  rx  r|  delete_PolysemousTrainingr   r>   r%   r$   r   rb  rb    s+   ?-/IOdeGH33G#-#]#] )UU !!T!TV`  WJ  WJ  K!*"V"VXb  YM  YM S 	
 !!T!TV`  WJ  WJ  P~  *FF
HtHt  {B  CJ:HH*JwJwxKZUNTO ";;r$   rb  c                   r   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS rS	 rSS jrS rS rS r\" \	R&                  \	R(                  SS9r\" \	R,                  \	R.                  SS9r\	R2                  r \	R6                  r \	R:                  r \	R>                  r  \	RB                  r" \	RF                  r$ \" \	RJ                  \	RL                  5      r'\" \	RP                  \	RR                  5      r*\" \	RV                  \	RX                  SS9r-S r.S r/S r0\	Rb                  r2Sr3g
)IndexPQi  zS
 Index based on a product quantizer. Stored vectors are
approximated by PQ codes.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexPQ.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   z0The product quantizer used to encode the vectorsc                 T    [         R                  " U [         R                  " U6 5        gz
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:type M: int
:param M:      number of subquantizers
:type nbits: int
:param nbits:  number of bit per subvector index
N)r   IndexPQ_swiginitnew_IndexPQr   s     r   rV   IndexPQ.__init__  s     	##D**@*@$*GHr$   c                 0    [         R                  " XU5      $ r/   )r   IndexPQ_trainr>  s      r   r?  IndexPQ.train*      ''33r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexPQ_searchr[  s          r   r]  IndexPQ.search-  s    ((!	6RRr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexPQ_sa_encoder  s       r   r  IndexPQ.sa_encode0  s    ++DQ>>r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexPQ_sa_decoder  s       r   r  IndexPQ.sa_decode3  s    ++DU>>r$   c                 .    [         R                  " U 5      $ r/   )r   %IndexPQ_get_FlatCodesDistanceComputerr[   s    r   rQ  %IndexPQ.get_FlatCodesDistanceComputer6  r  r$   zfalse = standard PQz+parameters used for the polysemous trainingz#Hamming threshold used for polysemyc           
      4    [         R                  " XX#XEXg5      $ r/   )r   IndexPQ_search_core_polysemous)r   ra   rE   rQ  rR  rS  polysemous_htgeneralized_hammings           r   search_core_polysemousIndexPQ.search_core_polysemousJ  s    88!	[h~~r$   c                 2    [         R                  " XX#XE5      $ )z
prepare query for a polysemous search, but instead of
computing the result, just get the histogram of Hamming
distances. May be computed on a provided dataset if xb != NULL
:type dist_histogram: int
:param dist_histogram: (M * nbits + 1)
)r   "IndexPQ_hamming_distance_histogram)r   ra   rE   rD  r^  dist_histograms         r   hamming_distance_histogram"IndexPQ.hamming_distance_histogramM  s     <<TaR``r$   c                 0    [         R                  " XX#5      $ )z
 compute pairwise distances between queries and database

:type n: int
:param n:    nb of query vectors
:type x: float
:param x:    query vector, size n * d
:type dis: int
:param dis:  output distances, size n * ntotal
)r   IndexPQ_hamming_distance_table)r   ra   rE   rF  s       r   hamming_distance_tableIndexPQ.hamming_distance_tableW  s     88!IIr$   r%   r/   )4r   r   r:   r;   r<   r   r   r   r   r   IndexPQ_pq_getIndexPQ_pq_setr  rV   r?  r]  r  r  rQ  "IndexPQ_do_polysemous_training_get"IndexPQ_do_polysemous_training_setdo_polysemous_trainingIndexPQ_polysemous_training_getIndexPQ_polysemous_training_setpolysemous_trainingIndexPQ_ST_PQST_PQIndexPQ_ST_HEST_HEIndexPQ_ST_generalized_HEST_generalized_HEIndexPQ_ST_SDCST_SDCIndexPQ_ST_polysemousST_polysemous IndexPQ_ST_polysemous_generalizeST_polysemous_generalizeIndexPQ_search_type_getIndexPQ_search_type_setr  IndexPQ_encode_signs_getIndexPQ_encode_signs_setencode_signsIndexPQ_polysemous_ht_getIndexPQ_polysemous_ht_setr  r  r  r  delete_IndexPQr   r>   r%   r$   r   r  r    sy   
 -/IOdeGH	*++Z-F-F  MD  
EBI4S??F%j&S&SU_  VC  VC  Ic  d":#M#MzOyOy  @r  s$$E1$$E$"<<&&F,44M0)JJ(:==z?a?abKJ??AdAdeLZAA:CgCg  nX  YMaJ "00r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS r\	R"                  rSrg	)
SearchParametersPQig  z)override search parameters from the classc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   SearchParametersPQ.<lambda>j  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  j  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   SearchParametersPQ_swiginitnew_SearchParametersPQr[   s    r   rV   SearchParametersPQ.__init__o  rj  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   "SearchParametersPQ_search_type_get"SearchParametersPQ_search_type_setr  $SearchParametersPQ_polysemous_ht_get$SearchParametersPQ_polysemous_ht_setr  rV   delete_SearchParametersPQr   r>   r%   r$   r   r  r  g  s]    4-/IOdeGH:HH*JwJwxKZLLjN}N}~MZ!;;r$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      rS rS r\	R*                  rS	rg
)IndexPQStatsiu  zg
statistics are robust to internal threading, but not if
IndexPQ::search is called by multiple threads
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexPQStats.<lambda>{  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  {  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   IndexPQStats_swiginitnew_IndexPQStatsr[   s    r   rV   IndexPQStats.__init__  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexPQStats_resetr[   s    r   r  IndexPQStats.reset  r   r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IndexPQStats_nq_getIndexPQStats_nq_setr  IndexPQStats_ncode_getIndexPQStats_ncode_setncodeIndexPQStats_n_hamming_pass_getIndexPQStats_n_hamming_pass_setn_hamming_passrV   r  delete_IndexPQStatsr   r>   r%   r$   r   r  r  u  s~    
 -/IOdeGH	*00*2P2P	QBZ66
8Y8YZEjHH*JtJtuNN3!55r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rSS	 jrS
 rS rS rS r\	R&                  rSrg)MultiIndexQuantizeri  zY
Quantizer where centroids are virtual: they are the Cartesian
product of sub-centroids.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   MultiIndexQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 0    [         R                  " XU5      $ r/   )r   MultiIndexQuantizer_trainr>  s      r   r?  MultiIndexQuantizer.train      33DQ??r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   MultiIndexQuantizer_searchr[  s          r   r]  MultiIndexQuantizer.search      44TaIW]^^r$   c                 0    [         R                  " XU5      $ )z#add and reset will crash at runtime)r   MultiIndexQuantizer_addr>  s      r   rH  MultiIndexQuantizer.add  r	  r$   c                 .    [         R                  " U 5      $ r/   )r   MultiIndexQuantizer_resetr[   s    r   r  MultiIndexQuantizer.reset  r  r$   c                 T    [         R                  " U [         R                  " U6 5        g)z
 number of bit per subvector index
:type d: int
:param d: dimension of the input vectors
:type M: int
:param M: number of subquantizers
N)r   MultiIndexQuantizer_swiginitnew_MultiIndexQuantizerr   s     r   rV   MultiIndexQuantizer.__init__  s      	//j6X6XZ^6_`r$   c                 0    [         R                  " XU5      $ r/   )r   MultiIndexQuantizer_reconstructrx  s      r   r{  MultiIndexQuantizer.reconstruct  s    99$VLLr$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   MultiIndexQuantizer_pq_getMultiIndexQuantizer_pq_setr  r?  r]  rH  r  rV   r{  delete_MultiIndexQuantizerr   r>   r%   r$   r   r  r    se    
 -/IOdeGH	*779^9^	_B@_>:aM!<<r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  5      rS rS	 rSS jr\	R&                  rSrg
)MultiIndexQuantizer2i  zGMultiIndexQuantizer where the PQ assignment is performed by sub-indexesc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   MultiIndexQuantizer2.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   zM Indexes on d / M dimensionsc                 T    [         R                  " U [         R                  " U6 5        g r/   )r   MultiIndexQuantizer2_swiginitnew_MultiIndexQuantizer2r   s     r   rV   MultiIndexQuantizer2.__init__  rJ  r$   c                 0    [         R                  " XU5      $ r/   )r   MultiIndexQuantizer2_trainr>  s      r   r?  MultiIndexQuantizer2.train  rN  r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   MultiIndexQuantizer2_searchr[  s          r   r]  MultiIndexQuantizer2.search      55dqYX^__r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   'MultiIndexQuantizer2_assign_indexes_get'MultiIndexQuantizer2_assign_indexes_setassign_indexes#MultiIndexQuantizer2_own_fields_get#MultiIndexQuantizer2_own_fields_setrR  rV   r?  r]  delete_MultiIndexQuantizer2r   r>   r%   r$   r   r  r    s|    R-/IOdeGHjPPR\  SE  SE  Ko  pN*HH*JxJxyJcA`!==r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rSS	 jrS
 rS rS r\	R$                  rSrg)IndexAdditiveQuantizeri  zKAbstract class for additive quantizers. The search functions are in common.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexAdditiveQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r1    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexAdditiveQuantizer_swiginitnew_IndexAdditiveQuantizerr   s     r   rV   IndexAdditiveQuantizer.__init__  r  r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexAdditiveQuantizer_searchr[  s          r   r]  IndexAdditiveQuantizer.search      77yZ`aar$   c                 0    [         R                  " XX#5      $ r/   )r    IndexAdditiveQuantizer_sa_encoder  s       r   r   IndexAdditiveQuantizer.sa_encode      ::4AMMr$   c                 0    [         R                  " XX#5      $ r/   )r    IndexAdditiveQuantizer_sa_decoder  s       r   r   IndexAdditiveQuantizer.sa_decode      ::4EMMr$   c                 .    [         R                  " U 5      $ r/   )r   4IndexAdditiveQuantizer_get_FlatCodesDistanceComputerr[   s    r   rQ  4IndexAdditiveQuantizer.get_FlatCodesDistanceComputer      NNtTTr$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   IndexAdditiveQuantizer_aq_getIndexAdditiveQuantizer_aq_setaqrV   r]  r  r  rQ  delete_IndexAdditiveQuantizerr   r>   r%   r$   r   r/  r/    s]    V-/IOdeGH	*::J<d<d	eBgbNNU!??r$   r/  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS rS	 r\	R                  rS
rg)IndexResidualQuantizeri  
 Index based on a residual quantizer. Stored vectors are
approximated by residual quantization codes.
Can also be used as a codec
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexResidualQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rO    rL   r$   rM   rN   1The residual quantizer used to encode the vectorsc                 T    [         R                  " U [         R                  " U6 5        gar  
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:type M: int
:param M:      number of subquantizers
:type nbits: int
:param nbits:  number of bit per subvector index

:type d: int
:param d: dimensionality of the input vectors
:type M: int
:param M: number of subquantizers
:type nbits: int
:param nbits: number of bit per subvector index
N)r   IndexResidualQuantizer_swiginitnew_IndexResidualQuantizerr   s     r   rV   IndexResidualQuantizer.__init__  s     $ 	2249^9^`d9efr$   c                 0    [         R                  " XU5      $ r/   )r   IndexResidualQuantizer_trainr>  s      r   r?  IndexResidualQuantizer.train      66tBBr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IndexResidualQuantizer_rq_getIndexResidualQuantizer_rq_setr  rV   r?  delete_IndexResidualQuantizerr   r>   r%   r$   r   rL  rL    sY     -/IOdeGH	*::J<d<d  kc  
dBg(C!??r$   rL  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS rS r\R                  rSrg	)
IndexLocalSearchQuantizeri  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   "IndexLocalSearchQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   ra    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        grS  )r   "IndexLocalSearchQuantizer_swiginitnew_IndexLocalSearchQuantizerr   s     r   rV   "IndexLocalSearchQuantizer.__init__  s     $ 	55dJ<d<dfj<klr$   c                 0    [         R                  " XU5      $ r/   )r   IndexLocalSearchQuantizer_trainr>  s      r   r?  IndexLocalSearchQuantizer.train  s    99$1EEr$   r%   N)r   r   r:   r;   r   r   r   r   r   !IndexLocalSearchQuantizer_lsq_get!IndexLocalSearchQuantizer_lsq_setr  rV   r?   delete_IndexLocalSearchQuantizerr   r>   r%   r$   r   r_  r_    sH    -/IOdeGH
:??AmAm
nCm(F!BBr$   r_  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS rS	 r\	R                  rS
rg)IndexProductResidualQuantizeri"  z,Index based on a product residual quantizer.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   &IndexProductResidualQuantizer.<lambda>%  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rp  %  rL   r$   rM   rN   9The product residual quantizer used to encode the vectorsc                 T    [         R                  " U [         R                  " U6 5        g)a  
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:type nsplits: int
:param nsplits:  number of residual quantizers
:type Msub: int
:param Msub:      number of subquantizers per RQ
:type nbits: int
:param nbits:  number of bit per subvector index

:type d: int
:param d: dimensionality of the input vectors
:type nsplits: int
:param nsplits: number of residual quantizers
:type Msub: int
:param Msub: number of subquantizers per RQ
:type nbits: int
:param nbits: number of bit per subvector index
N)r   &IndexProductResidualQuantizer_swiginit!new_IndexProductResidualQuantizerr   s     r   rV   &IndexProductResidualQuantizer.__init__)  s     , 	99$
@l@lnr@str$   c                 0    [         R                  " XU5      $ r/   )r   #IndexProductResidualQuantizer_trainr>  s      r   r?  #IndexProductResidualQuantizer.trainA  s    ==dqIIr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   %IndexProductResidualQuantizer_prq_get%IndexProductResidualQuantizer_prq_setprqrV   r?  $delete_IndexProductResidualQuantizerr   r>   r%   r$   r   rn  rn  "  sU    7-/IOdeGH
:CCZEuEu  ||  }Cu0J!FFr$   rn  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS rS	 r\	R                  rS
rg) IndexProductLocalSearchQuantizeriG  z0Index based on a product local search quantizer.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   )IndexProductLocalSearchQuantizer.<lambda>J  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  J  rL   r$   rM   rN   =The product local search quantizer used to encode the vectorsc                 T    [         R                  " U [         R                  " U6 5        g)a  
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:type nsplits: int
:param nsplits:  number of local search quantizers
:type Msub: int
:param Msub:     number of subquantizers per LSQ
:type nbits: int
:param nbits:  number of bit per subvector index

:type d: int
:param d: dimensionality of the input vectors
:type nsplits: int
:param nsplits: number of local search quantizers
:type Msub: int
:param Msub: number of subquantizers per LSQ
:type nbits: int
:param nbits: number of bit per subvector index
N)r   )IndexProductLocalSearchQuantizer_swiginit$new_IndexProductLocalSearchQuantizerr   s     r   rV   )IndexProductLocalSearchQuantizer.__init__N  s     , 	<<T:CrCrtxCyzr$   c                 0    [         R                  " XU5      $ r/   )r   &IndexProductLocalSearchQuantizer_trainr>  s      r   r?  &IndexProductLocalSearchQuantizer.trainf  s    @@!LLr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   )IndexProductLocalSearchQuantizer_plsq_get)IndexProductLocalSearchQuantizer_plsq_setplsqrV   r?  'delete_IndexProductLocalSearchQuantizerr   r>   r%   r$   r   r  r  G  sU    ;-/IOdeGHJHH*J~J~  EI  JD{0M!IIr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS r\" \	R                  \	R                  SS9rS	 rSS jrS rS rS r\	R,                  rSrg
)AdditiveCoarseQuantizeril  z
 A "virtual" index where the elements are the residual quantizer centroids.

Intended for use as a coarse quantizer in an IndexIVF.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF    AdditiveCoarseQuantizer.<lambda>s  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  s  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r    AdditiveCoarseQuantizer_swiginitnew_AdditiveCoarseQuantizerr   s     r   rV    AdditiveCoarseQuantizer.__init__w  r  r$   z)norms of centroids, useful for knn-searchc                 0    [         R                  " XU5      $ zN/A)r   AdditiveCoarseQuantizer_addr>  s      r   rH  AdditiveCoarseQuantizer.add{  s    55dqAAr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   AdditiveCoarseQuantizer_searchr[  s          r   r]  AdditiveCoarseQuantizer.search      88!	[abbr$   c                 0    [         R                  " XU5      $ r/   )r   #AdditiveCoarseQuantizer_reconstructrx  s      r   r{  #AdditiveCoarseQuantizer.reconstruct  s    ==dPPr$   c                 0    [         R                  " XU5      $ r/   )r   AdditiveCoarseQuantizer_trainr>  s      r   r?  AdditiveCoarseQuantizer.train  s    77CCr$   c                 .    [         R                  " U 5      $ r  )r   AdditiveCoarseQuantizer_resetr[   s    r   r  AdditiveCoarseQuantizer.reset      77==r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   AdditiveCoarseQuantizer_aq_getAdditiveCoarseQuantizer_aq_setrI  rV   *AdditiveCoarseQuantizer_centroid_norms_get*AdditiveCoarseQuantizer_centroid_norms_setrB  rH  r]  r{  r?  r  delete_AdditiveCoarseQuantizerr   r>   r%   r$   r   r  r  l  s     -/IOdeGH	*;;Z=f=f	gBijSSU_  VK  VK  QA  BNBcQD> "@@r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\R                  rS rSrg)	'SearchParametersResidualCoarseQuantizeri  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   0SearchParametersResidualCoarseQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   0SearchParametersResidualCoarseQuantizer_swiginit+new_SearchParametersResidualCoarseQuantizerr[   s    r   rV   0SearchParametersResidualCoarseQuantizer.__init__  s*    CCD*  KA  KA  KC  	Dr$   r%   N)r   r   r:   r;   r   r   r   r   r   7SearchParametersResidualCoarseQuantizer_beam_factor_get7SearchParametersResidualCoarseQuantizer_beam_factor_setbeam_factor.delete_SearchParametersResidualCoarseQuantizerr   rV   r>   r%   r$   r   r  r    sN    -/IOdeGH:]]_i  `b  `b  cK!PPDr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9rS	 rSS jrS rS r\	R(                  rSrg
)ResidualCoarseQuantizeri  z
 The ResidualCoarseQuantizer is a bit specialized compared to the
default AdditiveCoarseQuantizer because it can use a beam search
at search time (slow but may be useful for very large vocabularies)
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF    ResidualCoarseQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   rQ  ze
    factor between the beam size and the search k
    if negative, use exact search-to-centroid
    c                 .    [         R                  " X5      $ )z#computes centroid norms if required)r   'ResidualCoarseQuantizer_set_beam_factor)r   new_beam_factors     r   set_beam_factor'ResidualCoarseQuantizer.set_beam_factor  s    AA$XXr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   ResidualCoarseQuantizer_searchr[  s          r   r]  ResidualCoarseQuantizer.search  r  r$   c                 .    [         R                  " X5      $ )zm
 Copy the M first codebook levels from other. Useful to crop a
ResidualQuantizer to its first M quantizers.
)r   'ResidualCoarseQuantizer_initialize_fromr   s     r   r  'ResidualCoarseQuantizer.initialize_from  s    
 AA$NNr$   c                 T    [         R                  " U [         R                  " U6 5        grS  )r    ResidualCoarseQuantizer_swiginitnew_ResidualCoarseQuantizerr   s     r   rV    ResidualCoarseQuantizer.__init__  s     $ 	33D*:`:`bf:ghr$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   ResidualCoarseQuantizer_rq_getResidualCoarseQuantizer_rq_setr  'ResidualCoarseQuantizer_beam_factor_get'ResidualCoarseQuantizer_beam_factor_setr  r  r]  r  rV   delete_ResidualCoarseQuantizerr   r>   r%   r$   r   r  r    s     -/IOdeGH	*;;Z=f=f  me  
fB:MMz  PB  PB H 	K
YcOi& "@@r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9rS r\R                  rSrg	)
LocalSearchCoarseQuantizeri  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   #LocalSearchCoarseQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   rQ  c                 T    [         R                  " U [         R                  " U6 5        grS  )r   #LocalSearchCoarseQuantizer_swiginitnew_LocalSearchCoarseQuantizerr   s     r   rV   #LocalSearchCoarseQuantizer.__init__  s     $ 	66tZ=f=fhl=mnr$   r%   N)r   r   r:   r;   r   r   r   r   r   "LocalSearchCoarseQuantizer_lsq_get"LocalSearchCoarseQuantizer_lsq_setr  rV   !delete_LocalSearchCoarseQuantizerr   r>   r%   r$   r   r  r    sN    -/IOdeGH
:@@*BoBo  vn  oCo& "CCr$   r  c                   `    \ rS rSrSr\" S S SS9rS r\r	\
R                  rS rS	 rS
 rSrg)InvertedListsIteratori  zS
Definition of inverted lists + a few common classes that implement
the interface.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   InvertedListsIterator.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   InvertedListsIterator.__init__  rX   r$   c                 .    [         R                  " U 5      $ r/   )r   "InvertedListsIterator_is_availabler[   s    r   is_available"InvertedListsIterator.is_available  r  r$   c                 .    [         R                  " U 5      $ r/   )r   InvertedListsIterator_nextr[   s    r   rz   InvertedListsIterator.next  r  r$   c                 .    [         R                  " U 5      $ r/   )r   &InvertedListsIterator_get_id_and_codesr[   s    r   get_id_and_codes&InvertedListsIterator.get_id_and_codes      @@FFr$   r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r   delete_InvertedListsIteratorr   r  rz   r  r>   r%   r$   r   r  r    sB    
 -/IOdeGKH!>>C;Gr$   r  c                      \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  SS9r\" \
R                  \
R                  S	S9r\" \
R"                  \
R$                  S
S9r\
R(                  r\
R,                  r S rS rS rS rS rS rS rS rS"S jr S"S jr!S"S jr"S r#S r$S r%S r&S r'S r(\
RR                  r*\
RV                  r,\
RZ                  r.\
R^                  r0\
Rb                  r2S r3S r4S r5S  r6S!r7g)#InvertedListsi  z
 Table of inverted lists
multithreading rules:
- concurrent read accesses are allowed
- concurrent update accesses are allowed
- for resize and add_entries, only concurrent access to different lists
  are allowed
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   InvertedLists.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   InvertedLists.__init__  rX   r$   number of possible key valuescode size per vector in bytesz7request to use iterator rather than get_codes / get_idsc                 .    [         R                  " X5      $ )zget the size of a list)r   InvertedLists_list_sizer   list_nos     r   	list_sizeInvertedLists.list_size  s    11$@@r$   c                 .    [         R                  " X5      $ )z
 get the codes for an inverted list
must be released by release_codes

:rtype: uint8_t
:return: codes    size list_size * code_size
)r   InvertedLists_get_codesr   s     r   	get_codesInvertedLists.get_codes  s     11$@@r$   c                 .    [         R                  " X5      $ )zq
 get the ids for an inverted list
must be released by release_ids

:rtype: int
:return: ids      size list_size
)r   InvertedLists_get_idsr   s     r   get_idsInvertedLists.get_ids)  s     //>>r$   c                 0    [         R                  " XU5      $ )zBrelease codes returned by get_codes (default implementation is nop)r   InvertedLists_release_codesr   r  r  s      r   release_codesInvertedLists.release_codes3  s    55dUKKr$   c                 0    [         R                  " XU5      $ )zrelease ids returned by get_ids)r   InvertedLists_release_idsr   r  r  s      r   release_idsInvertedLists.release_ids7  s    33D3GGr$   c                 0    [         R                  " XU5      $ )z6
:rtype: int
:return: a single id in an inverted list
)r   InvertedLists_get_single_idr   r  r
  s      r   get_single_idInvertedLists.get_single_id;  s    
 55dVLLr$   c                 0    [         R                  " XU5      $ )zk
:rtype: uint8_t
:return: a single code in an inverted list
    (should be deallocated with release_codes)
)r   InvertedLists_get_single_coder  s      r   get_single_codeInvertedLists.get_single_codeB  s     77vNNr$   c                 0    [         R                  " XU5      $ )z[
prepare the following lists (default does nothing)
a list can be -1 hence the signed long
)r   InvertedLists_prefetch_listsr   list_nosnlists      r   prefetch_listsInvertedLists.prefetch_listsJ  s    
 66tuMMr$   Nc                 0    [         R                  " XU5      $ )zcheck if the list is empty)r   InvertedLists_is_emptyr   r  inverted_list_contexts      r   is_emptyInvertedLists.is_emptyQ  s    00@UVVr$   c                 0    [         R                  " XU5      $ )z(get iterable for lists that use_iterator)r   InvertedLists_get_iteratorr(  s      r   get_iteratorInvertedLists.get_iteratorU  s    44TDYZZr$   c                 2    [         R                  " XX#U5      $ )z!add one entry to an inverted list)r   InvertedLists_add_entry)r   r  theidr  r)  s        r   	add_entryInvertedLists.add_entryY  s    11$Ncddr$   c                 2    [         R                  " XX#U5      $ r/   )r   InvertedLists_add_entriesr   r  r  r  r  s        r   add_entriesInvertedLists.add_entries]  s    33D7QUVVr$   c                 2    [         R                  " XX#U5      $ r/   )r   InvertedLists_update_entry)r   r  r
  idr  s        r   update_entryInvertedLists.update_entry`  s    44TFPTUUr$   c                 2    [         R                  " XX#XE5      $ r/   )r   InvertedLists_update_entriesr   r  r
  r  r  r  s         r   update_entriesInvertedLists.update_entriesc  s    66tfWZaar$   c                 0    [         R                  " XU5      $ r/   )r   InvertedLists_resizer   r  new_sizes      r   r   InvertedLists.resizef  s    ..thGGr$   c                 .    [         R                  " U 5      $ r/   )r   InvertedLists_resetr[   s    r   r  InvertedLists.reseti  rw   r$   c                 0    [         R                  " XU5      $ )z,move all entries from oivf (empty on output))r   InvertedLists_merge_from)r   oivfr  s      r   r  InvertedLists.merge_froml  s    224vFFr$   c                 2    [         R                  " XX#U5      $ )zf
 copy a subset of the entries index to the other index
:rtype: int
:return: number of entries copied
)r   InvertedLists_copy_subset_tor   r   subset_typea1a2s        r   copy_subset_toInvertedLists.copy_subset_tou  s     66tKUWXXr$   c                 .    [         R                  " U 5      $ )z%1= perfectly balanced, >1: imbalanced)r   InvertedLists_imbalance_factorr[   s    r   r  InvertedLists.imbalance_factor}  s    88>>r$   c                 .    [         R                  " U 5      $ )z+display some stats about the inverted lists)r   InvertedLists_print_statsr[   s    r   print_statsInvertedLists.print_stats      33D99r$   c                 .    [         R                  " U 5      $ )zsum up list sizes)r   InvertedLists_compute_ntotalr[   s    r   compute_ntotalInvertedLists.compute_ntotal  s    66t<<r$   r%   r/   )8r   r   r:   r;   r<   r   r   rV   r   r   r   InvertedLists_nlist_getInvertedLists_nlist_setr#  InvertedLists_code_size_getInvertedLists_code_size_setr  InvertedLists_use_iterator_getInvertedLists_use_iterator_setuse_iteratordelete_InvertedListsr   InvertedLists_INVALID_CODE_SIZEINVALID_CODE_SIZEr  r  r
  r  r  r  r  r$  r*  r.  r3  r8  r=  rB  r   r  r  "InvertedLists_SUBSET_TYPE_ID_RANGESUBSET_TYPE_ID_RANGE InvertedLists_SUBSET_TYPE_ID_MODSUBSET_TYPE_ID_MOD'InvertedLists_SUBSET_TYPE_ELEMENT_RANGESUBSET_TYPE_ELEMENT_RANGE*InvertedLists_SUBSET_TYPE_INVLIST_FRACTIONSUBSET_TYPE_INVLIST_FRACTION!InvertedLists_SUBSET_TYPE_INVLISTSUBSET_TYPE_INVLISTrV  r  r]  rb  r>   r%   r$   r   r  r    s_    -/IOdeGKHZ779[9[  bF  GE??AgAg  nR  SIJEEzGpGp  wu  vL!66"BB
AA?LHMONW[eWVbH4G &HH#DD * R R#-#X#X $FFY?:=r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9rS rS	 rS
 rS rS rS rS rS rSS jr\	R2                  rSrg)ArrayInvertedListsi  z=simple (default) implementation as an array of inverted listsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ArrayInvertedLists.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r{    rL   r$   rM   rN   zInverted lists for indexesc                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   ArrayInvertedLists_swiginitnew_ArrayInvertedLists)r   r#  r  s      r   rV   ArrayInvertedLists.__init__  s    ..tZ5V5VW\5hir$   c                 .    [         R                  " X5      $ r/   )r   ArrayInvertedLists_list_sizer   s     r   r  ArrayInvertedLists.list_size      66tEEr$   c                 .    [         R                  " X5      $ r/   )r   ArrayInvertedLists_get_codesr   s     r   r  ArrayInvertedLists.get_codes  r  r$   c                 .    [         R                  " X5      $ r/   )r   ArrayInvertedLists_get_idsr   s     r   r
  ArrayInvertedLists.get_ids      44TCCr$   c                 2    [         R                  " XX#U5      $ r/   )r   ArrayInvertedLists_add_entriesr7  s        r   r8  ArrayInvertedLists.add_entries      88VZ[[r$   c                 2    [         R                  " XX#XE5      $ r/   )r   !ArrayInvertedLists_update_entriesrA  s         r   rB  !ArrayInvertedLists.update_entries  s    ;;D6\_ffr$   c                 0    [         R                  " XU5      $ r/   )r   ArrayInvertedLists_resizerF  s      r   r   ArrayInvertedLists.resize      33D8LLr$   c                 .    [         R                  " X5      $ )z5permute the inverted lists, map maps new_id to old_id)r   #ArrayInvertedLists_permute_invlistsr   r  s     r   permute_invlists#ArrayInvertedLists.permute_invlists  r	  r$   Nc                 0    [         R                  " XU5      $ r/   )r   ArrayInvertedLists_is_emptyr(  s      r   r*  ArrayInvertedLists.is_empty  s    55dEZ[[r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   ArrayInvertedLists_codes_getArrayInvertedLists_codes_setr  ArrayInvertedLists_ids_getArrayInvertedLists_ids_setr  rV   r  r  r
  r8  rB  r   r  r*  delete_ArrayInvertedListsr   r>   r%   r$   r   ry  ry    s    H-/IOdeGHZ<<j>e>efE
:88*:_:_  fG  HCjFFD\gMI\!;;r$   ry  c                   P   \ rS rSrSr\" S S SS9r\r\	R                  r\" \	R                  \	R                  5      r\" \	R                  5      r\" \	R"                  5      r\" \	R&                  \	R(                  5      rS rS rS	 rS
 rS rSS jrS rS r\	R<                  rSr g)ArrayInvertedListsPanoramai  zn
Level-oriented storage as defined in the IVFFlat section of Panorama
(https://www.arxiv.org/pdf/2510.00566).
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   #ArrayInvertedListsPanorama.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   #ArrayInvertedListsPanorama_swiginitnew_ArrayInvertedListsPanorama)r   r#  r  r  s       r   rV   #ArrayInvertedListsPanorama.__init__  s+    66tZ=f=fgl  zB  >C  	Dr$   c                 .    [         R                  " X5      $ r/   )r   'ArrayInvertedListsPanorama_get_cum_sumsr   s     r   get_cum_sums'ArrayInvertedListsPanorama.get_cum_sums  s    AA$PPr$   c                 2    [         R                  " XX#U5      $ r/   )r   &ArrayInvertedListsPanorama_add_entriesr7  s        r   r8  &ArrayInvertedListsPanorama.add_entries  s    @@PW^bccr$   c                 2    [         R                  " XX#XE5      $ r/   )r   )ArrayInvertedListsPanorama_update_entriesrA  s         r   rB  )ArrayInvertedListsPanorama.update_entries  s    CCDSYdgnnr$   c                 0    [         R                  " XU5      $ r/   )r   !ArrayInvertedListsPanorama_resizerF  s      r   r   !ArrayInvertedListsPanorama.resize      ;;D8TTr$   Nc                 0    [         R                  " XU5      $ )aF  
Panorama's layout make it impractical to support iterators as defined
by Faiss (i.e. `InvertedListsIterator` API). The iterator would require
to allocate and reassemble the vector at each call.
Hence, we override this method to throw an error, this effectively
disables the `iterate_codes` and `iterate_codes_range` methods.
)r   'ArrayInvertedListsPanorama_get_iteratorr(  s      r   r.  'ArrayInvertedListsPanorama.get_iterator  s     AA$Qfggr$   c                 0    [         R                  " XU5      $ )zFReconstructs a single code from level-oriented storage to flat format.)r   *ArrayInvertedListsPanorama_get_single_coder  s      r   r  *ArrayInvertedListsPanorama.get_single_code  s    DDTTZ[[r$   c                 0    [         R                  " XU5      $ )z*Frees codes returned by `get_single_code`.)r   (ArrayInvertedListsPanorama_release_codesr  s      r   r  (ArrayInvertedListsPanorama.release_codes  s    BB4RWXXr$   r%   r/   )!r   r   r:   r;   r<   r   r   r   r   r   %ArrayInvertedListsPanorama_kBatchSize
kBatchSize'ArrayInvertedListsPanorama_cum_sums_get'ArrayInvertedListsPanorama_cum_sums_setr  'ArrayInvertedListsPanorama_n_levels_getr  *ArrayInvertedListsPanorama_level_width_getr  #ArrayInvertedListsPanorama_pano_get#ArrayInvertedListsPanorama_pano_setpanorV   r  r8  rB  r   r.  r  r  !delete_ArrayInvertedListsPanoramar   r>   r%   r$   r   r  r    s    
 -/IOdeGHAAJ
JJJL~L~H
JJKH:PPQKJBBJDrDrsDDQdoUh\Y "CCr$   r  c                   `    \ rS rSrSr\" S S SS9rS r\r	S r
S	 rS
 r\R                  rSrg)ReadOnlyInvertedListsi  z*invlists that fail for all write functionsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ReadOnlyInvertedLists.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   ReadOnlyInvertedLists.__init__  rX   r$   c                 2    [         R                  " XX#U5      $ r/   )r   !ReadOnlyInvertedLists_add_entriesr7  s        r   r8  !ReadOnlyInvertedLists.add_entries  s    ;;D7Y]^^r$   c                 2    [         R                  " XX#XE5      $ r/   )r   $ReadOnlyInvertedLists_update_entriesrA  s         r   rB  $ReadOnlyInvertedLists.update_entries  s    >>tf_biir$   c                 0    [         R                  " XU5      $ r/   )r   ReadOnlyInvertedLists_resizerF  s      r   r   ReadOnlyInvertedLists.resize  s    66thOOr$   r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r8  rB  r   r   delete_ReadOnlyInvertedListsr   r>   r%   r$   r   r  r    s?    5-/IOdeGKH_jP!>>r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS rS	 rS
 rS rS rS rS rS r\	R,                  rSrg)HStackInvertedListsi  z"Horizontal stack of inverted listsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   HStackInvertedLists.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        gz0build InvertedLists by concatenating nil of themN)r   HStackInvertedLists_swiginitnew_HStackInvertedListsr   nililss      r   rV   HStackInvertedLists.__init__       //j6X6XY\6bcr$   c                 .    [         R                  " X5      $ r/   )r   HStackInvertedLists_list_sizer   s     r   r  HStackInvertedLists.list_size      77FFr$   c                 .    [         R                  " X5      $ r/   )r   HStackInvertedLists_get_codesr   s     r   r  HStackInvertedLists.get_codes  r  r$   c                 .    [         R                  " X5      $ r/   )r   HStackInvertedLists_get_idsr   s     r   r
  HStackInvertedLists.get_ids
      55dDDr$   c                 0    [         R                  " XU5      $ r/   )r   "HStackInvertedLists_prefetch_listsr!  s      r   r$  "HStackInvertedLists.prefetch_lists      <<TUSSr$   c                 0    [         R                  " XU5      $ r/   )r   !HStackInvertedLists_release_codesr  s      r   r  !HStackInvertedLists.release_codes      ;;D5QQr$   c                 0    [         R                  " XU5      $ r/   )r   HStackInvertedLists_release_idsr  s      r   r  HStackInvertedLists.release_ids      99$MMr$   c                 0    [         R                  " XU5      $ r/   )r   !HStackInvertedLists_get_single_idr  s      r   r  !HStackInvertedLists.get_single_id      ;;D6RRr$   c                 0    [         R                  " XU5      $ r/   )r   #HStackInvertedLists_get_single_coder  s      r   r  #HStackInvertedLists.get_single_code      ==dVTTr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   HStackInvertedLists_ils_getHStackInvertedLists_ils_setr  rV   r  r  r
  r$  r  r  r  r  delete_HStackInvertedListsr   r>   r%   r$   r   r  r    su    --/IOdeGH
:99:;a;a
bCdGGETRNSU!<<r$   r  c                   ,   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      rS rS rS	 rS
 rS rS rS rS rS r\	R8                  rSrg)SliceInvertedListsi  z2vertical slice of indexes in another InvertedListsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   SliceInvertedLists.<lambda>"  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  "  rL   r$   rM   rN   c                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   SliceInvertedLists_swiginitnew_SliceInvertedLists)r   ilr  i1s       r   rV   SliceInvertedLists.__init__(  s!    ..tZ5V5VWY_a5bcr$   c                 .    [         R                  " X5      $ r/   )r   SliceInvertedLists_list_sizer   s     r   r  SliceInvertedLists.list_size+  r  r$   c                 .    [         R                  " X5      $ r/   )r   SliceInvertedLists_get_codesr   s     r   r  SliceInvertedLists.get_codes.  r  r$   c                 .    [         R                  " X5      $ r/   )r   SliceInvertedLists_get_idsr   s     r   r
  SliceInvertedLists.get_ids1  r  r$   c                 0    [         R                  " XU5      $ r/   )r    SliceInvertedLists_release_codesr  s      r   r   SliceInvertedLists.release_codes4  s    ::4%PPr$   c                 0    [         R                  " XU5      $ r/   )r   SliceInvertedLists_release_idsr  s      r   r  SliceInvertedLists.release_ids7  s    88LLr$   c                 0    [         R                  " XU5      $ r/   )r    SliceInvertedLists_get_single_idr  s      r   r   SliceInvertedLists.get_single_id:  s    ::4&QQr$   c                 0    [         R                  " XU5      $ r/   )r   "SliceInvertedLists_get_single_coder  s      r   r  "SliceInvertedLists.get_single_code=  s    <<TFSSr$   c                 0    [         R                  " XU5      $ r/   )r   !SliceInvertedLists_prefetch_listsr!  s      r   r$  !SliceInvertedLists.prefetch_lists@  s    ;;DERRr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   SliceInvertedLists_il_getSliceInvertedLists_il_setr  SliceInvertedLists_i0_getSliceInvertedLists_i0_setr  SliceInvertedLists_i1_getSliceInvertedLists_i1_setr  rV   r  r  r
  r  r  r  r  r$  delete_SliceInvertedListsr   r>   r%   r$   r   r  r    s    =-/IOdeGH	*66
8\8\	]B	*66
8\8\	]B	*66
8\8\	]BdFFDQMRTS!;;r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS rS rS rS	 rS
 rS rS rS rS r\R0                  rSrg)VStackInvertedListsiF  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   VStackInvertedLists.<lambda>G  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r<  G  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        gr  )r   VStackInvertedLists_swiginitnew_VStackInvertedListsr  s      r   rV   VStackInvertedLists.__init__L  r  r$   c                 .    [         R                  " X5      $ r/   )r   VStackInvertedLists_list_sizer   s     r   r  VStackInvertedLists.list_sizeP  r  r$   c                 .    [         R                  " X5      $ r/   )r   VStackInvertedLists_get_codesr   s     r   r  VStackInvertedLists.get_codesS  r  r$   c                 .    [         R                  " X5      $ r/   )r   VStackInvertedLists_get_idsr   s     r   r
  VStackInvertedLists.get_idsV  r  r$   c                 0    [         R                  " XU5      $ r/   )r   !VStackInvertedLists_release_codesr  s      r   r  !VStackInvertedLists.release_codesY  r  r$   c                 0    [         R                  " XU5      $ r/   )r   VStackInvertedLists_release_idsr  s      r   r  VStackInvertedLists.release_ids\  r  r$   c                 0    [         R                  " XU5      $ r/   )r   !VStackInvertedLists_get_single_idr  s      r   r  !VStackInvertedLists.get_single_id_  r  r$   c                 0    [         R                  " XU5      $ r/   )r   #VStackInvertedLists_get_single_coder  s      r   r  #VStackInvertedLists.get_single_codeb  r  r$   c                 0    [         R                  " XU5      $ r/   )r   "VStackInvertedLists_prefetch_listsr!  s      r   r$  "VStackInvertedLists.prefetch_listse  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   VStackInvertedLists_ils_getVStackInvertedLists_ils_setr  VStackInvertedLists_cumsz_getVStackInvertedLists_cumsz_setcumszrV   r  r  r
  r  r  r  r  r$  delete_VStackInvertedListsr   r>   r%   r$   r   r:  r:  F  s    -/IOdeGH
:99:;a;a
bCZ==z?g?ghEdGGERNSUT!<<r$   r:  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS rS	 rS
 rS rS rS rS rS r\	R2                  rSrg)MaskedInvertedListsik  z
 use the first inverted lists if they are non-empty otherwise use the second

This is useful if il1 has a few inverted lists that are too long,
and that il0 has replacement lists for those, with empty lists for
the others.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   MaskedInvertedLists.<lambda>t  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rc  t  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   MaskedInvertedLists_swiginitnew_MaskedInvertedLists)r   il0il1s      r   rV   MaskedInvertedLists.__init__y  s    //j6X6XY\6bcr$   c                 .    [         R                  " X5      $ r/   )r   MaskedInvertedLists_list_sizer   s     r   r  MaskedInvertedLists.list_size|  r  r$   c                 .    [         R                  " X5      $ r/   )r   MaskedInvertedLists_get_codesr   s     r   r  MaskedInvertedLists.get_codes  r  r$   c                 .    [         R                  " X5      $ r/   )r   MaskedInvertedLists_get_idsr   s     r   r
  MaskedInvertedLists.get_ids  r  r$   c                 0    [         R                  " XU5      $ r/   )r   !MaskedInvertedLists_release_codesr  s      r   r  !MaskedInvertedLists.release_codes  r  r$   c                 0    [         R                  " XU5      $ r/   )r   MaskedInvertedLists_release_idsr  s      r   r  MaskedInvertedLists.release_ids  r  r$   c                 0    [         R                  " XU5      $ r/   )r   !MaskedInvertedLists_get_single_idr  s      r   r  !MaskedInvertedLists.get_single_id  r  r$   c                 0    [         R                  " XU5      $ r/   )r   #MaskedInvertedLists_get_single_coder  s      r   r  #MaskedInvertedLists.get_single_code  r  r$   c                 0    [         R                  " XU5      $ r/   )r   "MaskedInvertedLists_prefetch_listsr!  s      r   r$  "MaskedInvertedLists.prefetch_lists  r  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   MaskedInvertedLists_il0_getMaskedInvertedLists_il0_setrh  MaskedInvertedLists_il1_getMaskedInvertedLists_il1_setri  rV   r  r  r
  r  r  r  r  r$  delete_MaskedInvertedListsr   r>   r%   r$   r   ra  ra  k  s     -/IOdeGH
:99:;a;a
bC
:99:;a;a
bCdGGERNSUT!<<r$   ra  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS rS	 rS
 rS rS rS rS rS r\	R2                  rSrg)StopWordsInvertedListsi  zf
if the inverted list in il is smaller than maxsize then return it,
otherwise return an empty invlist
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   StopWordsInvertedLists.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   StopWordsInvertedLists_swiginitnew_StopWordsInvertedLists)r   r  maxsizes      r   rV   StopWordsInvertedLists.__init__  s    2249^9^_a9klr$   c                 .    [         R                  " X5      $ r/   )r    StopWordsInvertedLists_list_sizer   s     r   r   StopWordsInvertedLists.list_size      ::4IIr$   c                 .    [         R                  " X5      $ r/   )r    StopWordsInvertedLists_get_codesr   s     r   r   StopWordsInvertedLists.get_codes  r  r$   c                 .    [         R                  " X5      $ r/   )r   StopWordsInvertedLists_get_idsr   s     r   r
  StopWordsInvertedLists.get_ids  s    88GGr$   c                 0    [         R                  " XU5      $ r/   )r   $StopWordsInvertedLists_release_codesr  s      r   r  $StopWordsInvertedLists.release_codes  s    >>teTTr$   c                 0    [         R                  " XU5      $ r/   )r   "StopWordsInvertedLists_release_idsr  s      r   r  "StopWordsInvertedLists.release_ids  s    <<TCPPr$   c                 0    [         R                  " XU5      $ r/   )r   $StopWordsInvertedLists_get_single_idr  s      r   r  $StopWordsInvertedLists.get_single_id  s    >>tfUUr$   c                 0    [         R                  " XU5      $ r/   )r   &StopWordsInvertedLists_get_single_coder  s      r   r  &StopWordsInvertedLists.get_single_code  s    @@PVWWr$   c                 0    [         R                  " XU5      $ r/   )r   %StopWordsInvertedLists_prefetch_listsr!  s      r   r$  %StopWordsInvertedLists.prefetch_lists  s    ??PUVVr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   StopWordsInvertedLists_il0_getStopWordsInvertedLists_il0_setrh  "StopWordsInvertedLists_maxsize_get"StopWordsInvertedLists_maxsize_setr  rV   r  r  r
  r  r  r  r  r$  delete_StopWordsInvertedListsr   r>   r%   r$   r   r  r    s    
 -/IOdeGH
:<<j>g>g
hCzDDjFsFstGmJJHUQVXW!??r$   r  c                       \ rS rSrSr\" S S SS9rS r\r	\" \
R                  SS9r\" \
R                  S	S9rS
 rS rS r\
R$                  r\S 5       r\S 5       r\S 5       r\S 5       rSrg)InvertedListsIOHooki  ac  
 Callbacks to handle other types of InvertedList objects.

The callbacks should be registered with add_callback before calling
read_index or read_InvertedLists. The callbacks for
OnDiskInvertedLists are registrered by default. The invlist type is
identified by:

- the key (a fourcc) at read time
- the class name (as given by typeid.name) at write time
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   InvertedListsIOHook.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   InvertedListsIOHook.__init__  rX   r$   zstring version of the fourccztypeid.namec                 0    [         R                  " XU5      $ )z6write the index to the IOWriter (including the fourcc))r   InvertedListsIOHook_write)r   r  r|  s      r   r#  InvertedListsIOHook.write  s    33DqAAr$   c                 0    [         R                  " XU5      $ )z2called when the fourcc matches this class's fourcc)r   InvertedListsIOHook_read)r   r|  io_flagss      r   r8  InvertedListsIOHook.read  s    224HEEr$   c                 2    [         R                  " XX#XE5      $ )z
 read from a ArrayInvertedLists into this invertedlist type.
For this to work, the callback has to be enabled and the io_flag has to
be set to IO_FLAG_SKIP_IVF_DATA | (16 upper bits of the fourcc)

(default implementation fails)
)r   +InvertedListsIOHook_read_ArrayInvertedLists)r   r|  r  r#  r  sizess         r   read_ArrayInvertedLists+InvertedListsIOHook.read_ArrayInvertedLists  s     EEdx`iqqr$   c                 .    [         R                  " U 5      $ r/   )r    InvertedListsIOHook_add_callbackarg1s    r   add_callback InvertedListsIOHook.add_callback      ::4@@r$   c                  ,    [         R                  " 5       $ r/   )r   #InvertedListsIOHook_print_callbacksr%   r$   r   print_callbacks#InvertedListsIOHook.print_callbacks  s    ==??r$   c                 .    [         R                  " U 5      $ r/   )r   InvertedListsIOHook_lookup)hs    r   lookupInvertedListsIOHook.lookup  s    44Q77r$   c                 .    [         R                  " U 5      $ r/   )r   $InvertedListsIOHook_lookup_classname)	classnames    r   lookup_classname$InvertedListsIOHook.lookup_classname  s    >>yIIr$   r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r   InvertedListsIOHook_key_getry  !InvertedListsIOHook_classname_getr  r#  r8  r  delete_InvertedListsIOHookr   r7  r  r  r  r  r>   r%   r$   r   r  r    s    
 -/IOdeGKH
:99?b
cCEEK]^IBFr "<<A A @ @ 8 8 J Jr$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      r\" \	R,                  \	R.                  5      rS rS rS	 rS
 rS rS rS rS r \	RB                  r"Sr#g)BlockInvertedListsi  a2  
 Inverted Lists that are organized by blocks.

Different from the regular inverted lists, the codes are organized by blocks
of size block_size bytes that reprsent a set of n_per_block. Therefore, code
allocations are always rounded up to block_size bytes. The codes are also
aligned on 32-byte boundaries for use with SIMD.

To avoid misinterpretations, the code_size is set to (size_t)(-1), even if
arguably the amount of memory consumed by code is block_size / n_per_block.

The writing functions add_entries and update_entries operate on block-aligned
data.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   BlockInvertedLists.<lambda>
  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  
  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   BlockInvertedLists_swiginitnew_BlockInvertedListsr   s     r   rV   BlockInvertedLists.__init__      ..tZ5V5VX\5]^r$   c                 .    [         R                  " X5      $ r/   )r   BlockInvertedLists_list_sizer   s     r   r  BlockInvertedLists.list_size  r  r$   c                 .    [         R                  " X5      $ r/   )r   BlockInvertedLists_get_codesr   s     r   r  BlockInvertedLists.get_codes  r  r$   c                 .    [         R                  " X5      $ r/   )r   BlockInvertedLists_get_idsr   s     r   r
  BlockInvertedLists.get_ids  r  r$   c                 .    [         R                  " X5      $ )z!remove ids from the InvertedLists)r   BlockInvertedLists_remove_idsrs  s     r   rt  BlockInvertedLists.remove_ids      77BBr$   c                 2    [         R                  " XX#U5      $ r/   )r   BlockInvertedLists_add_entriesr7  s        r   r8  BlockInvertedLists.add_entries"  r  r$   c                 2    [         R                  " XX#XE5      $ znot implemented)r   !BlockInvertedLists_update_entriesrA  s         r   rB  !BlockInvertedLists.update_entries%  s    ;;D6\_ffr$   c                 0    [         R                  " XU5      $ r/   )r   BlockInvertedLists_resizerF  s      r   r   BlockInvertedLists.resize)  r  r$   r%   N)$r   r   r:   r;   r<   r   r   r   r   r   "BlockInvertedLists_n_per_block_get"BlockInvertedLists_n_per_block_setn_per_block!BlockInvertedLists_block_size_get!BlockInvertedLists_block_size_setrc  BlockInvertedLists_packer_getBlockInvertedLists_packer_setpackerBlockInvertedLists_codes_getBlockInvertedLists_codes_setr  BlockInvertedLists_ids_getBlockInvertedLists_ids_setr  rV   r  r  r
  rt  r8  rB  r   delete_BlockInvertedListsr   r>   r%   r$   r   r  r    s     -/IOdeGH:HH*JwJwxK*FF
HtHtuJj>>
@h@hiFZ<<j>e>efE
:88*:_:_
`C_FFDC\gM!;;r$   r  c                 .    [         R                  " X5      $ r/   )r   lo_build)list_idr
  s     r   r
  r
  0  s    w//r$   c                 .    [         R                  " U 5      $ r/   )r   	lo_listnolos    r   r  r  3      ##r$   c                 .    [         R                  " U 5      $ r/   )r   	lo_offsetr  s    r   r  r  6  r  r$   c                   r   \ rS rSrSr\" S S SS9r\r\	R                  r\	R                  r\	R                  r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  SS9r\" \	R,                  \	R.                  5      rS rS	 rS
 rS rS rS rS rS r S r!\	RD                  r#Sr$g)	DirectMapi8  z8Direct map: a way to map back from ids to inverted listsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   DirectMap.<lambda>;  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  ;  rL   r$   rM   rN   zEmap for direct access to the elements. Map ids to LO-encoded entries.c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   DirectMap_swiginitnew_DirectMapr[   s    r   rV   DirectMap.__init__D      %%dJ,D,D,FGr$   c                 0    [         R                  " XX#5      $ )zset type and initialize)r   DirectMap_set_type)r   new_typeinvlistsr  s       r   set_typeDirectMap.set_typeG  s    ,,TXNNr$   c                 .    [         R                  " X5      $ )zget an entry)r   DirectMap_getr   r<  s     r   r  DirectMap.getK  s    ''11r$   c                 .    [         R                  " U 5      $ )zfor quick checks)r   DirectMap_nor[   s    r   noDirectMap.noO  s    &&t,,r$   c                 .    [         R                  " X5      $ )z<
update the direct_map

 throw if Array and ids is not NULL
)r   DirectMap_check_can_add)r   r  s     r   check_can_addDirectMap.check_can_addS  s     11$<<r$   c                 0    [         R                  " XX#5      $ )znon thread-safe version)r   DirectMap_add_single_id)r   r<  r  r
  s       r   add_single_idDirectMap.add_single_id[  s    11$GLLr$   c                 .    [         R                  " U 5      $ )zremove all entries)r   DirectMap_clearr[   s    r   r   DirectMap.clear_      ))$//r$   c                 0    [         R                  " XU5      $ )z
operations on inverted lists that require translation with a DirectMap

 remove ids from the InvertedLists, possibly using the direct map
)r   DirectMap_remove_ids)r   rT  r   s      r   rt  DirectMap.remove_idsc  s     ..t(CCr$   c                 2    [         R                  " XX#XE5      $ )z$update entries, using the direct map)r   DirectMap_update_codes)r   r   ra   r  r"  r  s         r   update_codesDirectMap.update_codesk  s    00YYr$   r%   N)%r   r   r:   r;   r<   r   r   r   r   r   DirectMap_NoMapNoMapDirectMap_ArrayArrayDirectMap_Hashtable	HashtableDirectMap_type_getDirectMap_type_setr   DirectMap_array_getDirectMap_array_setarrayDirectMap_hashtable_getDirectMap_hashtable_set	hashtablerV   r!  r  r)  r-  r1  r   rt  r<  delete_DirectMapr   r>   r%   r$   r   r  r  8  s    C-/IOdeGH&&E&&E..IJ11:3P3PQDZ33Z5S5S  Zf  gE;;Z=_=_`IHO2-=M0DZ "22r$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      r\" \	R,                  \	R.                  5      r\" \	R2                  \	R4                  5      rS rS r\	R<                  rS	r g
)DirectMapAddir  z*Thread-safe way of updating the direct_mapc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   DirectMapAdd.<lambda>u  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rP  u  rL   r$   rM   rN   c                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   DirectMapAdd_swiginitnew_DirectMapAdd)r   
direct_mapra   rQ  s       r   rV   DirectMapAdd.__init__~  s     ((z/J/J:Z^/_`r$   c                 0    [         R                  " XX#5      $ )z4add vector i (with id xids[i]) at list_no and offset)r   DirectMapAdd_add)r   r+  r  r
  s       r   rH  DirectMapAdd.add  s    **4GDDr$   r%   N)!r   r   r:   r;   r<   r   r   r   r   r   DirectMapAdd_direct_map_getDirectMapAdd_direct_map_setrU  DirectMapAdd_type_getDirectMapAdd_type_setr   DirectMapAdd_ntotal_getDirectMapAdd_ntotal_setr  DirectMapAdd_n_getDirectMapAdd_n_setra   DirectMapAdd_xids_getDirectMapAdd_xids_setrQ  DirectMapAdd_all_ofs_getDirectMapAdd_all_ofs_setall_ofsrV   rH  delete_DirectMapAddr   r>   r%   r$   r   rN  rN  r  s    5-/IOdeGH*@@*BhBhiJJ44j6V6VWDj88*:\:\]F..
0M0MNAJ44j6V6VWDz::J<_<_`GaE "55r$   rN  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9r\" \	R2                  \	R4                  SS9rS rS rS rS rS r \	RB                  r"Sr#g)Level1Quantizeri  z
 Encapsulates a quantizer object for the IndexIVF

The class isolates the fields that are independent of the storage
of the lists (especially training)
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Level1Quantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rk    rL   r$   rM   rN   -quantizer that maps vectors to inverted listsznumber of inverted listsz
    = 0: use the quantizer as index in a kmeans training
    = 1: just pass on the training set to the train() of the quantizer
    = 2: kmeans training on a flat index + add the centroids to the quantizer
    !whether object owns the quantizer%to override default clustering params(to override index used during clusteringc                 2    [         R                  " XX#U5      $ )zETrains the quantizer and calls train_residual to train sub-quantizers)r   Level1Quantizer_train_q1)r   ra   rE   r  r   s        r   train_q1Level1Quantizer.train_q1  s    224ATTr$   c                 .    [         R                  " U 5      $ )z6compute the number of bytes required to store list ids)r    Level1Quantizer_coarse_code_sizer[   s    r   coarse_code_size Level1Quantizer.coarse_code_size  r  r$   c                 0    [         R                  " XU5      $ r/   )r   Level1Quantizer_encode_listno)r   r  r  s      r   encode_listnoLevel1Quantizer.encode_listno  s    77tLLr$   c                 .    [         R                  " X5      $ r/   )r   Level1Quantizer_decode_listnor  s     r   decode_listnoLevel1Quantizer.decode_listno  r  r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   Level1Quantizer_swiginitnew_Level1Quantizerr   s     r   rV   Level1Quantizer.__init__  r  r$   r%   N)$r   r   r:   r;   r<   r   r   r   r   r   Level1Quantizer_quantizer_getLevel1Quantizer_quantizer_set	quantizerLevel1Quantizer_nlist_getLevel1Quantizer_nlist_setr#  *Level1Quantizer_quantizer_trains_alone_get*Level1Quantizer_quantizer_trains_alone_setquantizer_trains_aloneLevel1Quantizer_own_fields_getLevel1Quantizer_own_fields_setrR  Level1Quantizer_cp_getLevel1Quantizer_cp_setrq
  $Level1Quantizer_clustering_index_get$Level1Quantizer_clustering_index_setclustering_indexrs  rw  r{  r  rV   delete_Level1Quantizerr   r>   r%   r$   r   ri  ri    s)    -/IOdeGHAA:CkCk  rf  gIZ99:;_;_  fE  FE%j&[&[]g  ^S  ^S Y 	
 *CCZEnEn  u]  ^J	*33Z5V5V  ]I  
JB
 O OQ[  RA  RA  Gv  wUAMDY!88r$   ri  c                   ,   \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9r\" \R                  \R                  SS9r\" \R                  \R                   5      r\" \R$                  \R&                  SS9r\R*                  rS	 rS
rg)SearchParametersIVFi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   SearchParametersIVF.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   number of probes at query time&max nb of codes to visit to do a queryz'context object to pass to InvertedListsc                 X    [         R                  " U [         R                  " 5       5        g r/   )r   SearchParametersIVF_swiginitnew_SearchParametersIVFr[   s    r   rV   SearchParametersIVF.__init__  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   SearchParametersIVF_nprobe_getSearchParametersIVF_nprobe_setnprobe!SearchParametersIVF_max_codes_get!SearchParametersIVF_max_codes_set	max_codes(SearchParametersIVF_quantizer_params_get(SearchParametersIVF_quantizer_params_setquantizer_params-SearchParametersIVF_inverted_list_context_get-SearchParametersIVF_inverted_list_context_setr)  delete_SearchParametersIVFr   rV   r>   r%   r$   r   r  r    s    -/IOdeGHj??AjAj  qV  WFEEzGsGs  zg  hI
 S SU_  VI  VI  J$Z%]%]_i  `X  `X  ^L  M!<<\r$   r  c                       \ rS rSr\" S S SS9rS r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9rSS
 jrSS jr\	R$                  rSrg	)IndexIVFInterfacei  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFInterface.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   IndexIVFInterface.__init__  rX   r$   r  r  Nc                 8    [         R                  " XX#XEXgXU
5      $ )a&  
 search a set of vectors, that are pre-quantized by the IVF
 quantizer. Fill in the corresponding heaps with the query
 results. The default implementation uses InvertedListScanners
 to do the search.

:type n: int
:param n:      nb of vectors to query
:type x: float
:param x:      query vectors, size nx * d
:type assign: int
:param assign: coarse quantization indices, size nx * nprobe
:type centroid_dis: float
:param centroid_dis:
                  distances to coarse centroids, size nx * nprobe
:param distance:
                  output distances, size n * k
:type labels: int
:param labels: output labels, size n * k
:type store_pairs: boolean
:param store_pairs: store inv list index + inv list offset
                        instead in upper/lower 32 bit of result,
                        instead of ids (used for reranking).
:type params: :py:class:`IVFSearchParameters`, optional
:param params: used to override the object's search parameters
:type stats: :py:class:`IndexIVFStats`, optional
:param stats:  search stats to be updated (can be null)
)r   $IndexIVFInterface_search_preassignedr   ra   rE   rQ  rl  centroid_disrR  rS  store_pairsr\  statss              r   search_preassigned$IndexIVFInterface.search_preassigned  s0    : >>tfdm  xC  MR  S  	Sr$   c
                 6    [         R                  " XX#XEXgX5
      $ )a  
 Range search a set of vectors, that are pre-quantized by the IVF
 quantizer. Fill in the RangeSearchResults results. The default
implementation uses InvertedListScanners to do the search.

:param n:      nb of vectors to query
:type x: float
:param x:      query vectors, size nx * d
:param assign: coarse quantization indices, size nx * nprobe
:param centroid_dis:
                  distances to coarse centroids, size nx * nprobe
:type result: :py:class:`RangeSearchResult`
:param result: Output results
:type store_pairs: boolean, optional
:param store_pairs: store inv list index + inv list offset
                        instead in upper/lower 32 bit of result,
                        instead of ids (used for reranking).
:type params: :py:class:`IVFSearchParameters`, optional
:param params: used to override the object's search parameters
:type stats: :py:class:`IndexIVFStats`, optional
:param stats:  search stats to be updated (can be null)
)r   *IndexIVFInterface_range_search_preassigned
r   rw  rE   rW  r  
coarse_disrX  r  r\  r  s
             r   range_search_preassigned*IndexIVFInterface.range_search_preassigned  s*    . DDTqZ^lr  BH  P  	Pr$   r%   r#  FNN)r   r   r:   r;   r   r   rV   r   r   r   IndexIVFInterface_nprobe_getIndexIVFInterface_nprobe_setr  IndexIVFInterface_max_codes_getIndexIVFInterface_max_codes_setr  r  r  delete_IndexIVFInterfacer   r>   r%   r$   r   r  r    s|    -/IOdeGKHj==z?f?f  mR  SFCCZEoEo  vc  dIS>P0 "::r$   r  c                      \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  SS9r\" \
R                  \
R                  5      r\" \
R"                  \
R$                  S	S9r\" \
R(                  \
R*                  S
S9r\" \
R.                  5      r\" \
R2                  \
R4                  SS9r\" \
R8                  \
R:                  SS9rS rS r S r!S r"S0S jr#S1S jr$S r%S r&S r'S r(S2S jr)S3S jr*S0S jr+S0S jr,S3S jr-S r.S r/S r0S0S  jr1S4S! jr2S" r3S# r4S$ r5S% r6S& r7S' r8\
Rr                  r:S( r;S) r<S5S* jr=S+ r>S1S, jr?S- r@S. rAS/rBg)6IndexIVFi  aP  
 Index based on a inverted file (IVF)

In the inverted file, the quantizer (an Index instance) provides a
quantization index for each vector to be added. The quantization
index maps to a list (aka inverted list or posting list), where the
id of the vector is stored.

The inverted list object is required only after training. If none is
set externally, an ArrayInvertedLists is used automatically.

At search time, the vector to be searched is also quantized, and
only the list corresponding to the quantization index is
searched. This speeds up the search by making it
non-exhaustive. This can be relaxed using multi-probe search: a few
(nprobe) quantization indices are selected and several inverted
lists are visited.

Sub-classes implement a post-filtering of the index that refines
the distance estimation from the query to database vectors.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVF.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   IndexIVF.__init__  rX   r$   Access to the actual datar  a]  
     Parallel mode determines how queries are parallelized with OpenMP

    0 (default): split over queries
    1: parallelize over inverted lists
    2: parallelize over both
    3: split over queries with a finer granularity

    PARALLEL_MODE_NO_HEAP_INIT: binary or with the previous to
    prevent the heap to be initialized and finalized
    z\
    optional map that maps back ids to invlist entries. This
    enables reconstruct()
    zX
    do the codes in the invlists encode the vectors relative to the
    centroids?
    c                 .    [         R                  " U 5      $ r/   )r   IndexIVF_resetr[   s    r   r  IndexIVF.reset7  r  r$   c                 0    [         R                  " XU5      $ )zDTrains the quantizer and calls train_encoder to train sub-quantizers)r   IndexIVF_trainr>  s      r   r?  IndexIVF.train:      ((!44r$   c                 0    [         R                  " XU5      $ )z Calls add_with_ids with NULL ids)r   IndexIVF_addr>  s      r   rH  IndexIVF.add>  s    &&t22r$   c                 0    [         R                  " XX#5      $ )z0default implementation that calls encode_vectors)r   IndexIVF_add_with_idsrP  s       r   rR  IndexIVF.add_with_idsB  s    //AAr$   Nc                 2    [         R                  " XX#XE5      $ )a  
 Implementation of vector addition where the vector assignments are
predefined. The default implementation hands over the code extraction to
encode_vectors.

:type precomputed_idx: int
:param precomputed_idx:    quantization indices for the input vectors
    (size n)
)r   IndexIVF_add_corer   ra   rE   rQ  precomputed_idxr)  s         r   add_coreIndexIVF.add_coreF  s     ++DQoeer$   c                 2    [         R                  " XX#XE5      $ )a  
 Encodes a set of vectors as they would appear in the inverted lists

:type list_nos: int
:param list_nos:   inverted list ids as returned by the
                      quantizer (size n). -1s are ignored.
:type codes: uint8_t
:param codes:      output codes, size n * code_size
:type include_listno: boolean, optional
:param include_listno:
                      include the list ids in the code (in this case add
                      ceil(log8(nlist)) to the code size)
)r   IndexIVF_encode_vectorsr   ra   rE   r"  r  include_listnos         r   encode_vectorsIndexIVF.encode_vectorsR  s     11$1^^r$   c                 2    [         R                  " XX#U5      $ )a,  
 Decodes a set of vectors as they would appear in a given set of inverted
lists (inverse of encode_vectors)

:type codes: uint8_t
:param codes:      input codes, size n * code_size
:type x: float
:param x:          output decoded vectors
:type list_nos: int
:param list_nos:   input listnos, size n
)r   IndexIVF_decode_vectorsr   ra   r  r"  rE   s        r   decode_vectorsIndexIVF.decode_vectorsb  s     11$5ANNr$   c                 0    [         R                  " XX#5      $ r  )r   IndexIVF_add_sa_codesr  s       r   r  IndexIVF.add_sa_codesp  s     //EEr$   c                 0    [         R                  " XX#5      $ )z
 Train the encoder for the vectors.

If by_residual then it is called with residuals and corresponding assign
array, otherwise x is the raw training vectors and assign=nullptr
)r   IndexIVF_train_encoderr   ra   rE   rl  s       r   train_encoderIndexIVF.train_encoder{  s     00!DDr$   c                 .    [         R                  " U 5      $ )zP
can be redefined by subclasses to indicate how many training vectors
they need
)r   "IndexIVF_train_encoder_num_vectorsr[   s    r   train_encoder_num_vectors"IndexIVF.train_encoder_num_vectors  s    
 <<TBBr$   c                 8    [         R                  " XX#XEXgXU
5      $ r/   )r   IndexIVF_search_preassignedr  s              r   r  IndexIVF.search_preassigned  s*    55dqV[dny  DI  J  	Jr$   c
                 6    [         R                  " XX#XEXgX5
      $ r/   )r   !IndexIVF_range_search_preassignedr  s
             r   r  !IndexIVF.range_search_preassigned  s$    ;;DaQUcix~  G  	Gr$   c           	      4    [         R                  " XX#XEU5      $ z.assign the vectors, then call search_preassign)r   IndexIVF_searchr[  s          r   r]  IndexIVF.search      ))$1FSSr$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexIVF_range_searchrf  s         r   rg  IndexIVF.range_search  s    //FSSr$   c                 0    [         R                  " XX#5      $ )a
  
 Get a scanner for this index (store_pairs means ignore labels)

The default search implementation uses this to compute the distances.
Use sel instead of params->sel, because sel is initialized with
params->sel, but may get overridden by IndexIVF's internal logic.
)r    IndexIVF_get_InvertedListScannerr   r  rT  r\  s       r   get_InvertedListScanner IndexIVF.get_InvertedListScanner  s     ::4cZZr$   c                 0    [         R                  " XU5      $ )zHreconstruct a vector. Works only if maintain_direct_map is set to 1 or 2)r   IndexIVF_reconstructrx  s      r   r{  IndexIVF.reconstruct  s    ..t&AAr$   c                 0    [         R                  " XX#5      $ )z
 Update a subset of vectors.

The index must have a direct_map

:type nv: int
:param nv:     nb of vectors to update
:type idx: int
:param idx:    vector indices to update, size nv
:type v: float
:param v:      vectors of new values, size nv*d
)r   IndexIVF_update_vectorsr   nvrc  rK   s       r   update_vectorsIndexIVF.update_vectors  s     11$CCCr$   c                 0    [         R                  " XX#5      $ )a_  
 Reconstruct a subset of the indexed vectors.

Overrides default implementation to bypass reconstruct() which requires
direct_map to be maintained.

:type i0: int
:param i0:     first vector to reconstruct
:type ni: int
:param ni:     nb of vectors to reconstruct
:type recons: float
:param recons: output array of reconstructed vectors, size ni * d
)r   IndexIVF_reconstruct_nr  s       r   r  IndexIVF.reconstruct_n  s     002FFr$   c           
      4    [         R                  " XX#XEXg5      $ )az  
 Similar to search, but also reconstructs the stored vectors (or an
approximation in the case of lossy coding) for the search results.

Overrides default implementation to avoid having to maintain direct_map
and instead fetch the code offsets through the `store_pairs` flag in
search_preassigned().

:type recons: float
:param recons:      reconstructed vectors size (n, k, d)
)r   IndexIVF_search_and_reconstructr  s           r   r  IndexIVF.search_and_reconstruct  s     99$1\bkkr$   c	                 6    [         R                  " XX#XEXgU5	      $ )aZ  
 Similar to search, but also returns the codes corresponding to the
stored vectors for the search results.

:param codes:      codes (n, k, code_size)
:type include_listno: boolean, optional
:param include_listno:
                      include the list ids in the code (in this case add
                      ceil(log8(nlist)) to the code size)
)r    IndexIVF_search_and_return_codes)	r   ra   rE   rQ  rR  rS  rz  r  r\  s	            r   search_and_return_codes IndexIVF.search_and_return_codes  s     ::4A)]cu{||r$   c                 0    [         R                  " XX#5      $ a  
 Reconstruct a vector given the location in terms of (inv list index +
inv list offset) instead of the id.

Useful for reconstructing when the direct_map is not maintained and
the inv list offset is computed by search_preassigned() with
`store_pairs` set.
)r    IndexIVF_reconstruct_from_offsetr   r  r
  rz  s       r   reconstruct_from_offset IndexIVF.reconstruct_from_offset  s     ::4&YYr$   c                 .    [         R                  " X5      $ zDataset manipulation functions)r   IndexIVF_remove_idsrs  s     r   rt  IndexIVF.remove_ids  s    --d88r$   c                 .    [         R                  " X5      $ r/   )r   #IndexIVF_check_compatible_for_merger  s     r   r  #IndexIVF.check_compatible_for_merge  s    ==dOOr$   c                 0    [         R                  " XU5      $ r/   )r   IndexIVF_merge_fromr  s      r   r  IndexIVF.merge_from  s    --dGGr$   c                 .    [         R                  " U 5      $ r/   )r   IndexIVF_get_CodePackerr[   s    r   r`  IndexIVF.get_CodePacker  r   r$   c                 2    [         R                  " XX#U5      $ )zt
 copy a subset of the entries index to the other index
see Invlists::copy_subset_to for the meaning of subset_type
)r   IndexIVF_copy_subset_torR  s        r   rV  IndexIVF.copy_subset_to  s    
 11${PRSSr$   c                 .    [         R                  " X5      $ r/   )r   IndexIVF_get_list_sizer   s     r   get_list_sizeIndexIVF.get_list_size   s    00??r$   c                 .    [         R                  " U 5      $ )zare the ids sorted?)r   IndexIVF_check_ids_sortedr[   s    r   check_ids_sortedIndexIVF.check_ids_sorted  r_  r$   c                 .    [         R                  " X5      $ z
 initialize a direct map

:type new_maintain_direct_map: boolean, optional
:param new_maintain_direct_map:    if true, create a direct map,
                                      else clear it
)r   IndexIVF_make_direct_mapr   new_maintain_direct_maps     r   make_direct_mapIndexIVF.make_direct_map  s     224QQr$   c                 .    [         R                  " X5      $ r/   )r   IndexIVF_set_direct_map_typer   r   s     r   set_direct_map_typeIndexIVF.set_direct_map_type      66tBBr$   c                 0    [         R                  " XU5      $ )zBreplace the inverted lists, old one is deallocated if own_invlists)r   IndexIVF_replace_invlistsr   r  r   s      r   replace_invlistsIndexIVF.replace_invlists  s    33DcBBr$   c                 .    [         R                  " U 5      $ r/   )r   IndexIVF_sa_code_sizer[   s    r   r  IndexIVF.sa_code_size      //55r$   c                 0    [         R                  " XX#5      $ )a0  
 encode a set of vectors
sa_encode will call encode_vectors with include_listno=true
:type n: int
:param n:      nb of vectors to encode
:type x: float
:param x:      the vectors to encode
:type bytes: uint8_t
:param bytes:  output array for the codes
:rtype: void
:return: nb of bytes written to codes
)r   IndexIVF_sa_encoder  s       r   r  IndexIVF.sa_encode  s     ,,Ta??r$   r%   r/   Fr#  r  )FNr!	  )Cr   r   r:   r;   r<   r   r   rV   r   r   r   IndexIVF_invlists_getIndexIVF_invlists_setr   IndexIVF_own_invlists_getIndexIVF_own_invlists_setown_invlistsIndexIVF_code_size_getIndexIVF_code_size_setr  IndexIVF_parallel_mode_getIndexIVF_parallel_mode_setparallel_mode'IndexIVF_PARALLEL_MODE_NO_HEAP_INIT_getPARALLEL_MODE_NO_HEAP_INITIndexIVF_direct_map_getIndexIVF_direct_map_setrU  IndexIVF_by_residual_getIndexIVF_by_residual_setby_residualr  r?  rH  rR  r  r  r  r  r  r  r  r  r]  rg  r
  r{  r  r  r  r  r#  rt  r  r  r`  rV  delete_IndexIVFr   r7  r;  rB  rG  rM  r  r  r>   r%   r$   r   r  r    s   , -/IOdeGKH
88*:Z:Z  aA  BHJ@@*BfBfgL::J<]<]  dH  IIZBBJDiDi 
p 
	M "***\*\!]*<<j>`>` g 	J :>>
@c@c j 	K
/53B
f_ O	FECJGTT[BDG l}	Z9PH8T "11@:RCC6@r$   r  c                      \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  SS9r\" \
R                  \
R                  S	S9r\" \
R"                  \
R$                  S
S9r\" \
R(                  \
R*                  SS9r\" \
R.                  \
R0                  SS9rS rS rS rS rS rS rS r \
RB                  r"Sr#g)InvertedListScanneri,  z
 Object that handles a query. The inverted lists to scan are
provided externally. The object has a lot of state, but
distance_to_code and scan_codes can be called in multiple
threads
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   InvertedListScanner.<lambda>4  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rl  4  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   InvertedListScanner.__init__6  rX   r$   zremember current listzkeep maximum instead of minimumz.store positions in invlists rather than labelszsearch in this subset of idsz,used in default implementation of scan_codesc                 .    [         R                  " X5      $ z!from now on we handle this query.)r   InvertedListScanner_set_queryr   query_vectors     r   r  InvertedListScanner.set_query?  s    77KKr$   c                 0    [         R                  " XU5      $ z,following codes come from this inverted list)r   InvertedListScanner_set_listr   r  r  s      r   set_listInvertedListScanner.set_listC  s    66tjQQr$   c                 .    [         R                  " X5      $ z'compute a single query-to-code distance)r   $InvertedListScanner_distance_to_coder  s     r   r  $InvertedListScanner.distance_to_codeG  s    >>tJJr$   c           	      4    [         R                  " XX#XEU5      $ )a;  
 scan a set of codes, compute distances to current query, and
update heap of results if necessary. Default implementation
calls distance_to_code.

:type n: int
:param n:          number of codes to scan
:type codes: uint8_t
:param codes:      codes to scan (n * code_size)
:type ids: int
:param ids:        corresponding ids (ignored if store_pairs)
:type distances: float
:param distances:  heap distances (size k)
:type labels: int
:param labels:     heap labels (size k)
:type k: int
:param k:          heap size
:rtype: int
:return: number of heap updates performed
)r   InvertedListScanner_scan_codesr   ra   r  r  rR  rS  rQ  s          r   
scan_codesInvertedListScanner.scan_codesK  s    * 88%iabccr$   c                 2    [         R                  " XX#XE5      $ r/   )r   !InvertedListScanner_iterate_codes)r   iteratorrR  rS  rQ  r  s         r   iterate_codes!InvertedListScanner.iterate_codesb  s    ;;DI_`llr$   c                 2    [         R                  " XX#XE5      $ )z
 scan a set of codes, compute distances to current query and
update results if distances are below radius

(default implementation fails)
)r   $InvertedListScanner_scan_codes_ranger   ra   r  r  rW  rX  s         r   scan_codes_range$InvertedListScanner.scan_codes_rangee  s     >>tTZccr$   c                 2    [         R                  " XX#U5      $ r/   )r   'InvertedListScanner_iterate_codes_range)r   r  rW  rX  r  s        r   iterate_codes_range'InvertedListScanner.iterate_codes_rangen  s    AA$RXbkllr$   r%   N)$r   r   r:   r;   r<   r   r   rV   r   r   r   InvertedListScanner_list_no_getInvertedListScanner_list_no_setr   InvertedListScanner_keep_max_get InvertedListScanner_keep_max_setr  #InvertedListScanner_store_pairs_get#InvertedListScanner_store_pairs_setr  InvertedListScanner_sel_getInvertedListScanner_sel_setrT  !InvertedListScanner_code_size_get!InvertedListScanner_code_size_setr  r  rz  r  r  r  r  r  delete_InvertedListScannerr   r>   r%   r$   r   rj  rj  ,  s    -/IOdeGKHzAA:CmCm  tP  QG
CCZEpEp  w]  ^H:II:KyKy  @u  vK
:99:;a;a  hK  LCEEzGsGs  zm  nILRKd.mdm!<<r$   rj  c                      \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      r\" \R*                  \R,                  5      r\" \R0                  \R2                  5      rS rS rS r\R<                  rS	r g
)IndexIVFStatsit  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFStats.<lambda>u  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  u  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   IndexIVFStats_swiginitnew_IndexIVFStatsr[   s    r   rV   IndexIVFStats.__init__~  r   r$   c                 .    [         R                  " U 5      $ r/   )r   IndexIVFStats_resetr[   s    r   r  IndexIVFStats.reset  rw   r$   c                 .    [         R                  " X5      $ r/   )r   IndexIVFStats_addr   s     r   rH  IndexIVFStats.add  r  r$   r%   N)!r   r   r:   r;   r   r   r   r   r   IndexIVFStats_nq_getIndexIVFStats_nq_setr  IndexIVFStats_nlist_getIndexIVFStats_nlist_setr#  IndexIVFStats_ndis_getIndexIVFStats_ndis_setndisIndexIVFStats_nheap_updates_getIndexIVFStats_nheap_updates_setnheap_updates#IndexIVFStats_quantization_time_get#IndexIVFStats_quantization_time_setquantization_timeIndexIVFStats_search_time_getIndexIVFStats_search_time_setsearch_timerV   r  rH  delete_IndexIVFStatsr   r>   r%   r$   r   r  r  t  s    -/IOdeGH	*11:3R3R	SBZ779[9[\EJ55z7X7XYDZGGIsIstM !O!OQ[QQ  A:CCZEmEmnKP49!66r$   r  c                 .    [         R                  " X5      $ )zb
 check if two indexes have the same parameters and are trained in
the same way, otherwise throw.
)r   r  )index1index2s     r   r  r    s    
 00@@r$   c                  (    [         R                  " U 6 $ )z
 get an IndexIVF from an index. The index may be an IndexIVF or
some wrapper class that encloses an IndexIVF

throws an exception if this is not the case.
)r   extract_index_ivfrI  s    r   r  r    s     ''..r$   c                  (    [         R                  " U 6 $ )z@same as above but returns nullptr instead of throwing on failure)r   try_extract_index_ivfrI  s    r   r  r    s    ++T22r$   c                 0    [         R                  " XU5      $ )z
 Merge index1 into index0. Works on IndexIVF's and IndexIVF's
 embedded in a IndexPreTransform. On output, the index1 is empty.

:type shift_ids: boolean
:param shift_ids:: translate the ids from index1 to index0->prev_ntotal
)r   
merge_into)index0r  	shift_idss      r   r  r    s       ;;r$   c                 0    [         R                  " XX#5      $ r/   )r   search_centroid)r}	  rE   ra   centroid_idss       r   r  r    s    %%e@@r$   c           
      4    [         R                  " XX#XEXg5      $ r/   )r   search_and_return_centroids)r}	  ra   xinrQ  rR  rS  query_centroid_idsresult_centroid_idss           r   r  r    s    11%CIWir$   c                   l   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9rS rS r\	R6                  rSrg)SlidingIndexWindowi  z
 A set of IndexIVFs concatenated together in a FIFO fashion.
at each "step", the oldest index slice is removed and a new index is added.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   SlidingIndexWindow.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   z-common index that contains the sliding windowzInvertedLists of indexz#number of slices currently in indexzsame as index->nlistz#cumulative list sizes at each slicec                 Z    [         R                  " U [         R                  " U5      5        g)z+index should be initially empty and trainedN)r   SlidingIndexWindow_swiginitnew_SlidingIndexWindowr   r}	  s     r   rV   SlidingIndexWindow.__init__  s    ..tZ5V5VW\5]^r$   c                 0    [         R                  " XU5      $ )z
 Add one index to the current index and remove the oldest one.

:type sub_index: :py:class:`Index`
:param sub_index:        slice to swap in (can be NULL)
:type remove_oldest: boolean
:param remove_oldest:    if true, remove the oldest slices
)r   SlidingIndexWindow_step)r   	sub_indexremove_oldests      r   stepSlidingIndexWindow.step  s     11$=QQr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   SlidingIndexWindow_index_getSlidingIndexWindow_index_setr}	  SlidingIndexWindow_ils_getSlidingIndexWindow_ils_setr  SlidingIndexWindow_n_slice_getSlidingIndexWindow_n_slice_setn_sliceSlidingIndexWindow_nlist_getSlidingIndexWindow_nlist_setr#  SlidingIndexWindow_sizes_getSlidingIndexWindow_sizes_setr  rV   r  delete_SlidingIndexWindowr   r>   r%   r$   r   r  r    s    
 -/IOdeGHZ<<j>e>e  l`  aE
:88*:_:_  fC  DCz@@*BkBk  r\  ]GZ<<j>e>e  lG  HEZ<<j>e>e  lV  WE_	R ";;r$   r  c                 0    [         R                  " XU5      $ )z'Get a subset of inverted lists [i0, i1))r   get_invlist_range)r}	  r  r  s      r   r  r    s    ''266r$   c                 0    [         R                  " XX#5      $ )zSet a subset of inverted lists)r   set_invlist_range)r}	  r  r  srcs       r   r  r    s    ''2;;r$   c	                 6    [         R                  " XX#XEXgU5	      $ )ac  
 search an IndexIVF, possibly embedded in an IndexPreTransform with
given parameters. This is a way to set the nprobe and get
statdistics in a thread-safe way.

Optionally returns (if non-nullptr):
- nb_dis: number of distances computed
- ms_per_stage: [0]: preprocessing time
                [1]: coarse quantization,
                [2]: list scanning
)r   search_with_parameters)	r}	  ra   rE   rQ  rR  rS  r\  nb_disms_per_stages	            r   r  r    s     ,,UqYPV`lmmr$   c           
      4    [         R                  " XX#XEXg5      $ )z3same as search_with_parameters but for range search)r   range_search_with_parameters)r}	  ra   rE   rW  rX  r\  r  r  s           r   r  r    s    225QX^mmr$   c                 .    [         R                  " X5      $ )z
 Build an IndexIVFResidualQuantizer from an ResidualQuantizer, using the
nlevel first components as coarse quantizer and the rest as codes in invlists
)r   ivf_residual_from_quantizer)r  nlevels     r   r  r    s    
 11$??r$   c                 0    [         R                  " XX#5      $ )a  
 add from codes. NB that the norm component is not used, so the code_size can
be provided.

:type ivfrq: :py:class:`IndexIVFResidualQuantizer`
:param ivfrq:      index to populate with the codes
:type codes: uint8_t
:param codes:      codes to add, size (ncode, code_size)
:type code_size: int, optional
:param code_size:  override the ivfrq's code_size, useful if the norm encoding
                      is different
)r    ivf_residual_add_from_flat_codes)ivfrqr  r  r  s       r   r  r    s     66uUVVr$   c                   P    \ rS rSr\" S S SS9rS r\rS r	\
R                  rSrg	)
ShardingFunctioni  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ShardingFunction.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   ShardingFunction.__init__  rX   r$   c                 0    [         R                  " XU5      $ r/   )r   ShardingFunction___call__r   r+  shard_counts      r   r  ShardingFunction.__call__  s    33D[IIr$   r%   N)r   r   r:   r;   r   r   rV   r   r   r  r   delete_ShardingFunctionr   r>   r%   r$   r   r  r    s0    -/IOdeGKHJ!99r$   r  c                   P    \ rS rSr\" S S SS9r\rS rS r	\
R                  rSrg	)
DefaultShardingFunctioni  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF    DefaultShardingFunction.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 0    [         R                  " XU5      $ r/   )r    DefaultShardingFunction___call__r  s      r   r   DefaultShardingFunction.__call__  s    ::4KPPr$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r    DefaultShardingFunction_swiginitnew_DefaultShardingFunctionr[   s    r   rV    DefaultShardingFunction.__init__  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r  rV   r   delete_DefaultShardingFunctionr   r>   r%   r$   r   r  r    s0    -/IOdeGHQd!@@r$   r  c                  (    [         R                  " U 6 $ )a  
Shards an IVF index centroids by the given sharding function, and writes
the index to the path given by filename_generator. The centroids must already
be added to the index quantizer.

:type index: :py:class:`IndexIVF`
:param index:             The IVF index containing centroids to shard.
:type shard_count: int, optional
:param shard_count:       Number of shards.
:type filename_template: string, optional
:param filename_template: Template for shard filenames.
:type sharding_function: :py:class:`ShardingFunction`, optional
:param sharding_function: The function to shard by. The default is ith vector
                             mod shard_count.
:type generate_ids: boolean, optional
:param generate_ids:      Generates ids using IndexIDMap2. If true, ids will
                             match the default ids in the unsharded index.
:rtype: void
:return: The number of shards written.
)r   shard_ivf_index_centroidsrI  s    r   r  r    s    * //66r$   c                  (    [         R                  " U 6 $ r/   )r    shard_binary_ivf_index_centroidsrI  s    r   r  r  0  s    66==r$   c                      \ rS rSrSr\" S S SS9r\r\	R                  r \	R                  r \	R                  r \	R                   r\	R$                  r\	R(                  r \	R,                  r \	R0                  r\	R4                  r \" \	R8                  \	R:                  5      r\	R>                  r  \	RB                  r" \	RF                  r$ \	RJ                  r& \" \	RN                  \	RP                  5      r)\" \	RT                  \	RV                  5      r,\" \	RZ                  \	R\                  SS9r/\" \	R`                  \	Rb                  SS9r2S	 r3S
 r4S r5S r6S r7S r8S r9SS jr:\	Rv                  r<Sr=g)ScalarQuantizeri2  z
The uniform quantizer has a range [vmin, vmax]. The range can be
the same for all dimensions (uniform) or specific per dimension
(default).
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ScalarQuantizer.<lambda>9  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  9  rL   r$   rM   rN   zbits per scalar codez$trained values (including the range)c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   ScalarQuantizer_swiginitnew_ScalarQuantizerr   s     r   rV   ScalarQuantizer.__init__[  r  r$   c                 .    [         R                  " U 5      $ )z,updates internal values based on qtype and d)r   !ScalarQuantizer_set_derived_sizesr[   s    r   set_derived_sizes!ScalarQuantizer.set_derived_sizes^      ;;DAAr$   c                 0    [         R                  " XU5      $ r/   )r   ScalarQuantizer_trainr>  s      r   r?  ScalarQuantizer.trainb  r  r$   c                 0    [         R                  " XX#5      $ )z
 Encode a set of vectors

:type x: float
:param x:      vectors to encode, size n * d
:type codes: uint8_t
:param codes:  output codes, size n * code_size
)r   ScalarQuantizer_compute_codesr	  s       r   r	  ScalarQuantizer.compute_codese  s     77JJr$   c                 0    [         R                  " XX#5      $ )z
 Decode a set of vectors

:param codes:  codes to decode, size n * code_size
:type x: float
:param x:      output vectors, size n * d
)r   ScalarQuantizer_decoder	  s       r   r	  ScalarQuantizer.decodep  s     00QBBr$   c                 .    [         R                  " U 5      $ r/   )r    ScalarQuantizer_select_quantizerr[   s    r   select_quantizer ScalarQuantizer.select_quantizerz  rr  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   %ScalarQuantizer_get_distance_computerr   s     r   r  %ScalarQuantizer.get_distance_computer}  s    ??LtLLr$   c                 2    [         R                  " XX#XE5      $ r/   )r   *ScalarQuantizer_select_InvertedListScanner)r   r  r  r  rT  rg  s         r   select_InvertedListScanner*ScalarQuantizer.select_InvertedListScanner  s    DDTygjxxr$   r%   NrV  )>r   r   r:   r;   r<   r   r   r   r   r   ScalarQuantizer_QT_8bitQT_8bitScalarQuantizer_QT_4bitQT_4bitScalarQuantizer_QT_8bit_uniformQT_8bit_uniformScalarQuantizer_QT_4bit_uniformQT_4bit_uniformScalarQuantizer_QT_fp16QT_fp16ScalarQuantizer_QT_8bit_directQT_8bit_directScalarQuantizer_QT_6bitQT_6bitScalarQuantizer_QT_bf16QT_bf16%ScalarQuantizer_QT_8bit_direct_signedQT_8bit_direct_signedScalarQuantizer_qtype_getScalarQuantizer_qtype_setqtypeScalarQuantizer_RS_minmax	RS_minmaxScalarQuantizer_RS_meanstd
RS_meanstdScalarQuantizer_RS_quantilesRS_quantilesScalarQuantizer_RS_optimRS_optimScalarQuantizer_rangestat_getScalarQuantizer_rangestat_set	rangestat!ScalarQuantizer_rangestat_arg_get!ScalarQuantizer_rangestat_arg_setrangestat_argScalarQuantizer_bits_getScalarQuantizer_bits_setbitsScalarQuantizer_trained_getScalarQuantizer_trained_settrainedrV   r'  r?  r	  r	  r5  r  r<  delete_ScalarQuantizerr   r>   r%   r$   r   r  r  2  s    -/IOdeGH00G00G @@O0 @@O00G>>N"00G00G&LL Z99:;_;_`E44I366J-::L22H9AA:CkCklIZII:KwKwxMJ779\9\b}~Dz==z?e?e  lW  XGYB<	KCAMy!88r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS rS	 rSS jrS rS rS r\	R&                  rSrg
)IndexScalarQuantizeri  z'Flat index built on a scalar quantizer.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexScalarQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rk    rL   r$   rM   rN   zUsed to encode the vectorsc                 T    [         R                  " U [         R                  " U6 5        g)z
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:type qtype: int
:param qtype:  type of scalar quantizer (e.g., QT_4bit)
:type metric: int, optional
:param metric: distance metric used for search (default: METRIC_L2)
N)r   IndexScalarQuantizer_swiginitnew_IndexScalarQuantizerr   s     r   rV   IndexScalarQuantizer.__init__  s      	00z7Z7Z\`7abr$   c                 0    [         R                  " XU5      $ r/   )r   IndexScalarQuantizer_trainr>  s      r   r?  IndexScalarQuantizer.train  rN  r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexScalarQuantizer_searchr[  s          r   r]  IndexScalarQuantizer.search  r'  r$   c                 .    [         R                  " U 5      $ r/   )r   2IndexScalarQuantizer_get_FlatCodesDistanceComputerr[   s    r   rQ  2IndexScalarQuantizer.get_FlatCodesDistanceComputer  s    LLTRRr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexScalarQuantizer_sa_encoder  s       r   r  IndexScalarQuantizer.sa_encode  s    88!KKr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexScalarQuantizer_sa_decoder  s       r   r  IndexScalarQuantizer.sa_decode  s    88%KKr$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   IndexScalarQuantizer_sq_getIndexScalarQuantizer_sq_setsqrV   r?  r]  rQ  r  r  delete_IndexScalarQuantizerr   r>   r%   r$   r   ri  ri    sm    2-/IOdeGH	*88*:`:`  gH  
IBcA`SLL!==r$   ri  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS rS	 rSS
 jrS rSS jrS rS rS r\	R,                  rSrg)IndexIVFScalarQuantizeri  z
 An IVF implementation where the components of the residuals are
encoded with a scalar quantizer. All distance computations
are asymmetric, so the encoded vectors are decoded and approximate
distances are computed.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF    IndexIVFScalarQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r    IndexIVFScalarQuantizer_swiginitnew_IndexIVFScalarQuantizerr   s     r   rV    IndexIVFScalarQuantizer.__init__  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   %IndexIVFScalarQuantizer_train_encoderr  s       r   r  %IndexIVFScalarQuantizer.train_encoder  s    ??SSr$   c                 .    [         R                  " U 5      $ r/   )r   1IndexIVFScalarQuantizer_train_encoder_num_vectorsr[   s    r   r  1IndexIVFScalarQuantizer.train_encoder_num_vectors  s    KKDQQr$   c                 2    [         R                  " XX#XE5      $ r/   )r   &IndexIVFScalarQuantizer_encode_vectorsr   ra   rE   r"  r  include_listnoss         r   r  &IndexIVFScalarQuantizer.encode_vectors  s    @@!W\nnr$   c                 2    [         R                  " XX#U5      $ r/   )r   &IndexIVFScalarQuantizer_decode_vectorsr  s        r   r  &IndexIVFScalarQuantizer.decode_vectors  s    @@%[\]]r$   Nc                 2    [         R                  " XX#XE5      $ r/   )r    IndexIVFScalarQuantizer_add_corer  s         r   r   IndexIVFScalarQuantizer.add_core  s    ::4A_ttr$   c                 0    [         R                  " XX#5      $ r/   )r   /IndexIVFScalarQuantizer_get_InvertedListScannerr	  s       r   r
  /IndexIVFScalarQuantizer.get_InvertedListScanner  s    II$]`iir$   c                 0    [         R                  " XX#5      $ r/   )r   /IndexIVFScalarQuantizer_reconstruct_from_offsetr"  s       r   r#  /IndexIVFScalarQuantizer.reconstruct_from_offset  s    II$Y_hhr$   c                 0    [         R                  " XX#5      $ r/   )r   !IndexIVFScalarQuantizer_sa_decoder  s       r   r  !IndexIVFScalarQuantizer.sa_decode  s    ;;DUNNr$   r%   rV  r/   )r   r   r:   r;   r<   r   r   r   r   r   IndexIVFScalarQuantizer_sq_getIndexIVFScalarQuantizer_sq_setr  rV   r  r  r  r  r  r
  r#  r  delete_IndexIVFScalarQuantizerr   r>   r%   r$   r   r  r    sy     -/IOdeGH	*;;Z=f=f	gBiTRo^ujiO!@@r$   r  c                   $   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\	R,                  r \	R0                  r \	R4                  r \	R8                  r \" \	R<                  \	R>                  5      r \" \	RB                  \	RD                  SS9r#S r$S r%SS jr&S r'S r(\	RR                  r*Sr+g)IndexIVFSpectralHashi  ah  
 Inverted list that stores binary codes of size nbit. Before the
binary conversion, the dimension of the vectors is transformed from
dim d into dim nbit by vt (a random rotation by default).

Each coordinate is subtracted from a value determined by
threshold_type, and split into intervals of size period. Half of
the interval is a 0 bit, the other half a 1.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFSpectralHash.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   z!transformation from d to nbit dimz
own the vtz"nb of bits of the binary signaturezinterval size for 0s and 1szH
    Trained threshold.
    size nlist * nbit or 0 if Thresh_global
    c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexIVFSpectralHash_swiginitnew_IndexIVFSpectralHashr   s     r   rV   IndexIVFSpectralHash.__init__  rJ  r$   c                 0    [         R                  " XX#5      $ r/   )r   "IndexIVFSpectralHash_train_encoderr  s       r   r  "IndexIVFSpectralHash.train_encoder  s    <<TaPPr$   c                 2    [         R                  " XX#XE5      $ r/   )r   #IndexIVFSpectralHash_encode_vectorsr  s         r   r  #IndexIVFSpectralHash.encode_vectors  s    ==dqTYkkr$   c                 0    [         R                  " XX#5      $ r/   )r   ,IndexIVFSpectralHash_get_InvertedListScannerr	  s       r   r
  ,IndexIVFSpectralHash.get_InvertedListScanner      FFtZ]ffr$   c                 0    [         R                  " U /UQ76 $ )aM  
*Overload 1:*
 replace the vector transform for an empty (and possibly untrained) index

|

*Overload 2:*
 convenience function to get the VT from an index constructed by an
index_factory (should end in "LSH")

|

*Overload 3:*
 convenience function to get the VT from an index constructed by an
index_factory (should end in "LSH")
)r   IndexIVFSpectralHash_replace_vtr   s     r   
replace_vtIndexIVFSpectralHash.replace_vt  s    " 99$FFFr$   r%   NrV  ),r   r   r:   r;   r<   r   r   r   r   r   IndexIVFSpectralHash_vt_getIndexIVFSpectralHash_vt_setr  #IndexIVFSpectralHash_own_fields_get#IndexIVFSpectralHash_own_fields_setrR  IndexIVFSpectralHash_nbit_getIndexIVFSpectralHash_nbit_setr"  IndexIVFSpectralHash_period_getIndexIVFSpectralHash_period_setperiod"IndexIVFSpectralHash_Thresh_globalThresh_global$IndexIVFSpectralHash_Thresh_centroidThresh_centroid)IndexIVFSpectralHash_Thresh_centroid_halfThresh_centroid_half"IndexIVFSpectralHash_Thresh_medianThresh_median'IndexIVFSpectralHash_threshold_type_get'IndexIVFSpectralHash_threshold_type_setthreshold_type IndexIVFSpectralHash_trained_get IndexIVFSpectralHash_trained_setrf  rV   r  r  r
  r  delete_IndexIVFSpectralHashr   r>   r%   r$   r   r  r    sP    -/IOdeGH	*88*:`:`  gO  
PB*HH*JxJx  P  QJJ<<j>f>f  mV  WDj@@*BlBl  sU  VFAAM  EEO%OO+AAM!jPPR\  SE  SE  FNzBBJDoDo v 	G
cQlgG$ "==r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS rS	 rSS
 jrS rS rS rS r\	R0                  rSrg)IndexIVFAdditiveQuantizeri  zQ
Abstract class for IVF additive quantizers.
The search functions are in common.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   "IndexIVFAdditiveQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   "IndexIVFAdditiveQuantizer_swiginitnew_IndexIVFAdditiveQuantizerr   s     r   rV   "IndexIVFAdditiveQuantizer.__init__"  s    55dJ<d<dfj<klr$   c                 0    [         R                  " XX#5      $ r/   )r   'IndexIVFAdditiveQuantizer_train_encoderr  s       r   r  'IndexIVFAdditiveQuantizer.train_encoder%  s    AA$1UUr$   c                 .    [         R                  " U 5      $ r/   )r   3IndexIVFAdditiveQuantizer_train_encoder_num_vectorsr[   s    r   r  3IndexIVFAdditiveQuantizer.train_encoder_num_vectors(  s    MMdSSr$   c                 2    [         R                  " XX#XE5      $ r/   )r   (IndexIVFAdditiveQuantizer_encode_vectorsr  s         r   r  (IndexIVFAdditiveQuantizer.encode_vectors+  s    BB4AY^ppr$   c                 2    [         R                  " XX#U5      $ r/   )r   (IndexIVFAdditiveQuantizer_decode_vectorsr  s        r   r  (IndexIVFAdditiveQuantizer.decode_vectors.  s    BB4E]^__r$   c                 0    [         R                  " XX#5      $ r/   )r   1IndexIVFAdditiveQuantizer_get_InvertedListScannerr	  s       r   r
  1IndexIVFAdditiveQuantizer.get_InvertedListScanner1  s    KKD_bkkr$   c                 0    [         R                  " XX#5      $ r/   )r   #IndexIVFAdditiveQuantizer_sa_decoder   ra   r  rE   s       r   r  #IndexIVFAdditiveQuantizer.sa_decode4  s    ==duPPr$   c                 0    [         R                  " XX#5      $ r/   )r   1IndexIVFAdditiveQuantizer_reconstruct_from_offsetr"  s       r   r#  1IndexIVFAdditiveQuantizer.reconstruct_from_offset7  s    KKD[ajjr$   r%   NrV  )r   r   r:   r;   r<   r   r   r   r   r    IndexIVFAdditiveQuantizer_aq_get IndexIVFAdditiveQuantizer_aq_setrI  3IndexIVFAdditiveQuantizer_use_precomputed_table_get3IndexIVFAdditiveQuantizer_use_precomputed_table_setuse_precomputed_tablerV   r  r  r  r  r
  r  r#   delete_IndexIVFAdditiveQuantizerr   r>   r%   r$   r   r  r    s    
 -/IOdeGH	*==z?j?j	kB$Z%c%ceo  fd  fd  emVTq`lQk!BBr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS r\	R                  rS	rg
)IndexIVFResidualQuantizeri=  j
 IndexIVF based on a residual quantizer. Stored vectors are
approximated by residual quantization codes.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   "IndexIVFResidualQuantizer.<lambda>C  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  C  rL   r$   rM   rN   rQ  c                 T    [         R                  " U [         R                  " U6 5        g)z
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:param M:      number of subquantizers
:type nbits: std::vector< size_t >
:param nbits:  number of bit per subvector index
N)r   "IndexIVFResidualQuantizer_swiginitnew_IndexIVFResidualQuantizerr   s     r   rV   "IndexIVFResidualQuantizer.__init__G  s      	55dJ<d<dfj<klr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r    IndexIVFResidualQuantizer_rq_get IndexIVFResidualQuantizer_rq_setr  rV    delete_IndexIVFResidualQuantizerr   r>   r%   r$   r   r  r  =  sU    
 -/IOdeGH	*==z?j?j  qi  
jB
m "BBr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS r\	R                  rS	rg
)IndexIVFLocalSearchQuantizeriV  r  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   %IndexIVFLocalSearchQuantizer.<lambda>\  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  \  rL   r$   rM   rN   z,The LSQ quantizer used to encode the vectorsc                 T    [         R                  " U [         R                  " U6 5        gr  )r   %IndexIVFLocalSearchQuantizer_swiginit new_IndexIVFLocalSearchQuantizerr   s     r   rV   %IndexIVFLocalSearchQuantizer.__init__`  s      	88z?j?jlp?qrr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   $IndexIVFLocalSearchQuantizer_lsq_get$IndexIVFLocalSearchQuantizer_lsq_setr  rV   #delete_IndexIVFLocalSearchQuantizerr   r>   r%   r$   r   r  r  V  sU    
 -/IOdeGH
:BBJDsDs  zm  nCs "EEr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS r\	R                  rS	rg
) IndexIVFProductResidualQuantizerip  zz
 IndexIVF based on a product residual quantizer. Stored vectors are
approximated by product residual quantization codes.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   )IndexIVFProductResidualQuantizer.<lambda>v  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  v  rL   r$   rM   rN   rr  c                 T    [         R                  " U [         R                  " U6 5        g)a  
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:type nsplits: int
:param nsplits:  number of residual quantizers
:type Msub: int
:param Msub:   number of subquantizers per RQ
:type nbits: int
:param nbits:  number of bit per subvector index
N)r   )IndexIVFProductResidualQuantizer_swiginit$new_IndexIVFProductResidualQuantizerr   s     r   rV   )IndexIVFProductResidualQuantizer.__init__z  s      	<<T:CrCrtxCyzr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   (IndexIVFProductResidualQuantizer_prq_get(IndexIVFProductResidualQuantizer_prq_setr|  rV   'delete_IndexIVFProductResidualQuantizerr   r>   r%   r$   r   r  r  p  sU    
 -/IOdeGH
:FF
H{H{  BB  CC{ "IIr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS r\	R                  rS	rg
)#IndexIVFProductLocalSearchQuantizeri  z
 IndexIVF based on a product local search quantizer. Stored vectors are
approximated by product local search quantization codes.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ,IndexIVFProductLocalSearchQuantizer.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r%    rL   r$   rM   rN   r  c                 T    [         R                  " U [         R                  " U6 5        g)a  
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:type nsplits: int
:param nsplits:  number of local search quantizers
:type Msub: int
:param Msub:   number of subquantizers per LSQ
:type nbits: int
:param nbits:  number of bit per subvector index
N)r   ,IndexIVFProductLocalSearchQuantizer_swiginit'new_IndexIVFProductLocalSearchQuantizerr   s     r   rV   ,IndexIVFProductLocalSearchQuantizer.__init__  s#     	??jFxFxz~F  	Ar$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   ,IndexIVFProductLocalSearchQuantizer_plsq_get,IndexIVFProductLocalSearchQuantizer_plsq_setr  rV   *delete_IndexIVFProductLocalSearchQuantizerr   r>   r%   r$   r   r#  r#    s]    
 -/IOdeGHJKKZ  NE  NE  KO  PDA "LLr$   r#  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\R$                  rS rSrg)	SearchParametersHNSWi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   SearchParametersHNSW.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r1    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   SearchParametersHNSW_swiginitnew_SearchParametersHNSWr[   s    r   rV   SearchParametersHNSW.__init__  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   !SearchParametersHNSW_efSearch_get!SearchParametersHNSW_efSearch_setefSearch0SearchParametersHNSW_check_relative_distance_get0SearchParametersHNSW_check_relative_distance_setcheck_relative_distance&SearchParametersHNSW_bounded_queue_get&SearchParametersHNSW_bounded_queue_setbounded_queuedelete_SearchParametersHNSWr   rV   r>   r%   r$   r   r/  r/    s    -/IOdeGH
DDjFrFrsH&z'b'bdn  e`  e`  aZNNPZ  QB  QB  CM!==^r$   r/  c                   x   \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9r\" \R                  \R                  SS9r\" \R                  \R                   SS9r\" \R$                  \R&                  S	S9r\" \R*                  \R,                  S
S9r\" \R0                  \R2                  SS9r\" \R6                  \R8                  5      r\" \R<                  \R>                  SS9r \" \RB                  \RD                  SS9r#\" \RH                  \RJ                  SS9r&\" \RN                  \RP                  SS9r)\" \RT                  \RV                  SS9r,S r-S r.S r/S r0S r1S%S jr2S r3S r4S&S jr5S&S jr6S'S jr7S'S jr8S r9S r:S  r;S&S! jr<\=S&S" j5       r>S# r?\R                  rAS$rBg)(HNSWi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   HNSW.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rD    rL   r$   rM   rN   z,assignment probability to each layer (sum=1)zf
    number of neighbors stored per layer (cumulative), should not
    be changed after first add
    z4level of each vector (base level = 1), size = ntotalzf
    offsets[i] is the offset in the neighbors array where vector i is stored
    size ntotal + 1
    z
    neighbors[offsets[i]:offsets[i+1]] is the list of neighbors of vector i
    for all levels. this is where all storage goes.
    zW
    entry point in the search structure (one of the points with maximum
    level
    zmaximum levelz%expansion factor at construction timezexpansion factor at search timezW
    during search: do we check whether the next best distance is good
    enough?
    z$use bounded queue during explorationc                 0    [         R                  " XU5      $ )zq
initialize the assign_probas and cum_nneighbor_per_level to
have 2*M links on level 0 and M links on levels > 0
)r   HNSW_set_default_probas)r   rX
  	levelMults      r   set_default_probasHNSW.set_default_probas  s    
 11$9EEr$   c                 0    [         R                  " XU5      $ )z;set nb of neighbors for this level (before adding anything))r   HNSW_set_nb_neighbors)r   level_nora   s      r   set_nb_neighborsHNSW.set_nb_neighbors  s    //BBr$   c                 .    [         R                  " X5      $ )znb of neighbors for this level)r   HNSW_nb_neighborsr   layer_nos     r   nb_neighborsHNSW.nb_neighbors  s    ++D;;r$   c                 .    [         R                  " X5      $ )z.cumulative nb up to (and excluding) this level)r   HNSW_cum_nb_neighborsrR  s     r   cum_nb_neighborsHNSW.cum_nb_neighbors  s    //??r$   c                 2    [         R                  " XX#U5      $ )z@range of entries in the neighbors table of vertex no at layer_no)r   HNSW_neighbor_range)r   r)  rS  beginends        r   neighbor_rangeHNSW.neighbor_range  s    --dMMr$   c                 Z    [         R                  " U [         R                  " U5      5        g)z)only mandatory parameter: nb of neighborsN)r   HNSW_swiginitnew_HNSW)r   rX
  s     r   rV   HNSW.__init__  s      z':':1'=>r$   c                 .    [         R                  " U 5      $ )z#pick a random level for a new point)r   HNSW_random_levelr[   s    r   random_levelHNSW.random_level      ++D11r$   c                 .    [         R                  " X5      $ )z/add n random levels to table (for debugging...))r   HNSW_fill_with_random_linksr`   s     r   fill_with_random_linksHNSW.fill_with_random_links  s    55d>>r$   c	                 6    [         R                  " XX#XEXgU5	      $ r/   )r   HNSW_add_links_starting_from)	r   ptdispt_idnearest	d_nearestlevellocksr  keep_max_size_level0s	            r   add_links_starting_fromHNSW.add_links_starting_from  s(    66tET]fk  rF  G  	Gr$   c           	      4    [         R                  " XX#XEU5      $ )zS
 add point pt_id on all levels <= pt_level and build the link
structure for them.
)r   HNSW_add_with_locks)r   ro  pt_levelrp  rt  r  ru  s          r   add_with_locksHNSW.add_with_locks  s    
 --d8EWkllr$   Nc                 2    [         R                  " XX#U5      $ )z+search interface for 1 point, single thread)r   HNSW_search)r   qdisr=
  r  r\  s        r   r]  HNSW.search  s    %%d#6BBr$   c
                 6    [         R                  " XX#XEXgX5
      $ )z*search only in level 0 from a given vertex)r   HNSW_search_level_0)
r   r  r=
  r  	nearest_i	nearest_dr  search_statsr  r\  s
             r   search_level_0HNSW.search_level_0  s#    --d#y]hxz  D  	Dr$   c                 .    [         R                  " U 5      $ r/   )r   
HNSW_resetr[   s    r   r  
HNSW.reset	  s    $$T**r$   c                 .    [         R                  " X5      $ r/   )r   HNSW_clear_neighbor_tablesr   rs  s     r   clear_neighbor_tablesHNSW.clear_neighbor_tables  r  r$   c                 .    [         R                  " X5      $ r/   )r   HNSW_print_neighbor_statsr  s     r   print_neighbor_statsHNSW.print_neighbor_stats  r  r$   c                 0    [         R                  " XU5      $ r/   )r   HNSW_prepare_level_tab)r   ra   preset_levelss      r   prepare_level_tabHNSW.prepare_level_tab  s    00-HHr$   c                 2    [         R                  " XX#U5      $ r/   )r   HNSW_shrink_neighbor_list)r  inputoutputmax_sizeru  s        r   shrink_neighbor_listHNSW.shrink_neighbor_list  s    33DSghhr$   c                 .    [         R                  " X5      $ r/   )r   HNSW_permute_entriesr  s     r   rq  HNSW.permute_entries  s    ..t99r$   r%       rV  r/   )Cr   r   r:   r;   r   r   r   r   r   HNSW_assign_probas_getHNSW_assign_probas_setassign_probas HNSW_cum_nneighbor_per_level_get HNSW_cum_nneighbor_per_level_setcum_nneighbor_per_levelHNSW_levels_getHNSW_levels_setlevelsHNSW_offsets_getHNSW_offsets_setoffsetsHNSW_neighbors_getHNSW_neighbors_set	neighborsHNSW_entry_point_getHNSW_entry_point_setentry_pointHNSW_rng_getHNSW_rng_setrngHNSW_max_level_getHNSW_max_level_set	max_levelHNSW_efConstruction_getHNSW_efConstruction_setefConstructionHNSW_efSearch_getHNSW_efSearch_setr9   HNSW_check_relative_distance_get HNSW_check_relative_distance_setr<  HNSW_search_bounded_queue_getHNSW_search_bounded_queue_setsearch_bounded_queuerI  rN  rT  rX  r^  rV   rf  rk  rv  r{  r]  r  r  r  r  r  r7  r  rq  delete_HNSWr   r>   r%   r$   r   rB  rB    s   -/IOdeGHZ>>
@a@a  h[  \M&z'R'RT^TT F 	 j00*2L2L  SN  OFz22J4O4O V 	G 66
8U8U \ 	I :::J<[<[ b 	K :**J,C,C
DC66
8U8U[opIj@@*BdBd  kW  XN
44j6R6RX~H&z'R'RT^TT F 	 $J$L$LjNvNv  }h  iFC<@N?2?GmCD+BAI i i:!--r$   rB  c                   8   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  SS9r\" \R                  \R                   SS9r\" \R$                  \R&                  SS9rS	 rS
 rS r\R0                  rSrg)	HNSWStatsi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   HNSWStats.<lambda>   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r     rL   r$   rM   rN   znumber of vectors searchedz;number of queries for which the candidate list is exhaustedznumber of distances computedc                 .    [         R                  " U 5      $ )z,number of hops aka number of edges traversed)r   HNSWStats_resetr[   s    r   r  HNSWStats.reset'  r6  r$   c                 .    [         R                  " X5      $ r/   )r   HNSWStats_combiner   s     r   combineHNSWStats.combine+  r  r$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   HNSWStats_swiginitnew_HNSWStatsr[   s    r   rV   HNSWStats.__init__.  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   HNSWStats_n1_getHNSWStats_n1_setr]  HNSWStats_n2_getHNSWStats_n2_setr^  HNSWStats_ndis_getHNSWStats_ndis_setr  HNSWStats_nhops_getHNSWStats_nhops_setnhopsr  r  rV   delete_HNSWStatsr   r>   r%   r$   r   r  r    s    -/IOdeGH	*--z/J/J	KB	*--z/J/JPq	rBJ11:3P3P  WY  ZDZ33Z5S5SY|}E09H!22r$   r  c	                 6    [         R                  " XX#XEXgU5	      $ r/   )r   search_from_candidates)	hnswr  r=
  
candidatesr  r  rs  nres_inr\  s	            r   r  r  5  s    ,,T"UZekllr$   c                 2    [         R                  " XX#U5      $ r/   )r   greedy_update_nearest)r  r  rs  rq  rr  s        r   r  r  8  s    ++D	RRr$   c                 2    [         R                  " XX#XE5      $ r/   )r   search_from_candidate_unbounded)r  noder  efr  r  s         r   r  r  ;  s    55d$BVVr$   c           
      4    [         R                  " XX#XEXg5      $ r/   )r   search_neighbors_to_add)r  r  resultsr  d_entry_pointrs  r  reference_versions           r   r  r  >  s    --d'P]fh||r$   c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      r\" \	R,                  \	R.                  5      rS r\	R4                  rS rS	 rSS jrSS jrS r S r!S r"SS jr#S r$S r%S r&S r'S r(S r)Sr*g
)	IndexHNSWi@  Y
 The HNSW index is a normal random-access index with a HNSW
link structure built on top
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexHNSW.<lambda>F  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  F  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexHNSW_swiginitnew_IndexHNSWr   s     r   rV   IndexHNSW.__init__N  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexHNSW_addr>  s      r   rH  IndexHNSW.addR  r  r$   c                 0    [         R                  " XU5      $ zTrains the storage if needed)r   IndexHNSW_trainr>  s      r   r?  IndexHNSW.trainU      ))$155r$   Nc           	      4    [         R                  " XX#XEU5      $ zentry point for search)r   IndexHNSW_searchr[  s          r   r]  IndexHNSW.searchY  s    **4A)VTTr$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexHNSW_range_searchrf  s         r   rg  IndexHNSW.range_search]  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexHNSW_reconstructrx  s      r   r{  IndexHNSW.reconstruct`  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexHNSW_resetr[   s    r   r  IndexHNSW.resetc  r  r$   c                 .    [         R                  " X5      $ r/   )r   "IndexHNSW_shrink_level_0_neighborsr   r   s     r   shrink_level_0_neighbors"IndexHNSW.shrink_level_0_neighborsf      <<THHr$   c                 8    [         R                  " XX#XEXgXU
5      $ )z
 Perform search only on level 0, given the starting points for
each vertex.

:type search_type: int, optional
:param search_type: 1:perform one search per nprobe, 2: enqueue
                       all entry points
)r   IndexHNSW_search_level_0)r   ra   rE   rQ  rq  r  rR  rS  r  r  r\  s              r   r  IndexHNSW.search_level_0i  s,     224A'V_io  E  F  	Fr$   c                 0    [         R                  " XX#5      $ zalternative graph building)r   $IndexHNSW_init_level_0_from_knngraph)r   rQ  r  r
  s       r   init_level_0_from_knngraph$IndexHNSW.init_level_0_from_knngrapht  s    >>tMMr$   c                 0    [         R                  " XX#5      $ r  )r   (IndexHNSW_init_level_0_from_entry_points)r   nptpointsnearestss       r   init_level_0_from_entry_points(IndexHNSW.init_level_0_from_entry_pointsx  s    BB4f__r$   c                 .    [         R                  " U 5      $ r/   )r   IndexHNSW_reorder_linksr[   s    r   reorder_linksIndexHNSW.reorder_links|  r   r$   c                 .    [         R                  " U 5      $ r/   )r   IndexHNSW_link_singletonsr[   s    r   link_singletonsIndexHNSW.link_singletons  r  r$   c                 .    [         R                  " X5      $ r/   )r   IndexHNSW_permute_entriesrp  s     r   rq  IndexHNSW.permute_entries  s    33D??r$   c                 .    [         R                  " U 5      $ r/   )r   IndexHNSW_get_distance_computerr[   s    r   r  IndexHNSW.get_distance_computer  r'  r$   r%   r/   )r   r   N)+r   r   r:   r;   r<   r   r   r   r   r   IndexHNSW_hnsw_getIndexHNSW_hnsw_setr  IndexHNSW_own_fields_getIndexHNSW_own_fields_setrR  IndexHNSW_storage_getIndexHNSW_storage_setstorageIndexHNSW_init_level0_getIndexHNSW_init_level0_setinit_level0"IndexHNSW_keep_max_size_level0_get"IndexHNSW_keep_max_size_level0_setru  rV   delete_IndexHNSWr   rH  r?  r]  rg  r{  r  r  r  r  r$  r(  r,  rq  r  r>   r%   r$   r   r  r  @  s   
 -/IOdeGHJ11:3P3PQD*==z?b?bcJz779Y9YZG:??AeAefK#J$Q$QS]  TA  TA  BM!2246UUC0I	FN`8:@@r$   r  c                   N    \ rS rSrSr\" S S SS9r\rS r	\
R                  rSrg	)
IndexHNSWFlati  zS
Flat index topped with with a HNSW structure to access elements
more efficiently.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexHNSWFlat.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rD    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexHNSWFlat_swiginitnew_IndexHNSWFlatr   s     r   rV   IndexHNSWFlat.__init__      ))$
0L0Ld0STr$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r   delete_IndexHNSWFlatr   r>   r%   r$   r   rB  rB    s1    
 -/IOdeGHU!66r$   rB  c                   T    \ rS rSrSr\" S S SS9r\rS r	S r
\R                  rS	rg
)IndexHNSWPQi  zQ
PQ index topped with with a HNSW structure to access elements
more efficiently.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexHNSWPQ.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rO    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexHNSWPQ_swiginitnew_IndexHNSWPQr   s     r   rV   IndexHNSWPQ.__init__  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexHNSWPQ_trainr>  s      r   r?  IndexHNSWPQ.train  rp  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r?  r   delete_IndexHNSWPQr   r>   r%   r$   r   rM  rM    s6    
 -/IOdeGHQ8!44r$   rM  c                   N    \ rS rSrSr\" S S SS9r\rS r	\
R                  rSrg	)
IndexHNSWSQi  zL
SQ index topped with a HNSW structure to access elements
more efficiently.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexHNSWSQ.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r\    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexHNSWSQ_swiginitnew_IndexHNSWSQr   s     r   rV   IndexHNSWSQ.__init__  r  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r   delete_IndexHNSWSQr   r>   r%   r$   r   rZ  rZ    s1    
 -/IOdeGHQ!44r$   rZ  c                   ^    \ rS rSrSr\" S S SS9r\rS r	S r
SS
 jr\R                  rSrg	)IndexHNSW2Leveli  z.2-level code structure with fast random accessc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexHNSW2Level.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rf    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexHNSW2Level_swiginitnew_IndexHNSW2Levelr   s     r   rV   IndexHNSW2Level.__init__  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexHNSW2Level_flip_to_ivfr[   s    r   flip_to_ivfIndexHNSW2Level.flip_to_ivf  r  r$   Nc           	      4    [         R                  " XX#XEU5      $ r  )r   IndexHNSW2Level_searchr[  s          r   r]  IndexHNSW2Level.search      00!	SYZZr$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   rV   rn  r]  r   delete_IndexHNSW2Levelr   r>   r%   r$   r   rd  rd    s:    9-/IOdeGHY<[ "88r$   rd  c                      \ rS rSr\" S S SS9r\rS r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9rS	 rSS jrS rS r\" \	R(                  \	R*                  5      r\	R.                  rSrg
)IndexHNSWCagrai  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexHNSWCagra.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rx    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexHNSWCagra_swiginitnew_IndexHNSWCagrar   s     r   rV   IndexHNSWCagra.__init__  r;  r$   a  
    When set to true, the index is immutable.
    This option is used to copy the knn graph from GpuIndexCagra
    to the base level of IndexHNSWCagra without adding upper levels.
    Doing so enables to search the HNSW index, but removes the
    ability to add vectors.
    
    When `base_level_only` is set to `True`, the search function
    searches only the base level knn graph of the HNSW index.
    This parameter selects the entry point by randomly selecting
    some points and using the best one.
    c                 0    [         R                  " XU5      $ r/   )r   IndexHNSWCagra_addr>  s      r   rH  IndexHNSWCagra.add  r{  r$   Nc           	      4    [         R                  " XX#XEU5      $ r  )r   IndexHNSWCagra_searchr[  s          r   r]  IndexHNSWCagra.search  rY  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexHNSWCagra_get_numeric_typer[   s    r   get_numeric_typeIndexHNSWCagra.get_numeric_type  r'  r$   c                 .    [         R                  " X5      $ r/   )r   IndexHNSWCagra_set_numeric_type)r   r#  s     r   set_numeric_typeIndexHNSWCagra.set_numeric_type  s    99$MMr$   r%   r/   )r   r   r:   r;   r   r   r   r   rV   r   "IndexHNSWCagra_base_level_only_get"IndexHNSWCagra_base_level_only_setbase_level_only4IndexHNSWCagra_num_base_level_search_entrypoints_get4IndexHNSWCagra_num_base_level_search_entrypoints_set!num_base_level_search_entrypointsrH  r]  r  r   IndexHNSWCagra_numeric_type__get IndexHNSWCagra_numeric_type__setnumeric_type_delete_IndexHNSWCagrar   r>   r%   r$   r   rv  rv    s    -/IOdeGHWzLLjN{N{ B 	O )11p1pr|  sr  sr x )	%9Z@NZHH*JuJuvM!77r$   rv  c                 0    [         R                  " XX#5      $ )a6  
 SMAWK algorithm. Find the row minima of a monotone matrix.

Expose this for testing.

:type nrows: int
:param nrows:    number of rows
:type ncols: int
:param ncols:    number of columns
:type x: float
:param x:        input matrix, size (nrows, ncols)
:type argmins: int
:param argmins:  argmin of each row
)r   smawk)nrowsncolsrE   argminss       r   r  r    s     E!55r$   c                 0    [         R                  " XX#5      $ )u8  
 Exact 1D K-Means by dynamic programming

From  "Fast Exact k-Means, k-Medians and Bregman Divergence Clustering in 1D"
Allan Grønlund, Kasper Green Larsen, Alexander Mathiasen, Jesper Sindahl
Nielsen, Stefan Schneider, Mingzhou Song, ArXiV'17

Section 2.2

https://arxiv.org/abs/1701.07204

:type x: float
:param x:          input 1D array
:type n: int
:param n:          input array length
:type nclusters: int
:param nclusters:  number of clusters
:type centroids: float
:param centroids:  output centroids, size nclusters
:rtype: float
:return: imbalance factor
)r   kmeans1d)rE   ra   	nclustersr  s       r   r  r    s    . qY::r$   c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      rS rS r\R(                  rSrg	)
Neighbori  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Neighbor.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   Neighbor_swiginitnew_Neighborr   s     r   rV   Neighbor.__init__#  r  r$   c                 .    [         R                  " X5      $ r/   )r   Neighbor___lt__r   s     r   __lt__Neighbor.__lt__&  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   Neighbor_id_getNeighbor_id_setr<  Neighbor_distance_getNeighbor_distance_setrl   Neighbor_flag_getNeighbor_flag_setflagrV   r  delete_Neighborr   r>   r%   r$   r   r  r    sw    -/IOdeGH	*,,j.H.H	IB
88*:Z:Z[HJ00*2N2NODK7!11r$   r  c                      \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      r\" \R*                  \R,                  5      r\" \R0                  \R2                  5      rS rS r\R:                  rSrg	)
Nhoodi,  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Nhood.<lambda>-  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  -  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   Nhood_swiginit	new_Nhoodr   s     r   rV   Nhood.__init__6  s    !!$
(<(<d(CDr$   c                 0    [         R                  " XU5      $ r/   )r   Nhood_insert)r   r<  dists      r   r  Nhood.insert9  s    &&t66r$   r%   N) r   r   r:   r;   r   r   r   r   r   Nhood_pool_getNhood_pool_setr  Nhood_M_getNhood_M_setrX
  Nhood_nn_old_getNhood_nn_old_setnn_oldNhood_nn_new_getNhood_nn_new_setnn_newNhood_rnn_old_getNhood_rnn_old_setrnn_oldNhood_rnn_new_getNhood_rnn_new_setrnn_newrV   r  delete_Nhoodr   r>   r%   r$   r   r  r  ,  s    -/IOdeGHJ--z/H/HID'')?)?@Aj11:3N3NOFj11:3N3NOFz33Z5Q5QRGz33Z5Q5QRGE7!..r$   r  c                   8   \ rS rSr\" S S SS9r\rS r\	R                  rS rS rS	 rS
 rS rS rS rS rS r\" \	R*                  \	R,                  5      r\" \	R0                  \	R2                  5      r\" \	R6                  \	R8                  5      r\" \	R<                  \	R>                  5      r \" \	RB                  \	RD                  5      r#\" \	RH                  \	RJ                  5      r&\" \	RN                  \	RP                  5      r)\" \	RT                  \	RV                  5      r,\" \	RZ                  \	R\                  5      r/\" \	R`                  \	Rb                  5      r2\" \	Rf                  \	Rh                  5      r5\" \	Rl                  \	Rn                  5      r8Sr9g)	NNDescenti?  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   NNDescent.<lambda>@  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  @  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   NNDescent_swiginitnew_NNDescent)r   r  r  s      r   rV   NNDescent.__init__C  s    %%dJ,D,DQ,JKr$   c                 0    [         R                  " XX#5      $ r/   )r   NNDescent_build)r   r  ra   r  s       r   buildNNDescent.buildG  s    ))$aAAr$   c                 2    [         R                  " XX#XE5      $ r/   )r   NNDescent_search)r   r  topkindicesdistsr  s         r   r]  NNDescent.searchJ  s    **4tePPr$   c                 .    [         R                  " U 5      $ r/   )r   NNDescent_resetr[   s    r   r  NNDescent.resetM  r  r$   c                 .    [         R                  " X5      $ )z!Initialize the KNN graph randomly)r   NNDescent_init_graphr   r  s     r   
init_graphNNDescent.init_graphP  s    ..t::r$   c                 0    [         R                  " XU5      $ )zPerform NNDescent algorithm)r   NNDescent_nndescent)r   r  r  s      r   	nndescentNNDescent.nndescentT  s    --d'BBr$   c                 .    [         R                  " X5      $ )zPerform local join on each node)r   NNDescent_joinr  s     r   joinNNDescent.joinX  s    ((44r$   c                 .    [         R                  " U 5      $ )z>Sample new neighbors for each node to perform local join later)r   NNDescent_updater[   s    r   updateNNDescent.update\  s    **400r$   c                 2    [         R                  " XX#U5      $ )zESample a small number of points to evaluate the quality of KNNG built)r   NNDescent_generate_eval_set)r   r  r  rK   Ns        r   generate_eval_setNNDescent.generate_eval_set`  s    55d!JJr$   c                 0    [         R                  " XU5      $ )z"Evaluate the quality of KNNG built)r   NNDescent_eval_recall)r   ctrl_pointsacc_eval_sets      r   eval_recallNNDescent.eval_recalld  s    //<PPr$   r%   N):r   r   r:   r;   r   r   r   r   rV   r   delete_NNDescentr   r  r]  r  r  r  r  r  r  r  NNDescent_has_built_getNNDescent_has_built_set	has_builtNNDescent_S_getNNDescent_S_setSNNDescent_R_getNNDescent_R_setRNNDescent_iter_getNNDescent_iter_setiterNNDescent_search_L_getNNDescent_search_L_setsearch_LNNDescent_random_seed_getNNDescent_random_seed_setr  NNDescent_K_getNNDescent_K_setr  NNDescent_d_getNNDescent_d_setr  NNDescent_L_getNNDescent_L_setLNNDescent_ntotal_getNNDescent_ntotal_setr  NNDescent_graph_getNNDescent_graph_setgraphNNDescent_final_graph_getNNDescent_final_graph_setfinal_graphr>   r%   r$   r   r  r  ?  s~   -/IOdeGHL!22BQ0;C51KQ ;;Z=_=_`I++Z-G-GHA++Z-G-GHAJ11:3P3PQD
99:;\;\]H:??AeAefK++Z-G-GHA++Z-G-GHA++Z-G-GHAj55z7V7VWFZ33Z5S5STE:??AeAefKr$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      rS r\	R(                  rS	 rS
 rSS jrS rS rSrg)IndexNNDescentiv  zd
 The NNDescent index is a normal random-access index with an NNDescent
link structure built on top
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexNNDescent.<lambda>|  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r(  |  rL   r$   rM   rN   zFaiss results are 64-bitc                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexNNDescent_swiginitnew_IndexNNDescentr   s     r   rV   IndexNNDescent.__init__  r;  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexNNDescent_addr>  s      r   rH  IndexNNDescent.add  r{  r$   c                 0    [         R                  " XU5      $ r   )r   IndexNNDescent_trainr>  s      r   r?  IndexNNDescent.train      ..t::r$   Nc           	      4    [         R                  " XX#XEU5      $ r  )r   IndexNNDescent_searchr[  s          r   r]  IndexNNDescent.search  rY  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexNNDescent_reconstructrx  s      r   r{  IndexNNDescent.reconstruct  rH  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexNNDescent_resetr[   s    r   r  IndexNNDescent.reset  r]   r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   IndexNNDescent_nndescent_getIndexNNDescent_nndescent_setr  IndexNNDescent_own_fields_getIndexNNDescent_own_fields_setrR  IndexNNDescent_storage_getIndexNNDescent_storage_setr:  rV   delete_IndexNNDescentr   rH  r?  r]  r{  r  r>   r%   r$   r   r&  r&  v  s    
 -/IOdeGH@@*BiBi  pO  PI*BBJDlDlmJz<<j>c>cdGW!779;ZH5r$   r&  c                   N    \ rS rSrSr\" S S SS9r\rS r	\
R                  rSrg	)
IndexNNDescentFlati  zX
Flat index topped with with a NNDescent structure to access elements
more efficiently.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexNNDescentFlat.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rH    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexNNDescentFlat_swiginitnew_IndexNNDescentFlatr   s     r   rV   IndexNNDescentFlat.__init__  r  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r   delete_IndexNNDescentFlatr   r>   r%   r$   r   rF  rF    s1    
 -/IOdeGH_!;;r$   rF  c                   z    \ rS rSrSr\" S S SS9r\rSS jr	SS	 jr
S
 rS rS rS rS r\R"                  rSrg)IndexIVFFlati  z
 Inverted file with stored vectors. Here the inverted file
pre-selects the vectors to be searched, but they are not otherwise
encoded, the code array just contains the raw float entries.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFFlat.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rR    rL   r$   rM   rN   Nc                 2    [         R                  " XX#XE5      $ r/   )r   IndexIVFFlat_add_corer  s         r   r  IndexIVFFlat.add_core  s    ///iir$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexIVFFlat_encode_vectorsr  s         r   r  IndexIVFFlat.encode_vectors  s    55dqEccr$   c                 2    [         R                  " XX#U5      $ r/   )r   IndexIVFFlat_decode_vectorsr  s        r   r  IndexIVFFlat.decode_vectors  s    55duPQRRr$   c                 0    [         R                  " XX#5      $ r/   )r   $IndexIVFFlat_get_InvertedListScannerr	  s       r   r
  $IndexIVFFlat.get_InvertedListScanner  s    >>tRU^^r$   c                 0    [         R                  " XX#5      $ r/   )r   $IndexIVFFlat_reconstruct_from_offsetr"  s       r   r#  $IndexIVFFlat.reconstruct_from_offset  s    >>tf]]r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexIVFFlat_sa_decoder  s       r   r  IndexIVFFlat.sa_decode      00%CCr$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexIVFFlat_swiginitnew_IndexIVFFlatr   s     r   rV   IndexIVFFlat.__init__  rr  r$   r%   r/   rV  )r   r   r:   r;   r<   r   r   r   r   r  r  r  r
  r#  r  rV   r   delete_IndexIVFFlatr   r>   r%   r$   r   rP  rP    sU     -/IOdeGHjdS_^DS!55r$   rP  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9rS rS rSS
 jrS rSS jrS rS rS r\R(                  rSrg	)IndexIVFFlatDedupi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFFlatDedup.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   ro    rL   r$   rM   rN   z
    Maps ids stored in the index to the ids of vectors that are
    the same. When a vector is unique, it does not appear in the
    instances map
    c                 0    [         R                  " XU5      $ )zalso dedups the training set)r   IndexIVFFlatDedup_trainr>  s      r   r?  IndexIVFFlatDedup.train  r	  r$   c                 0    [         R                  " XX#5      $ )z%implemented for all IndexIVF* classes)r   IndexIVFFlatDedup_add_with_idsrP  s       r   rR  IndexIVFFlatDedup.add_with_ids  s    88!JJr$   Nc                 8    [         R                  " XX#XEXgXU
5      $ r/   )r   $IndexIVFFlatDedup_search_preassignedr  s              r   r  $IndexIVFFlatDedup.search_preassigned  s.    >>tfdm  xC  MR  S  	Sr$   c                 .    [         R                  " X5      $ r/   )r   IndexIVFFlatDedup_remove_idsrs  s     r   rt  IndexIVFFlatDedup.remove_ids  r  r$   c                 2    [         R                  " XX#XE5      $ r  )r   IndexIVFFlatDedup_range_searchrf  s         r   rg  IndexIVFFlatDedup.range_search  s    88!V\\r$   c                 0    [         R                  " XX#5      $ r  )r    IndexIVFFlatDedup_update_vectorsr  s       r   r   IndexIVFFlatDedup.update_vectors  s    ::4SLLr$   c                 0    [         R                  " XX#5      $ r  )r   )IndexIVFFlatDedup_reconstruct_from_offsetr"  s       r   r#  )IndexIVFFlatDedup.reconstruct_from_offset  s    CCDSYbbr$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexIVFFlatDedup_swiginitnew_IndexIVFFlatDedupr   s     r   rV   IndexIVFFlatDedup.__init__  r  r$   r%   r#  r/   )r   r   r:   r;   r   r   r   r   r   IndexIVFFlatDedup_instances_getIndexIVFFlatDedup_instances_set	instancesr?  rR  r  rt  rg  r  r#  rV   delete_IndexIVFFlatDedupr   r>   r%   r$   r   rm  rm    ss    -/IOdeGHCCZEoEo v 	I>KSB]Mc]!::r$   rm  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS rS	 r\	R&                  rS
rg)IndexIVFFlatPanoramai  a  
Panorama adaptation of IndexIVFFlat following
https://www.arxiv.org/pdf/2510.00566.

IDEA:
Panorama adapts the storage layout within each cluster and uses
pruning with bounds to improve the search performance.
Combined with orthogonal transforms upstream that concentrate the energy
in the early dimensions (like PCA, Cayley, etc.), Panorama can prune up
to 95% of the vectors in the cluster.

OVERHEAD:
To be more efficient, we compute the residual energies at insertion time
and store them along the vectors, which comes with an additional storage
overhead of exactly (nlevels + 1) floats per vector. Add time is also
slightly higher due to the overhead of transposing the vectors.

NOTE:
We inherit from IndexIVFFlat instead of IndexIVF so we can keep the same
insertion logic. The code responsible for level-oriented storage is in
`ArrayInvertedListsPanorama`, which is a struct member of `IndexIVF`.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFFlatPanorama.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 0    [         R                  " XX#5      $ r/   )r   ,IndexIVFFlatPanorama_get_InvertedListScannerr	  s       r   r
  ,IndexIVFFlatPanorama.get_InvertedListScanner  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   ,IndexIVFFlatPanorama_reconstruct_from_offsetr"  s       r   r#  ,IndexIVFFlatPanorama.reconstruct_from_offset  s    FFtV\eer$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexIVFFlatPanorama_swiginitnew_IndexIVFFlatPanoramar   s     r   rV   IndexIVFFlatPanorama.__init__  rJ  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   !IndexIVFFlatPanorama_n_levels_get!IndexIVFFlatPanorama_n_levels_setr  !IndexIVFFlatPanorama_cum_sums_get!IndexIVFFlatPanorama_cum_sums_setr  r
  r#  rV   delete_IndexIVFFlatPanoramar   r>   r%   r$   r   r  r    sm    . -/IOdeGH
DDjFrFrsH
DDjFrFrsHgfc!==r$   r  c                 .    [         R                  " U 5      $ r/   )r   storage_distance_computer)r:  s    r   r  r    s    //88r$   c                      \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9r\" \R                  \R                  SS9r\" \R                  \R                   SS9r\" \R$                  \R&                  S	S9r\" \R*                  \R,                  S
S9r\" \R0                  \R2                  SS9r\" \R6                  \R8                  SS9r\" \R<                  \R>                  SS9r \" \RB                  \RD                  SS9r#SS jr$S r%S r&S r'S r(S r)S r*S r+S r,S r-S r.S r/S r0\Rb                  r2Sr3g)NSGi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   NSG.<lambda>   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r     rL   r$   rM   rN   znb of nodesnb of neighbors per nodez.length of the search path at construction timez(candidate pool size at construction timezlength of the search path
enterpointzNSG graph structurezNSG is built or notzrandom generatorc                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   NSG_swiginitnew_NSG)r   r  s     r   rV   NSG.__init__,  s    j&8&8&;<r$   c                 2    [         R                  " XX#U5      $ r/   )r   	NSG_build)r   r:  ra   	knn_graphr  s        r   r  	NSG.build/  s    ##D1IIr$   c                 .    [         R                  " U 5      $ r/   )r   	NSG_resetr[   s    r   r  	NSG.reset2  s    ##D))r$   c                 2    [         R                  " XX#XE5      $ r/   )r   
NSG_search)r   rF  rQ  r
  r  r  s         r   r]  
NSG.search5  s    $$Ta<<r$   c                 0    [         R                  " XU5      $ r/   )r   NSG_init_graph)r   r:  r  s      r   r  NSG.init_graph8  s    ((	BBr$   c                 2    [         R                  " XX#U5      $ r/   )r   NSG_add_reverse_links)r   qrt  rF  r!  s        r   add_reverse_linksNSG.add_reverse_links;  s    //UKKr$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   NSG_sync_prune)r   r  r  rF  r  r  r!  s          r   
sync_pruneNSG.sync_prune>  s    (($RERRr$   c                 2    [         R                  " XX#U5      $ r/   )r   NSG_link)r   r:  r  r!  r  s        r   linkNSG.linkA  s    ""4)GLLr$   c                 0    [         R                  " XU5      $ r/   )r   NSG_tree_grow)r   r:  degreess      r   	tree_growNSG.tree_growD  s    ''w??r$   c                 0    [         R                  " XX#5      $ r/   )r   NSG_dfs)r   r  rootcnts       r   dfsNSG.dfsG  s    !!$D66r$   c                 2    [         R                  " XX#U5      $ r/   )r   NSG_attach_unlinked)r   r:  r  vt2r  s        r   attach_unlinkedNSG.attach_unlinkedJ  s    --dRgNNr$   c                 .    [         R                  " U 5      $ r/   )r   NSG_check_graphr[   s    r   check_graphNSG.check_graphM  r  r$   c                 .    [         R                  " U 5      $ r/   )r   NSG_get_final_graphr[   s    r   get_final_graphNSG.get_final_graphP  rw   r$   r%   Nr  )4r   r   r:   r;   r   r   r   r   r   NSG_ntotal_getNSG_ntotal_setr  	NSG_R_get	NSG_R_setr  	NSG_L_get	NSG_L_setr  	NSG_C_get	NSG_C_setCNSG_search_L_getNSG_search_L_setr  NSG_enterpoint_getNSG_enterpoint_setr  NSG_final_graph_getNSG_final_graph_setr$  NSG_is_built_getNSG_is_built_setis_builtNSG_rng_getNSG_rng_setr  rV   r  r  r]  r  r  r  r  r  r  r  r  r  
delete_NSGr   r>   r%   r$   r   r  r    s_   -/IOdeGHj//1J1JPbcF%%z';';A`aA%%z';';AvwA%%z';';ApqA
33Z5P5PVvwH*779V9V\mnJ:99:;Y;Y_yzK
33Z5P5PVpqH
:)):+A+AG^
_C=J*=CLSM@7O04!,,r$   r  c                   6   \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9r\" \R                  \R                  SS9r\" \R                  \R                   SS9r\" \R$                  \R&                  S	S9rS
 r\R,                  rS rS rSrg)NSG_Graph_intiV  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   NSG_Graph_int.<lambda>W  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  W  rL   r$   rM   rN   z+the flattened adjacency matrix, size N-by-Kr  ztotal nb of nodesz*the underlying data owned by itself or notc                 T    [         R                  " U [         R                  " U6 5        g r/   )r   NSG_Graph_int_swiginitnew_NSG_Graph_intr   s     r   rV   NSG_Graph_int.__init__^  rJ  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   NSG_Graph_int_atr   s     r   r   NSG_Graph_int.atb  r  r$   c                 0    [         R                  " XU5      $ r/   )r   NSG_Graph_int_get_neighbors)r   r+  r  s      r   get_neighborsNSG_Graph_int.get_neighborse  s    55dyIIr$   r%   N)r   r   r:   r;   r   r   r   r   r   NSG_Graph_int_data_getNSG_Graph_int_data_setr   NSG_Graph_int_K_getNSG_Graph_int_K_setr  NSG_Graph_int_N_getNSG_Graph_int_N_setr  NSG_Graph_int_own_fields_getNSG_Graph_int_own_fields_setrR  rV   delete_NSG_Graph_intr   r   r  r>   r%   r$   r   r  r  V  s    -/IOdeGHJ55z7X7X  _Q  RD//1O1OUtuA//1O1OUmnA*AA:CjCj  qb  cJU!668Jr$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  S	S9r\" \	R,                  \	R.                  S
S9r\" \	R2                  \	R4                  SS9r\" \	R8                  \	R:                  SS9r\" \	R>                  \	R@                  5      r!\" \	RD                  \	RF                  5      r$\" \	RJ                  \	RL                  5      r'S r(\	RR                  r*S r+S r,S r-SS jr.S r/S r0S r1Sr2g)IndexNSGij  zW
 The NSG index is a normal random-access index with a NSG
link structure built on top
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexNSG.<lambda>p  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  p  rL   r$   rM   rN   zthe link structurezthe sequential storagezthe index is built or notzK of KNN graph for buildingzx
    indicate how to build a knn graph
    - 0: build NSG with brute force search
    - 1: build NSG with NNDescent
    zparameters for nndescentc                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexNSG_swiginitnew_IndexNSGr   s     r   rV   IndexNSG.__init__  r  r$   c                 2    [         R                  " XX#U5      $ r/   )r   IndexNSG_build)r   ra   rE   r  GKs        r   r  IndexNSG.build  s    ((!CCr$   c                 0    [         R                  " XU5      $ r/   )r   IndexNSG_addr>  s      r   rH  IndexNSG.add  s    &&t22r$   c                 0    [         R                  " XU5      $ r   )r   IndexNSG_trainr>  s      r   r?  IndexNSG.train  r  r$   Nc           	      4    [         R                  " XX#XEU5      $ r  )r   IndexNSG_searchr[  s          r   r]  IndexNSG.search  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexNSG_reconstructrx  s      r   r{  IndexNSG.reconstruct  s    ..t&AAr$   c                 .    [         R                  " U 5      $ r/   )r   IndexNSG_resetr[   s    r   r  IndexNSG.reset  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexNSG_check_knn_graph)r   r  ra   r  s       r   check_knn_graphIndexNSG.check_knn_graph  s    224AIIr$   r%   r/   )3r   r   r:   r;   r<   r   r   r   r   r   IndexNSG_nsg_getIndexNSG_nsg_setnsgIndexNSG_own_fields_getIndexNSG_own_fields_setrR  IndexNSG_storage_getIndexNSG_storage_setr:  IndexNSG_is_built_getIndexNSG_is_built_setr  IndexNSG_GK_getIndexNSG_GK_setr  IndexNSG_build_type_getIndexNSG_build_type_set
build_typeIndexNSG_nndescent_S_getIndexNSG_nndescent_S_setnndescent_SIndexNSG_nndescent_R_getIndexNSG_nndescent_R_setnndescent_RIndexNSG_nndescent_L_getIndexNSG_nndescent_L_setnndescent_LIndexNSG_nndescent_iter_getIndexNSG_nndescent_iter_setnndescent_iterrV   delete_IndexNSGr   r  rH  r?  r]  r{  r  r-  r>   r%   r$   r   r  r  j  sv   
 -/IOdeGH
:..
0K0KQj
kC*<<j>`>`  gD  EJz66
8W8WXG
88*:Z:Z  aA  BH	*,,j.H.HNp	qB*<<j>`>` g 	J
 :>>
@c@c  jI  JK:>>
@c@cdK:>>
@c@cdKjDDjFlFlmNK!11D35TB/Jr$   r  c                   N    \ rS rSrSr\" S S SS9r\rS r	\
R                  rSrg	)
IndexNSGFlati  zR
Flat index topped with with a NSG structure to access elements
more efficiently.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexNSGFlat.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rM    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexNSGFlat_swiginitnew_IndexNSGFlatr   s     r   rV   IndexNSGFlat.__init__  rr  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r   delete_IndexNSGFlatr   r>   r%   r$   r   rK  rK    s1    
 -/IOdeGHS!55r$   rK  c                   T    \ rS rSrSr\" S S SS9r\rS r	S r
\R                  rS	rg
)
IndexNSGPQi  zP
PQ index topped with with a NSG structure to access elements
more efficiently.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexNSGPQ.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rW    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexNSGPQ_swiginitnew_IndexNSGPQr   s     r   rV   IndexNSGPQ.__init__  rz	  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexNSGPQ_trainr>  s      r   r?  IndexNSGPQ.train      **4A66r$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r?  r   delete_IndexNSGPQr   r>   r%   r$   r   rU  rU    s6    
 -/IOdeGHO7!33r$   rU  c                   N    \ rS rSrSr\" S S SS9r\rS r	\
R                  rSrg	)

IndexNSGSQi  zP
SQ index topped with with a NSG structure to access elements
more efficiently.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexNSGSQ.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   re    rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexNSGSQ_swiginitnew_IndexNSGSQr   s     r   rV   IndexNSGSQ.__init__  rz	  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r   delete_IndexNSGSQr   r>   r%   r$   r   rc  rc    s1    
 -/IOdeGHO!33r$   rc  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      rS r\R&                  rSrg)	OnDiskOneListi  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   OnDiskOneList.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   ro    rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   OnDiskOneList_swiginitnew_OnDiskOneListr[   s    r   rV   OnDiskOneList.__init__  r   r$   r%   N)r   r   r:   r;   r   r   r   r   r   OnDiskOneList_size_getOnDiskOneList_size_setr   OnDiskOneList_capacity_getOnDiskOneList_capacity_setcapacityOnDiskOneList_offset_getOnDiskOneList_offset_setr
  rV   delete_OnDiskOneListr   r>   r%   r$   r   rm  rm    sr    -/IOdeGHJ55z7X7XYD
==z?d?deHj99:;^;^_FP!66r$   rm  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      r\" \	R,                  \	R.                  5      r\" \	R2                  \	R4                  5      rS rS rS	 rS
 rS r S r!SS jr"SS jr#S r$S r%\	RL                  r'\" \	RP                  \	RR                  5      r*\" \	RV                  \	RX                  5      r-\" \	R\                  \	R^                  5      r0S r1S r2S r3S r4S r5S r6S r7Sr8g)OnDiskInvertedListsi  a  
 On-disk storage of inverted lists.

The data is stored in a mmapped chunk of memory (base pointer ptr,
size totsize). Each list is a range of memory that contains (object
List) that contains:

- uint8_t codes[capacity * code_size]
- followed by idx_t ids[capacity]

in each of the arrays, the size <= capacity first elements are
used, the rest is not initialized.

Addition and resize are supported by:
- roundind up the capacity of the lists to a power of two
- maintaining a list of empty slots, sorted by size.
- resizing the mmapped block is adjusted as needed.

An OnDiskInvertedLists is compact if the size == capacity for all
lists and there are no available slots.

Addition to the invlists is slow. For incremental add it is better
to use a default ArrayInvertedLists object and convert it to an
OnDisk with merge_from.

When it is known that a set of lists will be accessed, it is useful
to call prefetch_lists, that launches a set of threads to read the
lists in parallel.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   OnDiskInvertedLists.<lambda>  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r    rL   r$   rM   rN   c                 .    [         R                  " X5      $ r/   )r   OnDiskInvertedLists_list_sizer   s     r   r  OnDiskInvertedLists.list_size   r  r$   c                 .    [         R                  " X5      $ r/   )r   OnDiskInvertedLists_get_codesr   s     r   r  OnDiskInvertedLists.get_codes   r  r$   c                 .    [         R                  " X5      $ r/   )r   OnDiskInvertedLists_get_idsr   s     r   r
  OnDiskInvertedLists.get_ids	   r  r$   c                 2    [         R                  " XX#U5      $ r/   )r   OnDiskInvertedLists_add_entriesr7  s        r   r8  OnDiskInvertedLists.add_entries   s    99$W[\\r$   c                 2    [         R                  " XX#XE5      $ r/   )r   "OnDiskInvertedLists_update_entriesrA  s         r   rB  "OnDiskInvertedLists.update_entries   s    <<TF]`ggr$   c                 0    [         R                  " XU5      $ r/   )r   OnDiskInvertedLists_resizerF  s      r   r   OnDiskInvertedLists.resize   s    44THMMr$   c                 2    [         R                  " XX#U5      $ r/   )r   'OnDiskInvertedLists_merge_from_multiple)r   r  n_ilr  r  s        r   merge_from_multiple'OnDiskInvertedLists.merge_from_multiple   s    AA$T^effr$   c                 0    [         R                  " XU5      $ )z'same as merge_from for a single invlist)r    OnDiskInvertedLists_merge_from_1)r   r  r  s      r   merge_from_1 OnDiskInvertedLists.merge_from_1   s    ::4WMMr$   c                 0    [         R                  " XU5      $ )zHrestrict the inverted lists to l0:l1 without touching the mmapped region)r   !OnDiskInvertedLists_crop_invlists)r   l0l1s      r   crop_invlists!OnDiskInvertedLists.crop_invlists   s    ;;DbIIr$   c                 0    [         R                  " XU5      $ r/   )r   "OnDiskInvertedLists_prefetch_listsr!  s      r   r$  "OnDiskInvertedLists.prefetch_lists    r  r$   c                 .    [         R                  " U 5      $ r/   )r   OnDiskInvertedLists_do_mmapr[   s    r   do_mmapOnDiskInvertedLists.do_mmap'   r  r$   c                 .    [         R                  " X5      $ r/   )r   "OnDiskInvertedLists_update_totsize)r   new_totsizes     r   update_totsize"OnDiskInvertedLists.update_totsize*   s    <<TOOr$   c                 0    [         R                  " XU5      $ r/   )r   !OnDiskInvertedLists_resize_lockedrF  s      r   resize_locked!OnDiskInvertedLists.resize_locked-   r  r$   c                 .    [         R                  " X5      $ r/   )r   !OnDiskInvertedLists_allocate_slot)r   ry  s     r   allocate_slot!OnDiskInvertedLists.allocate_slot0   s    ;;DKKr$   c                 0    [         R                  " XU5      $ r/   )r   OnDiskInvertedLists_free_slot)r   r
  ry  s      r   	free_slotOnDiskInvertedLists.free_slot3   s    77hOOr$   c                 .    [         R                  " X5      $ )z1override all list sizes and make a packed storage)r   'OnDiskInvertedLists_set_all_lists_sizes)r   r  s     r   set_all_lists_sizes'OnDiskInvertedLists.set_all_lists_sizes6   s    AA$NNr$   c                 T    [         R                  " U [         R                  " U6 5        g)z#are inverted lists mapped read-onlyN)r   OnDiskInvertedLists_swiginitnew_OnDiskInvertedListsr   s     r   rV   OnDiskInvertedLists.__init__:   s    //j6X6XZ^6_`r$   r%   N)FFrV  )9r   r   r:   r;   r<   r   r   r   r   r   OnDiskInvertedLists_lists_getOnDiskInvertedLists_lists_setlistsOnDiskInvertedLists_slots_getOnDiskInvertedLists_slots_setslots OnDiskInvertedLists_filename_get OnDiskInvertedLists_filename_setfilenameOnDiskInvertedLists_totsize_getOnDiskInvertedLists_totsize_settotsizeOnDiskInvertedLists_ptr_getOnDiskInvertedLists_ptr_setr+  !OnDiskInvertedLists_read_only_get!OnDiskInvertedLists_read_only_set	read_onlyr  r  r
  r8  rB  r   r  r  r  r$  delete_OnDiskInvertedListsr   OnDiskInvertedLists_locks_getOnDiskInvertedLists_locks_setrt  OnDiskInvertedLists_pf_getOnDiskInvertedLists_pf_setpf(OnDiskInvertedLists_prefetch_nthread_get(OnDiskInvertedLists_prefetch_nthread_setprefetch_nthreadr  r  r  r  r  r  rV   r>   r%   r$   r   r~  r~    su   < -/IOdeGHZ==z?g?ghEZ==z?g?ghE
CCZEpEpqHzAA:CmCmnG
:99:;a;a
bCEEzGsGstIGGE]hNgNJT!<<Z==z?g?ghE	*779^9^	_B
 S SU_  VI  VI  J<PULPOar$   r~  c                   @   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  SS9rS rS	 rS
 r\	R2                  rSrg)ZnSphereSearchi@   a  
 returns the nearest vertex in the sphere to a query. Returns only
the coordinates, not an id.

Algorithm: all points are derived from a one atom vector up to a
permutation and sign changes. The search function finds the most
appropriate atom and transformation.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ZnSphereSearch.<lambda>J   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  J   rL   r$   rM   rN   zsize dim * natomc                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   ZnSphereSearch_swiginitnew_ZnSphereSearchr   r	  r  s      r   rV   ZnSphereSearch.__init__Q   s    **41N1Ns1WXr$   c                 0    [         R                  " U /UQ76 $ )z
*Overload 1:*
find nearest centroid. x does not need to be normalized

|

*Overload 2:*
full call. Requires externally-allocated temp space

|

*Overload 3:*
full call. Requires externally-allocated temp space
)r   ZnSphereSearch_searchr   s     r   r]  ZnSphereSearch.searchT   s     //<t<<r$   c                 2    [         R                  " XX#U5      $ r/   )r   ZnSphereSearch_search_multi)r   ra   rE   c_outdp_outs        r   search_multiZnSphereSearch.search_multie   s    55dqPPr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   ZnSphereSearch_dimS_getZnSphereSearch_dimS_setdimSZnSphereSearch_r2_getZnSphereSearch_r2_setr  ZnSphereSearch_natom_getZnSphereSearch_natom_setnatomZnSphereSearch_voc_getZnSphereSearch_voc_setvocrV   r]  r  delete_ZnSphereSearchr   r>   r%   r$   r   r  r  @   s     -/IOdeGHJ66
8Z8Z[D	*22J4T4T	UBZ88*:]:]^E
:44j6W6W]t
uCY="Q!77r$   r  c                       \ rS rSr\" S S SS9rS r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  5      rS rS	 rS
 rS rS r\	R*                  rSrg)EnumeratedVectorsik   c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   EnumeratedVectors.<lambda>l   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  l   rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   EnumeratedVectors.__init__n   rX   r$   zsize of the collectionc                 .    [         R                  " X5      $ )z!encode a vector from a collection)r   EnumeratedVectors_encoderk   s     r   r
  EnumeratedVectors.encodet   s    224;;r$   c                 0    [         R                  " XU5      $ )z	decode it)r   EnumeratedVectors_decoder   r  r  s      r   r	  EnumeratedVectors.decodex   s    224qAAr$   c                 0    [         R                  " XX#5      $ r/   )r   EnumeratedVectors_encode_multi)r   ncr  r  s       r   encode_multiEnumeratedVectors.encode_multi|   s    881LLr$   c                 0    [         R                  " XX#5      $ r/   )r   EnumeratedVectors_decode_multi)r   r  r  r  s       r   decode_multiEnumeratedVectors.decode_multi   s    885LLr$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   EnumeratedVectors_find_nn)r   ra   r  r  r]  rc  rF  s          r   find_nnEnumeratedVectors.find_nn   s    33DUQTUUr$   r%   N)r   r   r:   r;   r   r   rV   r   r   r   EnumeratedVectors_nv_getEnumeratedVectors_nv_setr  EnumeratedVectors_dim_getEnumeratedVectors_dim_setr	  r
  r	  r  r  r  delete_EnumeratedVectorsr   r>   r%   r$   r   r  r  k   sz    -/IOdeGKH	*55z7Z7Z`}	~B
:779]9]
^C<BMMV!::r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS r\R                   rSrg)	Repeati   c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Repeat.<lambda>   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r     rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Repeat_swiginit
new_Repeatr[   s    r   rV   Repeat.__init__       ""4)>)>)@Ar$   r%   N)r   r   r:   r;   r   r   r   r   r   Repeat_val_getRepeat_val_setvalRepeat_n_getRepeat_n_setra   rV   delete_Repeatr   r>   r%   r$   r   r  r     sZ    -/IOdeGH
:,,j.G.G
HC((**A*ABAB!//r$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rSS jrS	 rS
 rS r\	R(                  rSrg)Repeatsi   z
Repeats: used to encode a vector that has n occurrences of
val. Encodes the signs and permutation of the vector. Useful for
atoms.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Repeats.<lambda>   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r/     rL   r$   rM   rN   Nc                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   Repeats_swiginitnew_Repeats)r   r	  r  s      r   rV   Repeats.__init__   s    ##D**@*@*HIr$   c                 .    [         R                  " U 5      $ r/   )r   Repeats_countr[   s    r   countRepeats.count   s    ''--r$   c                 .    [         R                  " X5      $ r/   )r   Repeats_encoder  s     r   r
  Repeats.encode   r=  r$   c                 0    [         R                  " XU5      $ r/   )r   Repeats_decoder  s      r   r	  Repeats.decode   s    ((Q77r$   r%   r   N)r   r   r:   r;   r<   r   r   r   r   r   Repeats_dim_getRepeats_dim_setr	  Repeats_repeats_getRepeats_repeats_setrepeatsrV   r7  r
  r	  delete_Repeatsr   r>   r%   r$   r   r-  r-     sp     -/IOdeGH
:--z/I/I
JCz55z7U7UVGJ.28!00r$   r-  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      rS rS rS	 rS
 r\	R.                  rSrg)ZnSphereCodeci   z
 codec that can return ids for the encoded vectors

uses the ZnSphereSearch to encode the vector by encoding the
permutation and signs. Depends on ZnSphereSearch because it uses
the atom numbers
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ZnSphereCodec.<lambda>   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rI     rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   ZnSphereCodec_swiginitnew_ZnSphereCodecr  s      r   rV   ZnSphereCodec.__init__   s    ))$
0L0LS0UVr$   c                 .    [         R                  " X5      $ r/   )r   ZnSphereCodec_search_and_encoderk   s     r   search_and_encodeZnSphereCodec.search_and_encode   s    99$BBr$   c                 0    [         R                  " XU5      $ r/   )r   ZnSphereCodec_decoder  s      r   r	  ZnSphereCodec.decode   s    ..t1==r$   c                 .    [         R                  " X5      $ )z.takes vectors that do not need to be centroids)r   ZnSphereCodec_encoderk   s     r   r
  ZnSphereCodec.encode       ..t77r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   ZnSphereCodec_code_segments_getZnSphereCodec_code_segments_setcode_segmentsZnSphereCodec_nv_getZnSphereCodec_nv_setr  ZnSphereCodec_code_size_getZnSphereCodec_code_size_setr  rV   rQ  r	  r
  delete_ZnSphereCodecr   r>   r%   r$   r   rG  rG     s     -/IOdeGHZGGIsIstM	*11:3R3R	SB??AgAghIWC>8 "66r$   rG  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      rS rS rS	 rS
 r\" \	R.                  \	R0                  5      r\" \	R4                  \	R6                  5      r\" \	R:                  \	R<                  5      r\" \	R@                  \	RB                  5      r"S r#S r$S r%\	RL                  r'Sr(g)ZnSphereCodecReci   z
 recursive sphere codec

Uses a recursive decomposition on the dimensions to encode
centroids found by the ZnSphereSearch. The codes are *not*
compatible with the ones of ZnSphereCodec
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ZnSphereCodecRec.<lambda>   rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   re     rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   ZnSphereCodecRec_swiginitnew_ZnSphereCodecRecr  s      r   rV   ZnSphereCodecRec.__init__       ,,T:3R3RSV3[\r$   c                 .    [         R                  " X5      $ r/   )r    ZnSphereCodecRec_encode_centroidr  s     r   encode_centroid ZnSphereCodecRec.encode_centroid   r  r$   c                 0    [         R                  " XU5      $ r/   )r   ZnSphereCodecRec_decoder  s      r   r	  ZnSphereCodecRec.decode       11$a@@r$   c                 .    [         R                  " X5      $ )zC
vectors need to be centroids (does not work on arbitrary
vectors)
)r   ZnSphereCodecRec_encoderk   s     r   r
  ZnSphereCodecRec.encode   s    
 11$::r$   c                 0    [         R                  " XU5      $ r/   )r   ZnSphereCodecRec_get_nv)r   ldr2as      r   get_nvZnSphereCodecRec.get_nv   s    11$C@@r$   c                 0    [         R                  " XX#5      $ r/   )r   ZnSphereCodecRec_get_nv_cum)r   ry  r2trz  s       r   
get_nv_cumZnSphereCodecRec.get_nv_cum   s    55dIIr$   c                 2    [         R                  " XX#U5      $ r/   )r   ZnSphereCodecRec_set_nv_cum)r   ry  r  rz  rK   s        r   
set_nv_cumZnSphereCodecRec.set_nv_cum   s    55d!LLr$   r%   N))r   r   r:   r;   r<   r   r   r   r   r   ZnSphereCodecRec_r2_getZnSphereCodecRec_r2_setr  ZnSphereCodecRec_log2_dim_getZnSphereCodecRec_log2_dim_setlog2_dimZnSphereCodecRec_code_size_getZnSphereCodecRec_code_size_setr  rV   rn  r	  r
  ZnSphereCodecRec_all_nv_getZnSphereCodecRec_all_nv_setall_nvZnSphereCodecRec_all_nv_cum_getZnSphereCodecRec_all_nv_cum_set
all_nv_cum$ZnSphereCodecRec_decode_cache_ld_get$ZnSphereCodecRec_decode_cache_ld_setdecode_cache_ld!ZnSphereCodecRec_decode_cache_get!ZnSphereCodecRec_decode_cache_setdecode_cacher{  r  r  delete_ZnSphereCodecRecr   r>   r%   r$   r   rc  rc     s    -/IOdeGH	*44j6X6X	YB
@@*BjBjkHBBJDmDmnI]DA; j<<j>d>deF*DDjFpFpqJzNNPZPP  AOJHH*JvJvwLAJM!99r$   rc  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS rS	 r\	R&                  rS
rg)ZnSphereCodecAlti   z[
 Codec that uses the recursive codec if dim is a power of 2 and
the regular one otherwise
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ZnSphereCodecAlt.<lambda>!  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  !  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   ZnSphereCodecAlt_swiginitnew_ZnSphereCodecAltr  s      r   rV   ZnSphereCodecAlt.__init__!  rk  r$   c                 .    [         R                  " X5      $ r/   )r   ZnSphereCodecAlt_encoderk   s     r   r
  ZnSphereCodecAlt.encode!  rn   r$   c                 0    [         R                  " XU5      $ r/   )r   ZnSphereCodecAlt_decoder  s      r   r	  ZnSphereCodecAlt.decode!  rs  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   ZnSphereCodecAlt_use_rec_getZnSphereCodecAlt_use_rec_setuse_recZnSphereCodecAlt_znc_rec_getZnSphereCodecAlt_znc_rec_setznc_recrV   r
  r	  delete_ZnSphereCodecAltr   r>   r%   r$   r   r  r     sl    
 -/IOdeGHz>>
@g@ghGz>>
@g@ghG];A!99r$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  5      r\" \	R2                  \	R4                  SS9rS rS rS rS rS r \	RB                  r"Sr#g)IndexLatticei!  zBIndex that encodes a vector with a series of Zn lattice quantizersc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexLattice.<lambda>!  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  !  rL   r$   rM   rN   znumber of sub-vectorszdimension of sub-vectorszthe lattice quantizerz/nb bits used to encode the scale, per subvectorz4mins and maxes of the vector norms, per subquantizerc           	      \    [         R                  " U [         R                  " XX45      5        g r/   )r   IndexLattice_swiginitnew_IndexLattice)r   r  nsq
scale_nbitr  s        r   rV   IndexLattice.__init__ !  s     ((z/J/J1S]/bcr$   c                 0    [         R                  " XU5      $ r/   )r   IndexLattice_trainr>  s      r   r?  IndexLattice.train#!  r{  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexLattice_sa_code_sizer[   s    r   r  IndexLattice.sa_code_size&!  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexLattice_sa_encoder  s       r   r  IndexLattice.sa_encode)!  s    00!CCr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexLattice_sa_decoder  s       r   r  IndexLattice.sa_decode,!  rf  r$   r%   N)$r   r   r:   r;   r<   r   r   r   r   r   IndexLattice_nsq_getIndexLattice_nsq_setr  IndexLattice_dsq_getIndexLattice_dsq_setdsq IndexLattice_zn_sphere_codec_get IndexLattice_zn_sphere_codec_setzn_sphere_codecIndexLattice_scale_nbit_getIndexLattice_scale_nbit_setr  IndexLattice_lattice_nbit_getIndexLattice_lattice_nbit_setlattice_nbitIndexLattice_trained_getIndexLattice_trained_setrf  rV   r?  r  r  r  delete_IndexLatticer   r>   r%   r$   r   r  r  !  s    M-/IOdeGH
:22J4S4SYu
vC
:22J4S4SYx
yCzJJJLwLw  ~Z  [O*@@*BhBh  oe  fJJDDjFnFnoLz::J<_<_  fa  bGd9:DD!55r$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9r\" \R                  \R                  SS9rS r\R                   rS	rg
)IVFPQSearchParametersi2!  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IVFPQSearchParameters.<lambda>3!  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  3!  rL   r$   rM   rN   $use table computation or on-the-fly?'Hamming thresh for polysemous filteringc                 X    [         R                  " U [         R                  " 5       5        g r/   )r   IVFPQSearchParameters_swiginitnew_IVFPQSearchParametersr[   s    r   rV   IVFPQSearchParameters.__init__8!  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   .IVFPQSearchParameters_scan_table_threshold_get.IVFPQSearchParameters_scan_table_threshold_setscan_table_threshold'IVFPQSearchParameters_polysemous_ht_get'IVFPQSearchParameters_polysemous_ht_setr  rV   delete_IVFPQSearchParametersr   r>   r%   r$   r   r  r  2!  s    -/IOdeGH#J$]$]_i  `Y  `Y  _J  KZOOQ[  RD  RD  Jx  yM`!>>r$   r  c                   :   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9r\" \	R2                  \	R4                  SS9r\" \	R8                  \	R:                  SS9rSS jrS r S r!S S jr"S!S jr#S r$S r%S r&S r'S r(SS jr)S r*S r+S r,S r-\	R\                  r/Sr0g)"
IndexIVFPQi>!  zn
 Inverted file with Product Quantizer encoding. Each residual
vector is encoded as a product quantizer code.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFPQ.<lambda>D!  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  D!  rL   r$   rM   rN   produces the codesz$reorder PQ centroids after training?zif NULL, use defaultr  r  z
     Precompute table that speed up query preprocessing at some
    memory cost (used only for by_residual with L2 metric)
    zA
    if use_precompute_table
    size nlist * pq.M * pq.ksub
    c                 2    [         R                  " XX#XE5      $ r/   )r   IndexIVFPQ_encode_vectorsr  s         r   r  IndexIVFPQ.encode_vectorsT!  s    33DQ%aar$   c                 2    [         R                  " XX#U5      $ r/   )r   IndexIVFPQ_decode_vectors)r   ra   r  listnosrE   s        r   r  IndexIVFPQ.decode_vectorsW!  s    33DUQOOr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexIVFPQ_sa_decoder  s       r   r  IndexIVFPQ.sa_decodeZ!  s    ..tAAr$   Nc                 2    [         R                  " XX#XE5      $ r/   )r   IndexIVFPQ_add_corer  s         r   r  IndexIVFPQ.add_core]!  s    --dqggr$   c           	      4    [         R                  " XX#XEU5      $ )zq
same as add_core, also:
- output 2nd level residuals if residuals_2 != NULL
- accepts precomputed_idx = nullptr
)r   IndexIVFPQ_add_core_o)r   ra   rE   rQ  residuals_2r  r)  s          r   
add_core_oIndexIVFPQ.add_core_o`!  s     //+`uvvr$   c                 0    [         R                  " XX#5      $ )ztrains the product quantizer)r   IndexIVFPQ_train_encoderr  s       r   r  IndexIVFPQ.train_encoderh!  s    224AFFr$   c                 .    [         R                  " U 5      $ r/   )r   $IndexIVFPQ_train_encoder_num_vectorsr[   s    r   r  $IndexIVFPQ.train_encoder_num_vectorsl!  r+  r$   c                 0    [         R                  " XX#5      $ r/   )r   "IndexIVFPQ_reconstruct_from_offsetr"  s       r   r#  "IndexIVFPQ.reconstruct_from_offseto!  s    <<TF[[r$   c                 0    [         R                  " XU5      $ )a  
 Find exact duplicates in the dataset.

the duplicates are returned in pre-allocated arrays (see the
max sizes).

:type lims: int
:param lims:   limits between groups of duplicates
                   (max size ntotal / 2 + 1)
:type ids: int
:param ids:    ids[lims[i]] : ids[lims[i+1]-1] is a group of
                   duplicates (max size ntotal)
:rtype: int
:return: n      number of groups found
)r   IndexIVFPQ_find_duplicates)r   r  r  s      r   find_duplicatesIndexIVFPQ.find_duplicatesr!  s      44TEEr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexIVFPQ_encode)r   ry  rE   r  s       r   r
  IndexIVFPQ.encode!  s    ++Dq??r$   c                 2    [         R                  " XX#XE5      $ )a  
 Encode multiple vectors

:type n: int
:param n:       nb vectors to encode
:type keys: int
:param keys:    posting list ids for those vectors (size n)
:type x: float
:param x:       vectors (size n * d)
:type codes: uint8_t
:param codes:   output codes (size n * code_size)
:type compute_keys: boolean, optional
:param compute_keys:  if false, assume keys are precomputed,
                         otherwise compute them
)r   IndexIVFPQ_encode_multiple)r   ra   r  rE   r  compute_keyss         r   encode_multipleIndexIVFPQ.encode_multiple!  s      44Tdu[[r$   c                 2    [         R                  " XX#U5      $ )zinverse of encode_multiple)r   IndexIVFPQ_decode_multiple)r   ra   r  xcodesrE   s        r   decode_multipleIndexIVFPQ.decode_multiple!  s    44TdANNr$   c                 0    [         R                  " XX#5      $ r/   )r   "IndexIVFPQ_get_InvertedListScannerr	  s       r   r
  "IndexIVFPQ.get_InvertedListScanner!  s    <<TPS\\r$   c                 .    [         R                  " U 5      $ )zbuild precomputed table)r   IndexIVFPQ_precompute_tabler[   s    r   precompute_tableIndexIVFPQ.precompute_table!      55d;;r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexIVFPQ_swiginitnew_IndexIVFPQr   s     r   rV   IndexIVFPQ.__init__!  rz	  r$   r%   rV  r/   r#  )1r   r   r:   r;   r<   r   r   r   r   r   IndexIVFPQ_pq_getIndexIVFPQ_pq_setr  %IndexIVFPQ_do_polysemous_training_get%IndexIVFPQ_do_polysemous_training_setr  "IndexIVFPQ_polysemous_training_get"IndexIVFPQ_polysemous_training_setr  #IndexIVFPQ_scan_table_threshold_get#IndexIVFPQ_scan_table_threshold_setr  IndexIVFPQ_polysemous_ht_getIndexIVFPQ_polysemous_ht_setr  $IndexIVFPQ_use_precomputed_table_get$IndexIVFPQ_use_precomputed_table_setr   IndexIVFPQ_precomputed_table_get IndexIVFPQ_precomputed_table_setprecomputed_tabler  r  r  r  r  r  r  r#  r  r
  r  r  r
  r  rV   delete_IndexIVFPQr   r>   r%   r$   r   r  r  >!  s   
 -/IOdeGH	*..
0L0LRk	lB%j&V&VXb  YI  YI  Oz  {":#P#PR\RR  Fa  b#J$R$RT^  UC  UC  It  uZDDjFmFm  tb  cM$Z%T%TV`  WF  WF L 	 !!L!LjNyNy @ 	
bPBhwGE\F$@\$O]<O!33r$   r  c                 2    [         R                  " XX#XE5      $ )aD  
 Pre-compute distance tables for IVFPQ with by-residual and METRIC_L2

:type use_precomputed_table: int
:param use_precomputed_table: (I/O)
           =-1: force disable
           =0: decide heuristically (default: use tables only if they are
               < precomputed_tables_max_bytes), set use_precomputed_table on
    output =1: tables that work for all quantizers (size 256 * nlist * M) =2:
    specific version for MultiIndexQuantizer (much more compact)
:type precomputed_table: faiss::AlignedTable< float,32 >
:param precomputed_table: precomputed table to initialize
)r   "initialize_IVFPQ_precomputed_table)r  r  r  r4  rg  r  s         r   r7  r7  !  s"     889N[]r}  H  Hr$   c                   6   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  S	S9rS
 rS r\	R0                  rSrg)IndexIVFPQStatsi!  zv
statistics are robust to internal threading, but not if
IndexIVFPQ::search_preassigned is called by multiple threads
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFPQStats.<lambda>!  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r;  !  rL   r$   rM   rN   znb of refines (IVFPQR)z4nb of passed Hamming distance tests (for polysemous)zonly for IVFPQRc                 X    [         R                  " U [         R                  " 5       5        g r/   )r   IndexIVFPQStats_swiginitnew_IndexIVFPQStatsr[   s    r   rV   IndexIVFPQStats.__init__!      ++D*2P2P2RSr$   c                 .    [         R                  " U 5      $ r/   )r   IndexIVFPQStats_resetr[   s    r   r  IndexIVFPQStats.reset!  rR  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IndexIVFPQStats_nrefine_getIndexIVFPQStats_nrefine_setnrefine"IndexIVFPQStats_n_hamming_pass_get"IndexIVFPQStats_n_hamming_pass_setr  !IndexIVFPQStats_search_cycles_get!IndexIVFPQStats_search_cycles_setsearch_cycles!IndexIVFPQStats_refine_cycles_get!IndexIVFPQStats_refine_cycles_setrefine_cyclesrV   r  delete_IndexIVFPQStatsr   r>   r%   r$   r   r9  r9  !  s    
 -/IOdeGHz==z?e?e  lI  JGjKKZMzMz  A|  }NZII:KwKwxMZII:KwKw  ~T  UMT6!88r$   r9  c                   4   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9rS
 rS rS rS rS rSS jrS rS rSS jrS r\	R:                  rSrg)IndexIVFPQRi!  z/Index with an additional level of PQ refinementc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFPQR.<lambda>!  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rT  !  rL   r$   rM   rN   z3rd level quantizerzcorresponding codeszGfactor between k requested in search and the k requested from the IVFPQc                 .    [         R                  " U 5      $ r/   )r   IndexIVFPQR_resetr[   s    r   r  IndexIVFPQR.reset!  r3  r$   c                 .    [         R                  " X5      $ r/   )r   IndexIVFPQR_remove_idsrs  s     r   rt  IndexIVFPQR.remove_ids!      00;;r$   c                 0    [         R                  " XX#5      $ )z!trains the two product quantizers)r   IndexIVFPQR_train_encoderr  s       r   r  IndexIVFPQR.train_encoder!  s    33DQGGr$   c                 .    [         R                  " U 5      $ r/   )r   %IndexIVFPQR_train_encoder_num_vectorsr[   s    r   r  %IndexIVFPQR.train_encoder_num_vectors!  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexIVFPQR_add_with_idsrP  s       r   rR  IndexIVFPQR.add_with_ids!      224ADDr$   Nc                 2    [         R                  " XX#XE5      $ )zAsame as add_with_ids, but optionally use the precomputed list ids)r   IndexIVFPQR_add_corer  s         r   r  IndexIVFPQR.add_core!  s    ..thhr$   c                 0    [         R                  " XX#5      $ r/   )r   #IndexIVFPQR_reconstruct_from_offsetr"  s       r   r#  #IndexIVFPQR.reconstruct_from_offset!  s    ==dV\\r$   c                 0    [         R                  " XU5      $ r/   )r   IndexIVFPQR_merge_fromr  s      r   r  IndexIVFPQR.merge_from!      006JJr$   c                 8    [         R                  " XX#XEXgXU
5      $ r/   )r   IndexIVFPQR_search_preassignedr  s              r   r  IndexIVFPQR.search_preassigned!  s*    88!^gq|  GL  M  	Mr$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexIVFPQR_swiginitnew_IndexIVFPQRr   s     r   rV   IndexIVFPQR.__init__!  r  r$   r%   r/   r#  ) r   r   r:   r;   r<   r   r   r   r   r   IndexIVFPQR_refine_pq_getIndexIVFPQR_refine_pq_set	refine_pqIndexIVFPQR_refine_codes_getIndexIVFPQR_refine_codes_setrefine_codesIndexIVFPQR_k_factor_getIndexIVFPQR_k_factor_setr_  r  rt  r  r  rR  r  r#  r  r  rV   delete_IndexIVFPQRr   r>   r%   r$   r   rR  rR  !  s    :-/IOdeGH==z?c?c  jD  EIJCCZElEl  sM  NL
;;Z=`=`  gu  vH2<HFEi]KMQ!44r$   rR  c                   V   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9rS r\	R.                  rS rSS jrS rS rS rS rSrg)Index2Layeri!  z
 Same as an IndexIVFPQ without the inverted lists: codes are stored
sequentially

The class is mainly intended to store encoded vectors that can be
accessed randomly, the search function is not implemented.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Index2Layer.<lambda>"  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  "  rL   r$   rM   rN   zfirst level quantizerz%second level quantizer is always a PQz;size of the code for the first level (ceil(log8(q1.nlist)))z%size of the code for the second levelc                 T    [         R                  " U [         R                  " U6 5        g r/   )r   Index2Layer_swiginitnew_Index2Layerr   s     r   rV   Index2Layer.__init__"  r  r$   c                 0    [         R                  " XU5      $ r/   )r   Index2Layer_trainr>  s      r   r?  Index2Layer.train"  rp  r$   Nc           	      4    [         R                  " XX#XEU5      $ r  )r   Index2Layer_searchr[  s          r   r]  Index2Layer.search"  r 	  r$   c                 .    [         R                  " U 5      $ r/   )r   !Index2Layer_get_distance_computerr[   s    r   r  !Index2Layer.get_distance_computer"  rn  r$   c                 .    [         R                  " X5      $ )z)transfer the flat codes to an IVFPQ index)r   Index2Layer_transfer_to_IVFPQr   s     r   transfer_to_IVFPQIndex2Layer.transfer_to_IVFPQ"  s    77DDr$   c                 0    [         R                  " XX#5      $ r/   )r   Index2Layer_sa_encoder  s       r   r  Index2Layer.sa_encode"  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   Index2Layer_sa_decoder  s       r   r  Index2Layer.sa_decode!"      //BBr$   r%   r/   ) r   r   r:   r;   r<   r   r   r   r   r   Index2Layer_q1_getIndex2Layer_q1_setq1Index2Layer_pq_getIndex2Layer_pq_setr  Index2Layer_code_size_1_getIndex2Layer_code_size_1_setcode_size_1Index2Layer_code_size_2_getIndex2Layer_code_size_2_setcode_size_2rV   delete_Index2Layerr   r?  r]  r  r  r  r  r>   r%   r$   r   r  r  !  s     -/IOdeGH	*//1N1NTp	qB	*//1N1N  UA  
BB:AA:CiCi  pr  sK:AA:CiCi  p\  ]KQ!448WBECCr$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9rS
 rS rS r\	R,                  rSrg)FastScanDistancePostProcessingi&"  zDSimple context object that holds processors for FastScan operations.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   'FastScanDistancePostProcessing.<lambda>)"  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  )"  rL   r$   rM   rN   zFNorm scaling processor for Additive Quantizers (nullptr if not needed)z
    Query factors data pointer for RaBitQ (nullptr if not needed)
    This pointer should point to the beginning of the relevant
    QueryFactorsData subset for this context.
    a  
    The nprobe value used when allocating query_factors storage.
    This is needed because the allocation size (n * nprobe) may use a
    different nprobe than index->nprobe if search params override it.
    Set to 0 to use index->nprobe as fallback.
    c                 X    [         R                  " U [         R                  " 5       5        g)z#Default constructor - no processingN)r   'FastScanDistancePostProcessing_swiginit"new_FastScanDistancePostProcessingr[   s    r   rV   'FastScanDistancePostProcessing.__init__8"  s    ::4AnAnApqr$   c                 .    [         R                  " U 5      $ )z Check if norm scaling is enabled)r   /FastScanDistancePostProcessing_has_norm_scalingr[   s    r   has_norm_scaling/FastScanDistancePostProcessing.has_norm_scaling<"  s    II$OOr$   c                 .    [         R                  " U 5      $ )z,Check if query factors processing is enabled)r   3FastScanDistancePostProcessing_has_query_processingr[   s    r   has_query_processing3FastScanDistancePostProcessing.has_query_processing@"  s    MMdSSr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   .FastScanDistancePostProcessing_norm_scaler_get.FastScanDistancePostProcessing_norm_scaler_setnorm_scaler0FastScanDistancePostProcessing_query_factors_get0FastScanDistancePostProcessing_query_factors_setquery_factors)FastScanDistancePostProcessing_nprobe_get)FastScanDistancePostProcessing_nprobe_setr  rV   r  r  %delete_FastScanDistancePostProcessingr   r>   r%   r$   r   r  r  &"  s    O-/IOdeGH:TTV`  WP  WP  Vc  dKZXXZd  [V  [V \ 	M
 jJJJ  MA  MA G 	FrPT "GGr$   r  c                   h   \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  5      r\" \
R                  \
R                  5      r\" \
R"                  \
R$                  5      r\" \
R(                  \
R*                  5      r\" \
R.                  \
R0                  5      r\" \
R4                  \
R6                  5      r\" \
R:                  \
R<                  5      r\" \
R@                  \
RB                  5      r"\" \
RF                  \
RH                  5      r%\" \
RL                  \
RN                  5      r(\" \
RR                  \
RT                  5      r+\" \
RX                  \
RZ                  5      r.S r/S	 r0SS jr1S r2S r3S r4S r5S r6S r7S r8S r9SS jr:S r;S r<S r=\
R|                  r?Sr@g
)IndexFastScaniG"  a  
 Fast scan version of IndexPQ and IndexAQ. Works for 4-bit PQ and AQ for now.

The codes are not stored sequentially but grouped in blocks of size bbs.
This makes it possible to compute distances quickly with SIMD instructions.
The trailing codes (padding codes that are added to complete the last code)
are garbage.

Implementations:
12: blocked loop with internal loop on Q with qbs
13: same with reservoir accumulator to store results
14: no qbs with heap accumulator
15: no qbs with reservoir accumulator
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexFastScan.<lambda>W"  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  W"  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   IndexFastScan.__init__Y"  rX   r$   c                 2    [         R                  " XX#XE5      $ )aP  
 Initialize the fast scan index

:type d: int
:param d:         dimensionality of vectors
:type M: int
:param M:         number of subquantizers
:type nbits: int
:param nbits:     number of bits per subquantizer
:type metric: int
:param metric:    distance metric to use
:type bbs: int
:param bbs:       block size for SIMD processing
)r   IndexFastScan_init_fastscan)r   r  rX
  r  r  bbss         r   init_fastscanIndexFastScan.init_fastscani"  s     55dqUUr$   c                 .    [         R                  " U 5      $ r/   )r   IndexFastScan_resetr[   s    r   r  IndexFastScan.resetz"  rw   r$   Nc           	      4    [         R                  " XX#XEU5      $ a  
 Search for k nearest neighbors

:type n: int
:param n:          number of query vectors
:type x: float
:param x:          query vectors (n * d)
:type k: int
:param k:          number of nearest neighbors to find
:type distances: float
:param distances:  output distances (n * k)
:type labels: int
:param labels:     output labels/indices (n * k)
:type params: :py:class:`SearchParameters`, optional
:param params:     optional search parameters
)r   IndexFastScan_searchr[  s          r   r]  IndexFastScan.search}"  s    " ..tiQWXXr$   c                 0    [         R                  " XU5      $ )z~
 Add vectors to the index

:type n: int
:param n:  number of vectors to add
:type x: float
:param x:  vectors to add (n * d)
)r   IndexFastScan_addr>  s      r   rH  IndexFastScan.add"       ++DQ77r$   c                 0    [         R                  " XX#5      $ )z
 Compute codes for vectors

:type codes: uint8_t
:param codes:  output codes
:type n: int
:param n:      number of vectors to encode
:type x: float
:param x:      vectors to encode (n * d)
)r   IndexFastScan_compute_codesr   r  ra   rE   s       r   r	  IndexFastScan.compute_codes"  s     55d1HHr$   c                 2    [         R                  " XX#U5      $ )aj  
 Compute floating-point lookup table for distance computation

:type lut: float
:param lut:          output lookup table
:type n: int
:param n:            number of query vectors
:type x: float
:param x:            query vectors (n * d)
:type context: :py:class:`FastScanDistancePostProcessing`
:param context:      processing context containing all processors
)r   IndexFastScan_compute_float_LUTr   lutra   rE   contexts        r   compute_float_LUTIndexFastScan.compute_float_LUT"  s     99$Q7SSr$   c
                 6    [         R                  " XX#XEXgX5
      $ )a  
 Create a KNN handler for this index type

This method can be overridden by derived classes to provide
specialized handlers (e.g., RaBitQHeapHandler for RaBitQ indexes).
Base implementation creates standard handlers based on k and impl.

:type is_max: boolean
:param is_max:       whether to use CMax comparator (true) or CMin (false)
:type impl: int
:param impl:         implementation number
:type n: int
:param n:            number of queries
:type k: int
:param k:            number of neighbors to find
:type ntotal: int
:param ntotal:       total number of vectors in database
:type distances: float
:param distances:    output distances array
:type labels: int
:param labels:       output labels array
:type sel: :py:class:`IDSelector`
:param sel:          optional ID selector
:param query_offset: query offset for batch processing
:rtype: void
:return: pointer to created handler (never returns nullptr)
)r   IndexFastScan_make_knn_handler)
r   is_maximplra   rQ  r  rR  rS  rT  r  s
             r   make_knn_handlerIndexFastScan.make_knn_handler"  s     8 88tPQ[dnq{{r$   c                 2    [         R                  " XX#XE5      $ r/   )r   #IndexFastScan_compute_quantized_LUT)r   ra   rE   r  normalizersr  s         r   compute_quantized_LUT#IndexFastScan.compute_quantized_LUT"  s    ==dq{ddr$   c                 0    [         R                  " XU5      $ )z
 Reconstruct a vector from its code

:type key: int
:param key:     index of vector to reconstruct
:type recons: float
:param recons:  output reconstructed vector
)r   IndexFastScan_reconstructrx  s      r   r{  IndexFastScan.reconstruct"  s     33DvFFr$   c                 .    [         R                  " X5      $ )z
 Remove vectors by ID selector

:type sel: :py:class:`IDSelector`
:param sel:  selector defining which vectors to remove
:rtype: int
:return: number of vectors removed
)r   IndexFastScan_remove_idsrs  s     r   rt  IndexFastScan.remove_ids"  s     224==r$   c                 .    [         R                  " U 5      $ )zi
 Get the code packer for this index

:rtype: :py:class:`CodePacker`
:return: pointer to the code packer
)r   IndexFastScan_get_CodePackerr[   s    r   r`  IndexFastScan.get_CodePacker"  s     66t<<r$   c                 0    [         R                  " XU5      $ )z
 Merge another index into this one

:type otherIndex: :py:class:`Index`
:param otherIndex:  index to merge from
:type add_id: int, optional
:param add_id:      ID offset to add to merged vectors
)r   IndexFastScan_merge_fromr  s      r   r  IndexFastScan.merge_from"  s     224VLLr$   c                 .    [         R                  " X5      $ )z
 Check if another index is compatible for merging

:type otherIndex: :py:class:`Index`
:param otherIndex:  index to check compatibility with
)r   (IndexFastScan_check_compatible_for_merger  s     r   r  (IndexFastScan.check_compatible_for_merge#  s     BB4TTr$   c                 .    [         R                  " U 5      $ )z8standalone codes interface (but the codes are flattened))r   IndexFastScan_sa_code_sizer[   s    r   r  IndexFastScan.sa_code_size#  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexFastScan_sa_encoder  s       r   r  IndexFastScan.sa_encode#  s    11$1DDr$   r%   r/   r  )Ar   r   r:   r;   r<   r   r   rV   r   r   r   IndexFastScan_implem_getIndexFastScan_implem_setimplemIndexFastScan_skip_getIndexFastScan_skip_setskipIndexFastScan_bbs_getIndexFastScan_bbs_setr  IndexFastScan_qbs_getIndexFastScan_qbs_setqbsIndexFastScan_M_getIndexFastScan_M_setrX
  IndexFastScan_nbits_getIndexFastScan_nbits_setr  IndexFastScan_ksub_getIndexFastScan_ksub_setr  IndexFastScan_code_size_getIndexFastScan_code_size_setr  IndexFastScan_ntotal2_getIndexFastScan_ntotal2_setntotal2IndexFastScan_M2_getIndexFastScan_M2_setM2IndexFastScan_codes_getIndexFastScan_codes_setr  IndexFastScan_orig_codes_getIndexFastScan_orig_codes_set
orig_codesr  r  r]  rH  r	  r  r  r  r{  rt  r`  r  r  r  r  delete_IndexFastScanr   r>   r%   r$   r   r  r  G"  s    -/IOdeGKHj99:;^;^_FJ55z7X7XYD
:33Z5U5U
VC
:33Z5U5U
VC//1O1OPAZ779[9[\EJ55z7X7XYD??AgAghIz;;Z=a=abG	*11:3R3R	SBZ779[9[\E*AA:CjCjkJV"4Y&	8IT|<e	G	>=	MU;E!66r$   r  c                   8   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      rS rS r\R.                  rSrg	)
FastScanStatsi#  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   FastScanStats.<lambda>#  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r(  #  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   FastScanStats_swiginitnew_FastScanStatsr[   s    r   rV   FastScanStats.__init__#  r   r$   c                 .    [         R                  " U 5      $ r/   )r   FastScanStats_resetr[   s    r   r  FastScanStats.reset #  rw   r$   r%   N)r   r   r:   r;   r   r   r   r   r   FastScanStats_t0_getFastScanStats_t0_setr  FastScanStats_t1_getFastScanStats_t1_sett1FastScanStats_t2_getFastScanStats_t2_sett2FastScanStats_t3_getFastScanStats_t3_sett3rV   r  delete_FastScanStatsr   r>   r%   r$   r   r&  r&  #  s    -/IOdeGH	*11:3R3R	SB	*11:3R3R	SB	*11:3R3R	SB	*11:3R3R	SBP4!66r$   r&  c                   d   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      rS r\	R.                  rS rS	 rS
 rS rS rSS jrS rSr g)IndexAdditiveQuantizerFastScani&#  a  
 Fast scan version of IndexAQ. Works for 4-bit AQ for now.

The codes are not stored sequentially but grouped in blocks of size bbs.
This makes it possible to compute distances quickly with SIMD instructions.

Implementations:
12: blocked loop with internal loop on Q with qbs
13: same with reservoir accumulator to store results
14: no qbs with heap accumulator
15: no qbs with reservoir accumulator
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   'IndexAdditiveQuantizerFastScan.<lambda>4#  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r@  4#  rL   r$   rM   rN   c                 0    [         R                  " U /UQ76 $ r/   )r   #IndexAdditiveQuantizerFastScan_initr   s     r   r	  #IndexAdditiveQuantizerFastScan.init;#  s    ==dJTJJr$   c                 T    [         R                  " U [         R                  " U6 5        g)z_
*Overload 1:*
build from an existing IndexAQ

|

*Overload 2:*
build from an existing IndexAQ
N)r   'IndexAdditiveQuantizerFastScan_swiginit"new_IndexAdditiveQuantizerFastScanr   s     r   rV   'IndexAdditiveQuantizerFastScan.__init__?#  s      	::4AnAnptAuvr$   c                 0    [         R                  " XU5      $ r/   )r   $IndexAdditiveQuantizerFastScan_trainr>  s      r   r?  $IndexAdditiveQuantizerFastScan.trainK#      >>tJJr$   c                 0    [         R                  " XU5      $ r/   )r   2IndexAdditiveQuantizerFastScan_estimate_norm_scaler>  s      r   estimate_norm_scale2IndexAdditiveQuantizerFastScan.estimate_norm_scaleN#  s    LLTVWXXr$   c                 0    [         R                  " XX#5      $ r/   )r   ,IndexAdditiveQuantizerFastScan_compute_codesr  s       r   r	  ,IndexAdditiveQuantizerFastScan.compute_codesQ#  s    FFtTUYYr$   c                 2    [         R                  " XX#U5      $ r/   )r   0IndexAdditiveQuantizerFastScan_compute_float_LUTr  s        r   r  0IndexAdditiveQuantizerFastScan.compute_float_LUTT#  s    JJ4VW\cddr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   %IndexAdditiveQuantizerFastScan_searchr[  s          r   r]  %IndexAdditiveQuantizerFastScan.searchW#  s    ??ybhiir$   c                 0    [         R                  " XX#5      $ )ae  
 Decode a set of vectors.

 NOTE: The codes in the IndexAdditiveQuantizerFastScan object are non-
       contiguous. But this method requires a contiguous representation.

:type n: int
:param n:       number of vectors
:type bytes: uint8_t
:param bytes:   input encoded vectors, size n * code_size
:type x: float
:param x:       output vectors, size n * d
)r   (IndexAdditiveQuantizerFastScan_sa_decoder  s       r   r  (IndexAdditiveQuantizerFastScan.sa_decodeZ#  s     BB4EUUr$   r%   r/   )!r   r   r:   r;   r<   r   r   r   r   r   %IndexAdditiveQuantizerFastScan_aq_get%IndexAdditiveQuantizerFastScan_aq_setrI  /IndexAdditiveQuantizerFastScan_rescale_norm_get/IndexAdditiveQuantizerFastScan_rescale_norm_setrescale_norm-IndexAdditiveQuantizerFastScan_norm_scale_get-IndexAdditiveQuantizerFastScan_norm_scale_set
norm_scale3IndexAdditiveQuantizerFastScan_max_train_points_get3IndexAdditiveQuantizerFastScan_max_train_points_setr  r	  %delete_IndexAdditiveQuantizerFastScanr   rV   r?  rO  r	  r  r]  r  r>   r%   r$   r   r>  r>  &#  s     -/IOdeGH	*BBJDtDt	uBJVVXb  YS  YS  TL*RRT^  UM  UM  NJ
 ^ ^`j  a_  a_  `K!GG
wKYZejVr$   r>  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS r\	R                  rS	rg
)IndexResidualQuantizerFastScanil#  rM  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   'IndexResidualQuantizerFastScan.<lambda>s#  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rk  s#  rL   r$   rM   rN   rQ  c                 T    [         R                  " U [         R                  " U6 5        ga  
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:type M: int
:param M:      number of subquantizers
:type nbits: int
:param nbits:  number of bit per subvector index
:type metric: int, optional
:param metric:  metric type
:type search_type: int, optional
:param search_type: AQ search type

:type d: int
:param d: dimensionality of the input vectors
:type M: int
:param M: number of subquantizers
:type nbits: int
:param nbits: number of bit per subvector index
N)r   'IndexResidualQuantizerFastScan_swiginit"new_IndexResidualQuantizerFastScanr   s     r   rV   'IndexResidualQuantizerFastScan.__init__w#  s     , 	::4AnAnptAuvr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   %IndexResidualQuantizerFastScan_rq_get%IndexResidualQuantizerFastScan_rq_setr  rV   %delete_IndexResidualQuantizerFastScanr   r>   r%   r$   r   ri  ri  l#  sU     -/IOdeGH	*BBJDtDt  {s  
tBw. "GGr$   ri  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS r\	R                  rSrg	)
!IndexLocalSearchQuantizerFastScani#  z
 Index based on a local search quantizer. Stored vectors are
approximated by local search quantization codes.
Can also be used as a codec
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   *IndexLocalSearchQuantizerFastScan.<lambda>#  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rx  #  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        grn  )r   *IndexLocalSearchQuantizerFastScan_swiginit%new_IndexLocalSearchQuantizerFastScanr   s     r   rV   *IndexLocalSearchQuantizerFastScan.__init__#  s     , 	==dJDtDtvzD{|r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   )IndexLocalSearchQuantizerFastScan_lsq_get)IndexLocalSearchQuantizerFastScan_lsq_setr  rV   (delete_IndexLocalSearchQuantizerFastScanr   r>   r%   r$   r   rv  rv  #  sK     -/IOdeGH
:GGI}I}
~C}. "JJr$   rv  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS r\	R                  rS	rg
)%IndexProductResidualQuantizerFastScani#  z
 Index based on a product residual quantizer. Stored vectors are
approximated by product residual quantization codes.
Can also be used as a codec
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   .IndexProductResidualQuantizerFastScan.<lambda>#  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  #  rL   r$   rM   rN   rr  c                 T    [         R                  " U [         R                  " U6 5        g)a  
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:type nsplits: int
:param nsplits:  number of residual quantizers
:type Msub: int
:param Msub:     number of subquantizers per RQ
:type nbits: int
:param nbits:  number of bit per subvector index
:type metric: int, optional
:param metric:  metric type
:type search_type: int, optional
:param search_type: AQ search type

:type d: int
:param d: dimensionality of the input vectors
:type nsplits: int
:param nsplits: number of residual quantizers
:type Msub: int
:param Msub: number of subquantizers per RQ
:type nbits: int
:param nbits: number of bit per subvector index
N)r   .IndexProductResidualQuantizerFastScan_swiginit)new_IndexProductResidualQuantizerFastScanr   s     r   rV   .IndexProductResidualQuantizerFastScan.__init__#  s+    4 	AA$
H|H|  C  ID  	Er$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   -IndexProductResidualQuantizerFastScan_prq_get-IndexProductResidualQuantizerFastScan_prq_setr|  rV   ,delete_IndexProductResidualQuantizerFastScanr   r>   r%   r$   r   r  r  #  s]     -/IOdeGH
:KKZ  NF  NF  LL  MCE6 "NNr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9rS r\	R                  rS	rg
)(IndexProductLocalSearchQuantizerFastScani#  z
 Index based on a product local search quantizer. Stored vectors are
approximated by product local search quantization codes.
Can also be used as a codec
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   1IndexProductLocalSearchQuantizerFastScan.<lambda>#  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  #  rL   r$   rM   rN   r  c                 T    [         R                  " U [         R                  " U6 5        g)a  
 Constructor.

:type d: int
:param d:      dimensionality of the input vectors
:type nsplits: int
:param nsplits:  number of local search quantizers
:type Msub: int
:param Msub:     number of subquantizers per LSQ
:type nbits: int
:param nbits:  number of bit per subvector index
:type metric: int, optional
:param metric:  metric type
:type search_type: int, optional
:param search_type: AQ search type

:type d: int
:param d: dimensionality of the input vectors
:type nsplits: int
:param nsplits: number of local search quantizers
:type Msub: int
:param Msub: number of subquantizers per LSQ
:type nbits: int
:param nbits: number of bit per subvector index
N)r   1IndexProductLocalSearchQuantizerFastScan_swiginit,new_IndexProductLocalSearchQuantizerFastScanr   s     r   rV   1IndexProductLocalSearchQuantizerFastScan.__init__#  s3    4 	DDT:  LC  LC  EI  LJ  	Kr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   1IndexProductLocalSearchQuantizerFastScan_plsq_get1IndexProductLocalSearchQuantizerFastScan_plsq_setr  rV   /delete_IndexProductLocalSearchQuantizerFastScanr   r>   r%   r$   r   r  r  #  s^     -/IOdeGHJPPR\  SO  SO  UY  ZDK6 "QQr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS rS	 rS
 rS r\	R$                  rSrg)IndexPQFastScani$  a  
 Fast scan version of IndexPQ. Works for 4-bit PQ for now.

The codes are not stored sequentially but grouped in blocks of size bbs.
This makes it possible to compute distances quickly with SIMD instructions.

Implementations:
12: blocked loop with internal loop on Q with qbs
13: same with reservoir accumulator to store results
14: no qbs with heap accumulator
15: no qbs with reservoir accumulator
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexPQFastScan.<lambda>$  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  $  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g)z_
*Overload 1:*
build from an existing IndexPQ

|

*Overload 2:*
build from an existing IndexPQ
N)r   IndexPQFastScan_swiginitnew_IndexPQFastScanr   s     r   rV   IndexPQFastScan.__init__$  s      	++D*2P2PRV2WXr$   c                 0    [         R                  " XU5      $ r/   )r   IndexPQFastScan_trainr>  s      r   r?  IndexPQFastScan.train*$  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexPQFastScan_compute_codesr  s       r   r	  IndexPQFastScan.compute_codes-$  s    77QJJr$   c                 2    [         R                  " XX#U5      $ r/   )r   !IndexPQFastScan_compute_float_LUTr  s        r   r  !IndexPQFastScan.compute_float_LUT0$  s    ;;DqWUUr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexPQFastScan_sa_decoder  s       r   r  IndexPQFastScan.sa_decode3$  s    33DUFFr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IndexPQFastScan_pq_getIndexPQFastScan_pq_setr  rV   r?  r	  r  r  delete_IndexPQFastScanr   r>   r%   r$   r   r  r  $  s`     -/IOdeGH	*33Z5V5V	WB
Y<KVG!88r$   r  c                   J    \ rS rSr\" S S SS9r\rS r\	R                  rSrg)	simd16uint16i9$  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   simd16uint16.<lambda>:$  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  :$  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   simd16uint16_swiginitnew_simd16uint16r[   s    r   rV   simd16uint16.__init__=$  r  r$   r%   N)r   r   r:   r;   r   r   r   r   rV   r   delete_simd16uint16r   r>   r%   r$   r   r  r  9$  s*    -/IOdeGHN!55r$   r  c                      \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  5      r\" \
R                  \
R                  5      r\" \
R"                  \
R$                  5      rS rS	 r\
R,                  rS
rg)SIMDResultHandleriC$  z@This file contains callbacks for kernels that compute distances.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   SIMDResultHandler.<lambda>F$  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  F$  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   SIMDResultHandler.__init__H$  rX   r$   c                 2    [         R                  " XX#U5      $ )zy
called when 32 distances are computed and provided in two
simd16uint16. (q, b) indicate which entry it is in the block.
)r   SIMDResultHandler_handler   r  r  d0d1s        r   handleSIMDResultHandler.handleO$  s    
 224A2FFr$   c                 0    [         R                  " XU5      $ )z)set the sub-matrix that is being computed)r   "SIMDResultHandler_set_block_origin)r   r  j0s      r   set_block_origin"SIMDResultHandler.set_block_originV$  s    <<TrJJr$   r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r   SIMDResultHandler_is_CMax_getSIMDResultHandler_is_CMax_setis_CMax SIMDResultHandler_sizeof_ids_get SIMDResultHandler_sizeof_ids_set
sizeof_ids!SIMDResultHandler_with_fields_get!SIMDResultHandler_with_fields_setwith_fieldsr  r  delete_SIMDResultHandlerr   r>   r%   r$   r   r  r  C$  s    K-/IOdeGKHz??AiAijG*EEzGrGrsJ:GGIuIuvKGK "::r$   r  c                      \ rS rSr\" S S SS9rS r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  SS9r\" \	R&                  \	R(                  5      r\" \	R,                  \	R.                  5      r\" \	R2                  \	R4                  5      rS rS	 rS
 rS r\	R@                  r!Sr"g)SIMDResultHandlerToFloati]$  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   !SIMDResultHandlerToFloat.<lambda>^$  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  ^$  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   !SIMDResultHandlerToFloat.__init__`$  rX   r$   zDthese fields are used mainly for the IVF variants (with_id_map=true)c                 .    [         R                  " X5      $ r/   )r   SIMDResultHandlerToFloat_beginr=  s     r   r\  SIMDResultHandlerToFloat.beginj$  s    88EEr$   c                 .    [         R                  " U 5      $ r/   )r   SIMDResultHandlerToFloat_endr[   s    r   r]  SIMDResultHandlerToFloat.endm$  r  r$   c                 .    [         R                  " U 5      $ r/   )r   $SIMDResultHandlerToFloat_num_updatesr[   s    r   num_updates$SIMDResultHandlerToFloat.num_updatesp$  r+  r$   c                 0    [         R                  " XU5      $ )a  
 Set context information for handlers that need additional data

This method can be overridden by handlers that need list numbers
and probe mappings (e.g., RaBitQ handlers). Base implementation
does nothing since most handlers don't need this context.

:param list_no:      current inverted list number being processed
:param probe_map:    mapping from local query index to probe index
)r   )SIMDResultHandlerToFloat_set_list_contextr   r   arg3s      r   set_list_context)SIMDResultHandlerToFloat.set_list_contexts$  s     CCDPTUUr$   r%   N)#r   r   r:   r;   r   r   rV   r   r   r   SIMDResultHandlerToFloat_nq_getSIMDResultHandlerToFloat_nq_setr  #SIMDResultHandlerToFloat_ntotal_get#SIMDResultHandlerToFloat_ntotal_setr  #SIMDResultHandlerToFloat_id_map_get#SIMDResultHandlerToFloat_id_map_setid_map"SIMDResultHandlerToFloat_q_map_get"SIMDResultHandlerToFloat_q_map_setq_map"SIMDResultHandlerToFloat_dbias_get"SIMDResultHandlerToFloat_dbias_setdbias(SIMDResultHandlerToFloat_normalizers_get(SIMDResultHandlerToFloat_normalizers_setr  r\  r]  r  r  delete_SIMDResultHandlerToFloatr   r>   r%   r$   r   r  r  ]$  s    -/IOdeGKH	*<<j>h>h	iBjDDjFtFtuFjDDjFtFt  {F  GFZBBJDqDqrEZBBJDqDqrE:NNPZ  QD  QD  EKF=EV "AAr$   r  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS r\	R                  rS	 rS
rg)DummyResultHandleri$  zk
 Dummy structure that just computes a checksum on results
(to avoid the computation to be optimized away)
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   DummyResultHandler.<lambda>$  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  $  rL   r$   rM   rN   c                 2    [         R                  " XX#U5      $ r/   )r   DummyResultHandler_handler  s        r   r  DummyResultHandler.handle$      33DQBGGr$   c                 0    [         R                  " XU5      $ r/   )r   #DummyResultHandler_set_block_originr  s      r   r  #DummyResultHandler.set_block_origin$  s    ==d$OOr$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   DummyResultHandler_swiginitnew_DummyResultHandlerr[   s    r   rV   DummyResultHandler.__init__$  rj  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   DummyResultHandler_cs_getDummyResultHandler_cs_setr  r  r  delete_DummyResultHandlerr   rV   r>   r%   r$   r   r   r   $  sU    
 -/IOdeGH	*66
8\8\	]BHP!;;Zr$   r   c                   B   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      rS rS rS	 r\	R2                  rS
rg)StoreResultHandleri$  z[
 memorize results in a nq-by-nb matrix.

j0 is the current upper-left block of the matrix
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   StoreResultHandler.<lambda>$  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  $  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   StoreResultHandler_swiginitnew_StoreResultHandler)r   r   ry  s      r   rV   StoreResultHandler.__init__$  s    ..tZ5V5VW[5`ar$   c                 2    [         R                  " XX#U5      $ r/   )r   StoreResultHandler_handler  s        r   r  StoreResultHandler.handle$  r  r$   c                 0    [         R                  " XU5      $ r/   )r   #StoreResultHandler_set_block_origin)r   i0_inj0_ins      r   r  #StoreResultHandler.set_block_origin$  s    ==d5QQr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   StoreResultHandler_data_getStoreResultHandler_data_setr   StoreResultHandler_ld_getStoreResultHandler_ld_setry  StoreResultHandler_i0_getStoreResultHandler_i0_setr  StoreResultHandler_j0_getStoreResultHandler_j0_setr  rV   r  r  delete_StoreResultHandlerr   r>   r%   r$   r   r  r  $  s     -/IOdeGHJ::J<b<bcD	*66
8\8\	]B	*66
8\8\	]B	*66
8\8\	]BbHR!;;r$   r  c                   `   \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  5      r\" \
R                  \
R                  5      r\" \
R"                  \
R$                  5      r\" \
R(                  \
R*                  5      r\" \
R.                  \
R0                  5      r\" \
R4                  \
R6                  5      r\" \
R:                  \
R<                  5      r\" \
R@                  \
RB                  5      r"\" \
RF                  \
RH                  5      r%\" \
RL                  \
RN                  5      r(S r)S	 r*\
RV                  r,\" \
RZ                  \
R\                  S
S9r/S r0S r1S r2S r3SS jr4SS jr5SS jr6SS jr7SS jr8SS jr9SS jr:SS jr;SS jr<S r=S r>S r?S r@SrAg) IndexIVFFastScani$  a7  
 Fast scan version of IVFPQ and IVFAQ. Works for 4-bit PQ/AQ for now.

The codes in the inverted lists are not stored sequentially but
grouped in blocks of size bbs. This makes it possible to very quickly
compute distances with SIMD instructions.

Implementations (implem):
0: auto-select implementation (default)
1: orig's search, re-implemented
2: orig's search, re-ordered by invlist
10: optimizer int16 search, collect results in heap, no qbs
11: idem, collect results in reservoir
12: optimizer int16 search, collect results in heap, uses qbs
13: idem, collect results in reservoir
14: internally multithreaded implem over nq * nprobe
15: same with reservoir

For range search, only 10 and 12 are supported.
add 100 to the implem to force single-thread scanning (the coarse quantizer
may still use multiple threads).
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFFastScan.<lambda>$  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r/  $  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   IndexIVFFastScan.__init__$  rX   r$   c           
      4    [         R                  " XX#XEXg5      $ )aK  
 Initialize the fast scan functionality (called by implementations)

:type fine_quantizer: :py:class:`Quantizer`
:param fine_quantizer:  fine quantizer for encoding
:type M: int
:param M:               number of subquantizers
:type nbits: int
:param nbits:           number of bits per subquantizer
:type nlist: int
:param nlist:           number of inverted lists
:type metric: int
:param metric:          distance metric to use
:type bbs: int
:param bbs:             block size for SIMD processing
:type own_invlists: boolean
:param own_invlists:    whether to own the inverted lists
)r   IndexIVFFastScan_init_fastscan)r   fine_quantizerrX
  r  r#  r  r  r[  s           r   r  IndexIVFFastScan.init_fastscan$  s    & 88qY^hkzzr$   c                 .    [         R                  " U 5      $ r/   )r   !IndexIVFFastScan_init_code_packerr[   s    r   init_code_packer!IndexIVFFastScan.init_code_packer$  rn  r$   z%orig's inverted lists (for debugging)c                 0    [         R                  " XX#5      $ )z
 Add vectors with specific IDs to the index

:type n: int
:param n:     number of vectors to add
:type x: float
:param x:     vectors to add (n * d)
:type xids: int
:param xids:  IDs for the vectors (n)
)r   IndexIVFFastScan_add_with_idsrP  s       r   rR  IndexIVFFastScan.add_with_ids$  s     77IIr$   c                 .    [         R                  " U 5      $ r/   )r   #IndexIVFFastScan_lookup_table_is_3dr[   s    r   lookup_table_is_3d#IndexIVFFastScan.lookup_table_is_3d%  r/  r$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexIVFFastScan_compute_LUTr   ra   rE   cqr  biasesr  s          r   r5  IndexIVFFastScan.compute_LUT%  s    66tz[bccr$   c           
      4    [         R                  " XX#XEXg5      $ )a  
 Compute quantized lookup tables for distance computation

:type n: int
:param n:             number of query vectors
:type x: float
:param x:             query vectors (n * d)
:type cq: faiss::IndexIVFFastScan::CoarseQuantized
:param cq:            coarse quantization results
:type dis_tables: faiss::AlignedTable< uint8_t >
:param dis_tables:    output quantized distance tables
:type biases: faiss::AlignedTable< uint16_t >
:param biases:        output quantized bias values
:type normalizers: float
:param normalizers:   output normalization factors
:type context: :py:class:`FastScanDistancePostProcessing`
:param context:       processing context containing query factors
    processor
)r   "IndexIVFFastScan_compute_LUT_uint8)r   ra   rE   rE  r  rF  r  r  s           r   compute_LUT_uint8"IndexIVFFastScan.compute_LUT_uint8%  s    ( <<TaZalvvr$   Nc           	      4    [         R                  " XX#XEU5      $ r  )r   IndexIVFFastScan_searchr[  s          r   r]  IndexIVFFastScan.search%  s    " 11$1TZ[[r$   c                 8    [         R                  " XX#XEXgXU
5      $ )aE  
 Search with pre-assigned coarse quantization

:type n: int
:param n:             number of query vectors
:type x: float
:param x:             query vectors (n * d)
:type k: int
:param k:             number of nearest neighbors to find
:type assign: int
:param assign:        coarse cluster assignments (n * nprobe)
:type centroid_dis: float
:param centroid_dis:  distances to centroids (n * nprobe)
:type distances: float
:param distances:     output distances (n * k)
:type labels: int
:param labels:        output labels/indices (n * k)
:type store_pairs: boolean
:param store_pairs:   whether to store cluster-relative pairs
:type params: :py:class:`IVFSearchParameters`, optional
:param params:        optional IVF search parameters
:type stats: :py:class:`IndexIVFStats`, optional
:param stats:         optional search statistics
)r   #IndexIVFFastScan_search_preassignedr  s              r   r  #IndexIVFFastScan.search_preassigned1%  s0    2 ==dqVcl  wB  LQ  R  	Rr$   c                 2    [         R                  " XX#XE5      $ )a  
 Range search for all neighbors within radius

:type n: int
:param n:       number of query vectors
:type x: float
:param x:       query vectors (n * d)
:type radius: float
:param radius:  search radius
:type result: :py:class:`RangeSearchResult`
:param result:  output range search results
:type params: :py:class:`SearchParameters`, optional
:param params:  optional search parameters
)r   IndexIVFFastScan_range_searchrf  s         r   rg  IndexIVFFastScan.range_searchL%  s     77F[[r$   c
                 6    [         R                  " XX#XEXgX5
      $ )u  
 Create a KNN handler for this index type

This method can be overridden by derived classes to provide
specialized handlers (e.g., IVFRaBitQHeapHandler for RaBitQ indexes).
Base implementation creates standard handlers based on k and impl.

:type is_max: boolean
:param is_max:        true for max-heap (inner product), false for
                         min-heap (L2 distance)
:type impl: int
:param impl:          implementation number:
                         - even (10, 12, 14): use heap for top-k
                         - odd (11, 13, 15): use reservoir sampling
:type n: int
:param n:             number of queries
:type k: int
:param k:             number of neighbors to find per query
:type distances: float
:param distances:     output array for distances (n * k), will be
                         populated by handler
:type labels: int
:param labels:        output array for result IDs (n * k), will be
                         populated by handler
:type sel: :py:class:`IDSelector`
:param sel:           optional ID selector to filter results (nullptr =
                         no filtering)
:type context: :py:class:`FastScanDistancePostProcessing`
:param context:       processing context containing additional data
:type normalizers: float, optional
:param normalizers:   optional array of size 2*n for converting quantized
                         uint16 distances to float.

:rtype: :py:class:`SIMDResultHandlerToFloat`
:return: Allocated result handler (caller owns and must delete).
            Handler processes SIMD batches and populates distances/labels.

Notes: The returned handler must be deleted by caller after use.
      Typical usage: handler->begin() → process batches → handler->end()
)r   !IndexIVFFastScan_make_knn_handler)
r   r  r  ra   rQ  rR  rS  rT  r  r  s
             r   r  !IndexIVFFastScan.make_knn_handler]%  s'    R ;;D$STagnu  D  	Dr$   c	                 6    [         R                  " XX#XEXgU5	      $ r/   )r   'IndexIVFFastScan_search_dispatch_implem)	r   ra   rE   rQ  rR  rS  rE  r  r\  s	            r   search_dispatch_implem'IndexIVFFastScan.search_dispatch_implem%  s    AA$1QZdfqwxxr$   c           
      4    [         R                  " XX#XEXg5      $ r/   )r   -IndexIVFFastScan_range_search_dispatch_implem)r   ra   rE   rW  rrescq_inr  r\  s           r   range_search_dispatch_implem-IndexIVFFastScan.range_search_dispatch_implem%  s    GGQR\`ipyyr$   c	                 6    [         R                  " XX#XEXgU5	      $ r/   )r   !IndexIVFFastScan_search_implem_10	r   ra   rE   handlerrE  ndis_out	nlist_outr  r\  s	            r   search_implem_10!IndexIVFFastScan.search_implem_10%      ;;DQQS_hsyzzr$   c	                 6    [         R                  " XX#XEXgU5	      $ r/   )r   !IndexIVFFastScan_search_implem_12rd  s	            r   search_implem_12!IndexIVFFastScan.search_implem_12%  rj  r$   c
                 6    [         R                  " XX#XEXgX5
      $ r/   )r   !IndexIVFFastScan_search_implem_14)
r   ra   rE   rQ  rR  rS  rE  r  r  r\  s
             r   search_implem_14!IndexIVFFastScan.search_implem_14%  s    ;;DQ9^`hoxxr$   c                 0    [         R                  " XX#5      $ r/   )r   (IndexIVFFastScan_reconstruct_from_offsetr"  s       r   r#  (IndexIVFFastScan.reconstruct_from_offset%  s    BB4RXaar$   c                 .    [         R                  " U 5      $ r/   )r   IndexIVFFastScan_get_CodePackerr[   s    r   r`  IndexIVFFastScan.get_CodePacker%  r'  r$   c                 .    [         R                  " U 5      $ r/   )r   *IndexIVFFastScan_reconstruct_orig_invlistsr[   s    r   reconstruct_orig_invlists*IndexIVFFastScan.reconstruct_orig_invlists%  s    DDTJJr$   c                 0    [         R                  " XX#5      $ )aP  
 Decode a set of vectors

NOTE: The codes in the IndexFastScan object are non-contiguous.
      But this method requires a contiguous representation.

:type n: int
:param n:       number of vectors
:type bytes: uint8_t
:param bytes:   input encoded vectors, size n * code_size
:type x: float
:param x:       output vectors, size n * d
)r   IndexIVFFastScan_sa_decoder  s       r   r  IndexIVFFastScan.sa_decode%  s     44TeGGr$   r%   r/   r#  )Br   r   r:   r;   r<   r   r   rV   r   r   r   IndexIVFFastScan_bbs_getIndexIVFFastScan_bbs_setr  IndexIVFFastScan_M_getIndexIVFFastScan_M_setrX
  IndexIVFFastScan_nbits_getIndexIVFFastScan_nbits_setr  IndexIVFFastScan_ksub_getIndexIVFFastScan_ksub_setr  IndexIVFFastScan_M2_getIndexIVFFastScan_M2_setr  IndexIVFFastScan_implem_getIndexIVFFastScan_implem_setr  IndexIVFFastScan_skip_getIndexIVFFastScan_skip_setr  IndexIVFFastScan_qbs_getIndexIVFFastScan_qbs_setr  IndexIVFFastScan_qbs2_getIndexIVFFastScan_qbs2_setqbs2#IndexIVFFastScan_fine_quantizer_get#IndexIVFFastScan_fine_quantizer_setr5  r  r9  delete_IndexIVFFastScanr   "IndexIVFFastScan_orig_invlists_get"IndexIVFFastScan_orig_invlists_setorig_invlistsrR  r@  r5  rJ  r]  r  rg  r  rZ  r`  rh  rm  rq  r#  r`  r{  r  r>   r%   r$   r   r-  r-  $  s   . -/IOdeGKH
:66
8[8[
\C22J4U4UVAZ::J<a<abEJ88*:^:^_D	*44j6X6X	YBj<<j>d>deFJ88*:^:^_D
:66
8[8[
\CJ88*:^:^_DjLLjN|N|}N{*B!99ZJJJLyLy  @l  mMJDdw,\&R6\")DVyz{{yb@KHr$   r-  c                   f   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      r\" \R*                  \R,                  5      r\" \R0                  \R2                  5      r\" \R6                  \R8                  5      r\" \R<                  \R>                  5      r \" \RB                  \RD                  5      r#S r$S r%S r&S	 r'\RP                  r)S
r*g)IVFFastScanStatsi%  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IVFFastScanStats.<lambda>%  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  %  rL   r$   rM   rN   c                 .    [         R                  " X5      $ r/   )r   IVFFastScanStats_Mcy_atr  s     r   Mcy_atIVFFastScanStats.Mcy_at%  rn   r$   c                 .    [         R                  " X5      $ r/   )r   !IVFFastScanStats_Mcy_reservoir_atr  s     r   Mcy_reservoir_at!IVFFastScanStats.Mcy_reservoir_at%  r6  r$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   IVFFastScanStats_swiginitnew_IVFFastScanStatsr[   s    r   rV   IVFFastScanStats.__init__%  r-  r$   c                 .    [         R                  " U 5      $ r/   )r   IVFFastScanStats_resetr[   s    r   r  IVFFastScanStats.reset%  rB  r$   r%   N)+r   r   r:   r;   r   r   r   r   r   IVFFastScanStats_times_getIVFFastScanStats_times_settimes.IVFFastScanStats_t_compute_distance_tables_get.IVFFastScanStats_t_compute_distance_tables_sett_compute_distance_tablesIVFFastScanStats_t_round_getIVFFastScanStats_t_round_sett_round IVFFastScanStats_t_copy_pack_get IVFFastScanStats_t_copy_pack_sett_copy_packIVFFastScanStats_t_scan_getIVFFastScanStats_t_scan_sett_scanIVFFastScanStats_t_to_flat_getIVFFastScanStats_t_to_flat_set	t_to_flat$IVFFastScanStats_reservoir_times_get$IVFFastScanStats_reservoir_times_setreservoir_times IVFFastScanStats_t_aq_encode_get IVFFastScanStats_t_aq_encode_sett_aq_encode%IVFFastScanStats_t_aq_norm_encode_get%IVFFastScanStats_t_aq_norm_encode_sett_aq_norm_encoder  r  rV   r  delete_IVFFastScanStatsr   r>   r%   r$   r   r  r  %  s0   -/IOdeGHZ::J<a<abE ()b)bdn  e^  e^  !_z>>
@g@ghG:FF
HsHstKj<<j>d>deFBBJDmDmnIzNNPZPP  AO:FF
HsHstK
 P PR\  SC  SC  D;EV7!99r$   r  c                   n   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      rS r\	R.                  rS rS	 rS
 rS rSS jrSS jrS rS r Sr!g)!IndexIVFAdditiveQuantizerFastScani%  a?  
 Fast scan version of IVFAQ. Works for 4-bit AQ for now.

The codes in the inverted lists are not stored sequentially but
grouped in blocks of size bbs. This makes it possible to very quickly
compute distances with SIMD instructions.

Implementations (implem):
0: auto-select implementation (default)
1: orig's search, re-implemented
2: orig's search, re-ordered by invlist
10: optimizer int16 search, collect results in heap, no qbs
11: idem, collect results in reservoir
12: optimizer int16 search, collect results in heap, uses qbs
13: idem, collect results in reservoir
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   *IndexIVFAdditiveQuantizerFastScan.<lambda>%  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  %  rL   r$   rM   rN   c                 2    [         R                  " XX#XE5      $ r/   )r   &IndexIVFAdditiveQuantizerFastScan_init)r   rI  r#  r  r  r[  s         r   r	  &IndexIVFAdditiveQuantizerFastScan.init%  s    @@5Z]llr$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   *IndexIVFAdditiveQuantizerFastScan_swiginit%new_IndexIVFAdditiveQuantizerFastScanr   s     r   rV   *IndexIVFAdditiveQuantizerFastScan.__init__%      ==dJDtDtvzD{|r$   c                 0    [         R                  " XX#5      $ r/   )r   /IndexIVFAdditiveQuantizerFastScan_train_encoderr  s       r   r  /IndexIVFAdditiveQuantizerFastScan.train_encoder%  s    II$ST]]r$   c                 .    [         R                  " U 5      $ r/   )r   ;IndexIVFAdditiveQuantizerFastScan_train_encoder_num_vectorsr[   s    r   r  ;IndexIVFAdditiveQuantizerFastScan.train_encoder_num_vectors%  s    UUVZ[[r$   c                 0    [         R                  " XU5      $ r/   )r   5IndexIVFAdditiveQuantizerFastScan_estimate_norm_scaler>  s      r   rO  5IndexIVFAdditiveQuantizerFastScan.estimate_norm_scale%  s    OOPTYZ[[r$   c                 2    [         R                  " XX#XE5      $ )zY
same as the regular IVFAQ encoder. The codes are not reorganized by
blocks a that point
)r   0IndexIVFAdditiveQuantizerFastScan_encode_vectorsr  s         r   r  0IndexIVFAdditiveQuantizerFastScan.encode_vectors%  s    
 JJ4TUafwwr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   (IndexIVFAdditiveQuantizerFastScan_searchr[  s          r   r]  (IndexIVFAdditiveQuantizerFastScan.search%  s    BB4AR[ekllr$   c                 .    [         R                  " U 5      $ r/   )r   4IndexIVFAdditiveQuantizerFastScan_lookup_table_is_3dr[   s    r   r@  4IndexIVFAdditiveQuantizerFastScan.lookup_table_is_3d&  rF  r$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   -IndexIVFAdditiveQuantizerFastScan_compute_LUTrD  s          r   r5  -IndexIVFAdditiveQuantizerFastScan.compute_LUT&  s    GGQRXblsttr$   r%   rV  r/   )"r   r   r:   r;   r<   r   r   r   r   r   (IndexIVFAdditiveQuantizerFastScan_aq_get(IndexIVFAdditiveQuantizerFastScan_aq_setrI  2IndexIVFAdditiveQuantizerFastScan_rescale_norm_get2IndexIVFAdditiveQuantizerFastScan_rescale_norm_setra  0IndexIVFAdditiveQuantizerFastScan_norm_scale_get0IndexIVFAdditiveQuantizerFastScan_norm_scale_setrd  6IndexIVFAdditiveQuantizerFastScan_max_train_points_get6IndexIVFAdditiveQuantizerFastScan_max_train_points_setr  r	  (delete_IndexIVFAdditiveQuantizerFastScanr   rV   r  r  rO  r  r]  r@  r5  r>   r%   r$   r   r  r  %  s    " -/IOdeGH	*EEzGzGz	{BJYY[e  \Y  \Y  ZL*UUWa  XS  XS  TJ
 a acm  de  de  fm!JJ}^\\xmUur$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS r\R                  rSrg)	$IndexIVFLocalSearchQuantizerFastScani	&  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   -IndexIVFLocalSearchQuantizerFastScan.<lambda>
&  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  
&  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   -IndexIVFLocalSearchQuantizerFastScan_swiginit(new_IndexIVFLocalSearchQuantizerFastScanr   s     r   rV   -IndexIVFLocalSearchQuantizerFastScan.__init__&  s)    @@zGzGz  }A  HB  	Cr$   r%   N)r   r   r:   r;   r   r   r   r   r   ,IndexIVFLocalSearchQuantizerFastScan_lsq_get,IndexIVFLocalSearchQuantizerFastScan_lsq_setr  rV   +delete_IndexIVFLocalSearchQuantizerFastScanr   r>   r%   r$   r   r  r  	&  sM    -/IOdeGH
:JJJ  MD  MD  ECC!MMr$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS r\R                  rSrg)	!IndexIVFResidualQuantizerFastScani&  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   *IndexIVFResidualQuantizerFastScan.<lambda>&  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  &  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   *IndexIVFResidualQuantizerFastScan_swiginit%new_IndexIVFResidualQuantizerFastScanr   s     r   rV   *IndexIVFResidualQuantizerFastScan.__init__&  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   (IndexIVFResidualQuantizerFastScan_rq_get(IndexIVFResidualQuantizerFastScan_rq_setr  rV   (delete_IndexIVFResidualQuantizerFastScanr   r>   r%   r$   r   r  r  &  sB    -/IOdeGH	*EEzGzGz	{B}!JJr$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS r\R                  rSrg)	+IndexIVFProductLocalSearchQuantizerFastScani&  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   4IndexIVFProductLocalSearchQuantizerFastScan.<lambda> &  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r   &  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   4IndexIVFProductLocalSearchQuantizerFastScan_swiginit/new_IndexIVFProductLocalSearchQuantizerFastScanr   s     r   rV   4IndexIVFProductLocalSearchQuantizerFastScan.__init__$&  s1    GGj  OI  OI  KO  OP  	Qr$   r%   N)r   r   r:   r;   r   r   r   r   r   4IndexIVFProductLocalSearchQuantizerFastScan_plsq_get4IndexIVFProductLocalSearchQuantizerFastScan_plsq_setr  rV   2delete_IndexIVFProductLocalSearchQuantizerFastScanr   r>   r%   r$   r   r  r  &  sN    -/IOdeGHJSSU_  VU  VU  VDQ!TTr$   r  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS r\R                  rSrg)	(IndexIVFProductResidualQuantizerFastScani*&  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   1IndexIVFProductResidualQuantizerFastScan.<lambda>+&  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  +&  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   1IndexIVFProductResidualQuantizerFastScan_swiginit,new_IndexIVFProductResidualQuantizerFastScanr   s     r   rV   1IndexIVFProductResidualQuantizerFastScan.__init__/&  s1    DDT:  LC  LC  EI  LJ  	Kr$   r%   N)r   r   r:   r;   r   r   r   r   r   0IndexIVFProductResidualQuantizerFastScan_prq_get0IndexIVFProductResidualQuantizerFastScan_prq_setr|  rV   /delete_IndexIVFProductResidualQuantizerFastScanr   r>   r%   r$   r   r  r  *&  sN    -/IOdeGH
:NNPZ  QL  QL  MCK!QQr$   r  c                   J   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9rS rS rS rSS jrS r\	R6                  rSrg)IndexIVFIndependentQuantizeri5&  z
 An IVF index with a quantizer that has a different input dimension from the
payload size. The vectors to encode are obtained from the input vectors by a
VectorTransform.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   %IndexIVFIndependentQuantizer.<lambda><&  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r'  <&  rL   r$   rM   rN   z0quantizer is fed directly with the input vectorsz,transform before the IVF vectors are appliedz(the IVF index, controls nlist and nprobezwhether *this owns the 3 fieldsc                 T    [         R                  " U [         R                  " U6 5        g r/   )r   %IndexIVFIndependentQuantizer_swiginit new_IndexIVFIndependentQuantizerr   s     r   rV   %IndexIVFIndependentQuantizer.__init__C&  s    88z?j?jlp?qrr$   c                 0    [         R                  " XU5      $ r/   )r   "IndexIVFIndependentQuantizer_trainr>  s      r   r?  "IndexIVFIndependentQuantizer.trainF&  s    <<TaHHr$   c                 0    [         R                  " XU5      $ r/   )r    IndexIVFIndependentQuantizer_addr>  s      r   rH   IndexIVFIndependentQuantizer.addI&      ::4AFFr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   #IndexIVFIndependentQuantizer_searchr[  s          r   r]  #IndexIVFIndependentQuantizer.searchL&  s    ==dqY`fggr$   c                 .    [         R                  " U 5      $ r/   )r   "IndexIVFIndependentQuantizer_resetr[   s    r   r  "IndexIVFIndependentQuantizer.resetO&  r  r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   *IndexIVFIndependentQuantizer_quantizer_get*IndexIVFIndependentQuantizer_quantizer_setr  #IndexIVFIndependentQuantizer_vt_get#IndexIVFIndependentQuantizer_vt_setr  *IndexIVFIndependentQuantizer_index_ivf_get*IndexIVFIndependentQuantizer_index_ivf_set	index_ivf+IndexIVFIndependentQuantizer_own_fields_get+IndexIVFIndependentQuantizer_own_fields_setrR  rV   r?  rH  r]  r  #delete_IndexIVFIndependentQuantizerr   r>   r%   r$   r   r%  r%  5&  s     -/IOdeGHNNPZ  QF  QF  LC  DI	*@@*BpBp  wj  
kBNNPZ  QF  QF  L{  |I*PPR\  SI  SI  Ou  vJsIGhC!EEr$   r%  c                   $   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9rS
 rS rS rS rSS jrS rS rS r\	R6                  rSrg)IndexIVFPQFastScaniU&  a?  
 Fast scan version of IVFPQ. Works for 4-bit PQ for now.

The codes in the inverted lists are not stored sequentially but
grouped in blocks of size bbs. This makes it possible to very quickly
compute distances with SIMD instructions.

Implementations (implem):
0: auto-select implementation (default)
1: orig's search, re-implemented
2: orig's search, re-ordered by invlist
10: optimizer int16 search, collect results in heap, no qbs
11: idem, collect results in reservoir
12: optimizer int16 search, collect results in heap, uses qbs
13: idem, collect results in reservoir
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFPQFastScan.<lambda>g&  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rG  g&  rL   r$   rM   rN   r  zprecomputed tables managementz3if use_precompute_table size (nlist, pq.M, pq.ksub)c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexIVFPQFastScan_swiginitnew_IndexIVFPQFastScanr   s     r   rV   IndexIVFPQFastScan.__init__m&  r  r$   c                 0    [         R                  " XX#5      $ r/   )r    IndexIVFPQFastScan_train_encoderr  s       r   r   IndexIVFPQFastScan.train_encoderp&  s    ::4ANNr$   c                 .    [         R                  " U 5      $ r/   )r   ,IndexIVFPQFastScan_train_encoder_num_vectorsr[   s    r   r  ,IndexIVFPQFastScan.train_encoder_num_vectorss&  s    FFtLLr$   c                 .    [         R                  " U 5      $ )z@build precomputed table, possibly updating use_precomputed_table)r   #IndexIVFPQFastScan_precompute_tabler[   s    r   r  #IndexIVFPQFastScan.precompute_tablev&  r
  r$   c                 2    [         R                  " XX#XE5      $ )zY
same as the regular IVFPQ encoder. The codes are not reorganized by
blocks a that point
)r   !IndexIVFPQFastScan_encode_vectorsr  s         r   r  !IndexIVFPQFastScan.encode_vectorsz&  s    
 ;;DQRWhhr$   c                 .    [         R                  " U 5      $ r/   )r   %IndexIVFPQFastScan_lookup_table_is_3dr[   s    r   r@  %IndexIVFPQFastScan.lookup_table_is_3d&  r  r$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexIVFPQFastScan_compute_LUTrD  s          r   r5  IndexIVFPQFastScan.compute_LUT&  s    88!]deer$   c                 0    [         R                  " XX#5      $ r/   )r   *IndexIVFPQFastScan_get_InvertedListScanner)r   r  rT  arg4s       r   r
  *IndexIVFPQFastScan.get_InvertedListScanner&  s    DDTX[bbr$   r%   NrV  )r   r   r:   r;   r<   r   r   r   r   r   IndexIVFPQFastScan_pq_getIndexIVFPQFastScan_pq_setr  ,IndexIVFPQFastScan_use_precomputed_table_get,IndexIVFPQFastScan_use_precomputed_table_setr  (IndexIVFPQFastScan_precomputed_table_get(IndexIVFPQFastScan_precomputed_table_setr4  rV   r  r  r  r  r@  r5  r
  delete_IndexIVFPQFastScanr   r>   r%   r$   r   rE  rE  U&  s    " -/IOdeGH	*66
8\8\b{	|B$Z%\%\^h  _V  _V  \@  A !T!TV`  WJ  WJ  PJ  K_OMDiFfc!;;r$   rE  c                 2    [         R                  " XX#U5      $ )a  
 Functions to quantize PQ floating-point Look Up Tables (LUT) to uint8, and
biases to uint16. The accumulation is supposed to take place in uint16.
The quantization coefficients are float (a, b) such that

     original_value = quantized_value * a / b

The hardest part of the quantization is with multiple LUTs that need to be
added up together. In that case, coefficient a has to be chosen so that
the sum fits in a uint16 accumulator.
)r   round_uint8_per_column)r  ra   r  a_outb_outs        r   rk  rk  &  s     ,,SQuEEr$   c                 2    [         R                  " XX#XE5      $ r/   )r   round_uint8_per_column_multi)r  r  ra   r  rl  rm  s         r   ro  ro  &  s    2231NNr$   c                 8    [         R                  " XX#XEXgXU
5      $ )a  
 LUT quantization to uint8 and bias to uint16.

(nprobe, M, ksub, lut_is_3d) determine the size of the the LUT

 LUT input:
 - 2D size (M, ksub): single matrix per probe (lut_is_3d=false)
 - 3D size (nprobe, M, ksub): separate LUT per probe (lut_is_3d=true)
 bias input:
 - nullptr: bias is 0
 - size (nprobe): one bias per probe
 Output:
 - LUTq uint8 version of the LUT (M size is rounded up to M2)
 - biasq (or nullptr): uint16 version of the LUT
 - a, b: scalars to approximate the true distance
)r   quantize_LUT_and_bias)r  rX
  r  	lut_is_3dr2  biasLUTqr  biasqrl  rm  s              r   rq  rq  &  s"    " ++FtSW]bkpqqr$   c                 8    [         R                  " XX#XEXgXX5      $ r/   )r   aq_quantize_LUT_and_bias)r  rX
  r  r2  rs  M_normrd  rt  r  ru  rl  rm  s               r   rw  rw  &  s     ..v$TS]egpu}}r$   c                 0    [         R                  " XX#5      $ r/   )r   aq_estimate_norm_scale)rX
  r  rx  r2  s       r   rz  rz  &  s    ,,QfBBr$   c                   .   \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  SS9r\" \
R                  \
R                  S	S9r\" \
R"                  \
R$                  S
S9r\" \
R(                  \
R*                  SS9r\" \
R.                  \
R0                  SS9r\" \
R4                  \
R6                  SS9r\
R:                  rS rS r S r!S r"S r#S r$S$S jr%S$S jr&S$S jr'S%S jr(S r)S r*S r+S r,S$S jr-S r.S&S jr/S  r0S! r1S" r2S#r3g)'IndexBinaryi&  z
 Abstract structure for a binary index.

Supports adding vertices and searching them.

All queries are symmetric because there is no distinction between codes and
vectors.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinary.<lambda>&  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r~  &  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   IndexBinary.__init__&  rX   r$   r8  z&number of bytes per vector ( = d / 8 )r9  r:  zX
    set if the Index does not require training, or if training is done
    already
    r;  c                 0    [         R                  " XU5      $ )z
 Perform training on a representative set of vectors.

:type n: int
:param n:      nb of training vectors
:type x: uint8_t
:param x:      training vectors, size n * d / 8
)r   IndexBinary_trainr>  s      r   r?  IndexBinary.train&  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexBinary_train_exrC  s       r   rD  IndexBinary.train_ex&  s    ..tHHr$   c                 0    [         R                  " XU5      $ )z
 Add n vectors of dimension d to the index.

Vectors are implicitly assigned labels ntotal .. ntotal + n - 1
:type x: uint8_t
:param x:      input matrix, size n * d / 8
)r   IndexBinary_addr>  s      r   rH  IndexBinary.add&  s     ))$155r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexBinary_add_exrC  s       r   rL  IndexBinary.add_ex&  s    ,,TaFFr$   c                 0    [         R                  " XX#5      $ )z
 Same as add, but stores xids instead of sequential ids.

The default implementation fails with an assertion, as it is
not supported by all indexes.

:type xids: int
:param xids: if non-null, ids to store for the vectors (size n)
)r   IndexBinary_add_with_idsrP  s       r   rR  IndexBinary.add_with_ids&  s     224ADDr$   c                 2    [         R                  " XX#U5      $ r/   )r   IndexBinary_add_with_ids_exrV  s        r   rW  IndexBinary.add_with_ids_ex&      55dqPTUUr$   Nc           	      4    [         R                  " XX#XEU5      $ )a  
 Query n vectors of dimension d to the index.

return at most k vectors. If there are not enough results for a
query, the result array is padded with -1s.

:type x: uint8_t
:param x:           input vectors to search, size n * d / 8
:type labels: int
:param labels:      output labels of the NNs, size n*k
:type distances: int
:param distances:   output pairwise distances, size n*k
)r   IndexBinary_searchr[  s          r   r]  IndexBinary.search&  s     ,,TaIvVVr$   c           
      4    [         R                  " XX#XEXg5      $ r/   )r   IndexBinary_search_exra  s           r   rb  IndexBinary.search_ex'  s    //!X^ggr$   c                 2    [         R                  " XX#XE5      $ )a  
 Query n vectors of dimension d to the index.

return all vectors with distance < radius. Note that many indexes
do not implement the range_search (only the k-NN search is
mandatory). The distances are converted to float to reuse the
RangeSearchResult structure, but they are integer. By convention,
only distances < radius (strict comparison) are returned,
ie. radius = 0 does not return any result and 1 returns only
exact same vectors.

:type x: uint8_t
:param x:           input vectors to search, size n * d / 8
:type radius: int
:param radius:      search radius
:type result: :py:class:`RangeSearchResult`
:param result:      result table
)r   IndexBinary_range_searchrf  s         r   rg  IndexBinary.range_search'  s    & 224AvVVr$   c                 2    [         R                  " XX#U5      $ )a   
 Return the indexes of the k vectors closest to the query x.

This function is identical to search but only returns labels of
neighbors.
:type x: uint8_t
:param x:           input vectors to search, size n * d / 8
:type labels: int
:param labels:      output labels of the NNs, size n*k
)r   IndexBinary_assignrk  s        r   rl  IndexBinary.assign#'  s     ,,TaCCr$   c                 .    [         R                  " U 5      $ )z'Removes all elements from the database.)r   IndexBinary_resetr[   s    r   r  IndexBinary.reset0'  rh  r$   c                 .    [         R                  " X5      $ )z9Removes IDs from the index. Not supported by all indexes.)r   IndexBinary_remove_idsrs  s     r   rt  IndexBinary.remove_ids4'  s    00;;r$   c                 0    [         R                  " XU5      $ )z
 Reconstruct a stored vector.

This function may not be defined for some indexes.
:type key: int
:param key:         id of the vector to reconstruct
:type recons: uint8_t
:param recons:      reconstructed vector (size d / 8)
)r   IndexBinary_reconstructrx  s      r   r{  IndexBinary.reconstruct8'  s     11$VDDr$   c                 0    [         R                  " XX#5      $ )z
 Reconstruct vectors i0 to i0 + ni - 1.

This function may not be defined for some indexes.
:type recons: uint8_t
:param recons:      reconstructed vectors (size ni * d / 8)
)r   IndexBinary_reconstruct_nr  s       r   r  IndexBinary.reconstruct_nD'  s     33DbIIr$   c           
      4    [         R                  " XX#XEXg5      $ )a.  
 Similar to search, but also reconstructs the stored vectors (or an
approximation in the case of lossy coding) for the search results.

If there are not enough results for a query, the resulting array
is padded with -1s.

:type recons: uint8_t
:param recons:      reconstructed vectors size (n, k, d)
)r   "IndexBinary_search_and_reconstructr  s           r   r  "IndexBinary.search_and_reconstructN'  s     <<TaI_ennr$   c                 .    [         R                  " U 5      $ )z1Display the actual class name and some more info.)r   IndexBinary_displayr[   s    r   displayIndexBinary.display['  s    --d33r$   c                 0    [         R                  " XU5      $ r  )r   IndexBinary_merge_fromr  s      r   r  IndexBinary.merge_from_'  s     006JJr$   c                 .    [         R                  " X5      $ r  )r   &IndexBinary_check_compatible_for_merger  s     r   r  &IndexBinary.check_compatible_for_mergeh'  s     @@RRr$   c                 .    [         R                  " U 5      $ r  )r   IndexBinary_sa_code_sizer[   s    r   r  IndexBinary.sa_code_sizep'      22488r$   c                 0    [         R                  " XX#5      $ )z%Same as add_with_ids for IndexBinary.)r   IndexBinary_add_sa_codesr  s       r   r  IndexBinary.add_sa_codest'  s    224EHHr$   r%   r/   r   r  )4r   r   r:   r;   r<   r   r   rV   r   r   r   IndexBinary_d_getIndexBinary_d_setr  IndexBinary_code_size_getIndexBinary_code_size_setr  IndexBinary_ntotal_getIndexBinary_ntotal_setr  IndexBinary_verbose_getIndexBinary_verbose_setr  IndexBinary_is_trained_getIndexBinary_is_trained_setr  IndexBinary_metric_type_getIndexBinary_metric_type_setr   delete_IndexBinaryr   r?  rD  rH  rL  rR  rW  r]  rb  rg  rl  r  rt  r{  r  r  r  r  r  r  r  r>   r%   r$   r   r|  r|  &  sa    -/IOdeGKH--z/K/KQhiA==z?c?c  jW  XIj779Z9Z  aC  DFz99:;];]cyzG*??AfAf m 	J :AA:CiCi  p`  aK!44	8I6G
EVW hW*D2<
EJo4KS9Ir$   r|  c                   ^   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      rS	 rS
 rSS jrSS jrS rS rS r\	R:                  rSrg)IndexBinaryFlatiz'  zBIndex that stores the full vectors and performs exhaustive search.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryFlat.<lambda>}'  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  }'  rL   r$   rM   rN   z%database vectors, size ntotal * d / 8t
     Select between using a heap or counting to select the k smallest values
    when scanning inverted lists.
    c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryFlat_addr>  s      r   rH  IndexBinaryFlat.add'      --dq99r$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryFlat_resetr[   s    r   r  IndexBinaryFlat.reset'  rR  r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexBinaryFlat_searchr[  s          r   r]  IndexBinaryFlat.search'  r  r$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexBinaryFlat_range_searchrf  s         r   rg  IndexBinaryFlat.range_search'      66t6ZZr$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryFlat_reconstructrx  s      r   r{  IndexBinaryFlat.reconstruct'      55dHHr$   c                 .    [         R                  " X5      $ )z
 Remove some ids. Note that because of the indexing structure,
the semantics of this operation are different from the usual ones:
the new ids are shifted.
)r   IndexBinaryFlat_remove_idsrs  s     r   rt  IndexBinaryFlat.remove_ids'  s     44T??r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexBinaryFlat_swiginitnew_IndexBinaryFlatr   s     r   rV   IndexBinaryFlat.__init__'  r  r$   r%   r/   ) r   r   r:   r;   r<   r   r   r   r   r   IndexBinaryFlat_xb_getIndexBinaryFlat_xb_setr^  IndexBinaryFlat_use_heap_getIndexBinaryFlat_use_heap_setuse_heap$IndexBinaryFlat_query_batch_size_get$IndexBinaryFlat_query_batch_size_setquery_batch_size$IndexBinaryFlat_approx_topk_mode_get$IndexBinaryFlat_approx_topk_mode_setr:  rH  r  r]  rg  r{  rt  rV   delete_IndexBinaryFlatr   r>   r%   r$   r   r  r  z'  s    M-/IOdeGH	*33Z5V5V  ]I  
JB
??AhAh o 	H  
 O OQ[  RA  RA  B
 O OQ[  RA  RA  B:6[[I@Y!88r$   r  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  5      r\" \	R                   \	R"                  SS9r\" \	R&                  \	R(                  S	S9r\" \	R,                  \	R.                  S
S9r\" \	R2                  \	R4                  SS9r\" \	R8                  \	R:                  SS9r\" \	R>                  \	R@                  SS9r!\" \	RD                  \	RF                  SS9r$\" \	RJ                  \	RL                  SS9r'\" \	RP                  \	RR                  SS9r*\" \	RV                  \	RX                  SS9r-S r.\	R^                  r0S r1S r2S r3S r4S r5S*S jr6S+S jr7S*S jr8S*S jr9S r:S r;S r<S*S  jr=S! r>S" r?S# r@S$ rAS% rBS,S& jrCS' rDS+S( jrES)rFg)-IndexBinaryIVFi'  aC  
 Index based on a inverted file (IVF)

In the inverted file, the quantizer (an IndexBinary instance) provides a
quantization index for each vector to be added. The quantization
index maps to a list (aka inverted list or posting list), where the
id of the vector is stored.

Otherwise the object is similar to the IndexIVF
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryIVF.<lambda>'  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r  '  rL   r$   rM   rN   r  r  r  r  zcollect computations per batchz=map for direct access to the elements. Enables reconstruct().rm  r  rn  ro  rp  c                 T    [         R                  " U [         R                  " U6 5        g)z
 The Inverted file takes a quantizer (an IndexBinary) on input,
which implements the function mapping a vector to a list
identifier. The pointer is borrowed: the quantizer should not
be deleted while the IndexBinaryIVF is in use.
N)r   IndexBinaryIVF_swiginitnew_IndexBinaryIVFr   s     r   rV   IndexBinaryIVF.__init__'  s      	**41N1NPT1UVr$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryIVF_resetr[   s    r   r  IndexBinaryIVF.reset'  r]   r$   c                 0    [         R                  " XU5      $ )zTrains the quantizer)r   IndexBinaryIVF_trainr>  s      r   r?  IndexBinaryIVF.train'  r4  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryIVF_addr>  s      r   rH  IndexBinaryIVF.add'  r{  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexBinaryIVF_add_with_idsrP  s       r   rR  IndexBinaryIVF.add_with_ids'  rm  r$   c                 2    [         R                  " XX#U5      $ )z
 Implementation of vector addition where the vector assignments are
predefined.

:type precomputed_idx: int
:param precomputed_idx:    quantization indices for the input vectors
    (size n)
)r   IndexBinaryIVF_add_core)r   ra   rE   rQ  r  s        r   r  IndexBinaryIVF.add_core'  s     11$1OTTr$   Nc
                 6    [         R                  " XX#XEXgX5
      $ )a  
 Search a set of vectors, that are pre-quantized by the IVF
 quantizer. Fill in the corresponding heaps with the query
 results. search() calls this.

:type n: int
:param n:      nb of vectors to query
:type x: uint8_t
:param x:      query vectors, size nx * d
:type assign: int
:param assign: coarse quantization indices, size nx * nprobe
:type centroid_dis: int
:param centroid_dis:
                  distances to coarse centroids, size nx * nprobe
:param distance:
                  output distances, size n * k
:type labels: int
:param labels: output labels, size n * k
:type store_pairs: boolean
:param store_pairs: store inv list index + inv list offset
                        instead in upper/lower 32 bit of result,
                        instead of ids (used for reranking).
:type params: :py:class:`IVFSearchParameters`, optional
:param params: used to override the object's search parameters
)r   !IndexBinaryIVF_search_preassigned)
r   ra   rE   rQ  rl  r  rR  rS  r  r\  s
             r   r  !IndexBinaryIVF.search_preassigned'  s%    4 ;;DQ6ajt  I  	Ir$   c                 .    [         R                  " X5      $ r/   )r   &IndexBinaryIVF_get_InvertedListScanner)r   r  s     r   r
  &IndexBinaryIVF.get_InvertedListScanner (  s    @@SSr$   c           	      4    [         R                  " XX#XEU5      $ r   )r   IndexBinaryIVF_searchr[  s          r   r]  IndexBinaryIVF.search(  rY  r$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexBinaryIVF_range_searchrf  s         r   rg  IndexBinaryIVF.range_search(  r]  r$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   'IndexBinaryIVF_range_search_preassigned)r   ra   rE   rW  rl  r  rX  s          r   r  'IndexBinaryIVF.range_search_preassigned
(  s    AA$1V\lrssr$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryIVF_reconstructrx  s      r   r{  IndexBinaryIVF.reconstruct(  rH  r$   c                 0    [         R                  " XX#5      $ )ae  
 Reconstruct a subset of the indexed vectors.

Overrides default implementation to bypass reconstruct() which requires
direct_map to be maintained.

:type i0: int
:param i0:     first vector to reconstruct
:type ni: int
:param ni:     nb of vectors to reconstruct
:type recons: uint8_t
:param recons: output array of reconstructed vectors, size ni * d / 8
)r   IndexBinaryIVF_reconstruct_nr  s       r   r  IndexBinaryIVF.reconstruct_n(  s     66tLLr$   c           
      4    [         R                  " XX#XEXg5      $ )a  
 Similar to search, but also reconstructs the stored vectors (or an
approximation in the case of lossy coding) for the search results.

Overrides default implementation to avoid having to maintain direct_map
and instead fetch the code offsets through the `store_pairs` flag in
search_preassigned().

:type recons: uint8_t
:param recons:      reconstructed vectors size (n, k, d / 8)
)r   %IndexBinaryIVF_search_and_reconstructr  s           r   r  %IndexBinaryIVF.search_and_reconstruct (  s     ??ybhqqr$   c                 0    [         R                  " XX#5      $ r   )r   &IndexBinaryIVF_reconstruct_from_offsetr"  s       r   r#  &IndexBinaryIVF.reconstruct_from_offset.(  s     @@PV__r$   c                 .    [         R                  " X5      $ r&  )r   IndexBinaryIVF_remove_idsrs  s     r   rt  IndexBinaryIVF.remove_ids9(  s    33D>>r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryIVF_merge_from)r   r   r  s      r   r  IndexBinaryIVF.merge_from=(  s    33DHHr$   c                 .    [         R                  " X5      $ r/   )r   )IndexBinaryIVF_check_compatible_for_merger  s     r   r  )IndexBinaryIVF.check_compatible_for_merge@(  rf  r$   c                 .    [         R                  " X5      $ r/   )r   IndexBinaryIVF_get_list_sizer   s     r   r7  IndexBinaryIVF.get_list_sizeC(  r  r$   c                 .    [         R                  " X5      $ r>  )r   IndexBinaryIVF_make_direct_mapr@  s     r   rB  IndexBinaryIVF.make_direct_mapF(  s     88WWr$   c                 .    [         R                  " X5      $ r/   )r   "IndexBinaryIVF_set_direct_map_typerF  s     r   rG  "IndexBinaryIVF.set_direct_map_typeP(  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryIVF_replace_invlistsrL  s      r   rM  IndexBinaryIVF.replace_invlistsS(  s    99$CHHr$   r%   r/   rV  r!	  )Gr   r   r:   r;   r<   r   r   r   r   r   IndexBinaryIVF_invlists_getIndexBinaryIVF_invlists_setr   IndexBinaryIVF_own_invlists_getIndexBinaryIVF_own_invlists_setr[  IndexBinaryIVF_nprobe_getIndexBinaryIVF_nprobe_setr  IndexBinaryIVF_max_codes_getIndexBinaryIVF_max_codes_setr  IndexBinaryIVF_use_heap_getIndexBinaryIVF_use_heap_setr  %IndexBinaryIVF_per_invlist_search_get%IndexBinaryIVF_per_invlist_search_setper_invlist_searchIndexBinaryIVF_direct_map_getIndexBinaryIVF_direct_map_setrU  IndexBinaryIVF_quantizer_getIndexBinaryIVF_quantizer_setr  IndexBinaryIVF_nlist_getIndexBinaryIVF_nlist_setr#  IndexBinaryIVF_own_fields_getIndexBinaryIVF_own_fields_setrR  IndexBinaryIVF_cp_getIndexBinaryIVF_cp_setrq
  #IndexBinaryIVF_clustering_index_get#IndexBinaryIVF_clustering_index_setr  rV   delete_IndexBinaryIVFr   r  r?  rH  rR  r  r  r
  r]  rg  r  r{  r  r  r#  rt  r  r  r7  rB  rG  rM  r>   r%   r$   r   r  r  '  sG   	 -/IOdeGH
>>
@f@f  mM  NHJFF
HrHrsLj::J<`<`  gL  MF@@*BiBi  p]  ^I
>>
@f@f m 	H "*"R"RT^  UE  UE  Kp  q*BBJDlDl  sw  xJ@@*BiBi  pd  eIZ88*:]:]  dH  IE*BBJDlDl  s[  \J	*22J4T4T  [G  
HB
 N NPZP~P~  Et  uW "775;9H	UI8TZZtHM r	`?IVFXIIr$   r  c                   h    \ rS rSr\" S S SS9rS r\rS r	S r
S	 rS
 rS r\R                  rSrg)BinaryInvertedListScanneriX(  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   "BinaryInvertedListScanner.<lambda>Y(  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r]   Y(  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   "BinaryInvertedListScanner.__init__[(  rX   r$   c                 .    [         R                  " X5      $ rq  )r   #BinaryInvertedListScanner_set_queryrs  s     r   r  #BinaryInvertedListScanner.set_query_(  s    ==dQQr$   c                 0    [         R                  " XU5      $ rw  )r   "BinaryInvertedListScanner_set_listry  s      r   rz  "BinaryInvertedListScanner.set_listc(  s    <<TJWWr$   c                 .    [         R                  " X5      $ r}  )r   *BinaryInvertedListScanner_distance_to_coder  s     r   r  *BinaryInvertedListScanner.distance_to_codeg(  r  r$   c           	      4    [         R                  " XX#XEU5      $ )a  
 compute the distances to codes. (distances, labels) should be
organized as a min- or max-heap

:type n: int
:param n:      number of codes to scan
:type codes: uint8_t
:param codes:  codes to scan (n * code_size)
:type ids: int
:param ids:        corresponding ids (ignored if store_pairs)
:type distances: int
:param distances:  heap distances (size k)
:type labels: int
:param labels:     heap labels (size k)
:type k: int
:param k:          heap size
)r   $BinaryInvertedListScanner_scan_codesr  s          r   r  $BinaryInvertedListScanner.scan_codesk(  s    $ >>tT]ghiir$   c                 2    [         R                  " XX#XE5      $ r/   )r   *BinaryInvertedListScanner_scan_codes_ranger  s         r   r  *BinaryInvertedListScanner.scan_codes_range(  s    DDTeZ`iir$   r%   N)r   r   r:   r;   r   r   rV   r   r   r  rz  r  r  r  r    delete_BinaryInvertedListScannerr   r>   r%   r$   r   r[   r[   X(  sH    -/IOdeGKHRXQj(j!BBr$   r[   c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9rS r\	R"                  rS	 rS
 rSS jrS rSrg)IndexBinaryFromFloati(  z
 IndexBinary backed by a float Index.

Supports adding vertices and searching them.

All queries are symmetric because there is no distinction between codes and
vectors.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryFromFloat.<lambda>(  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rt   (  rL   r$   rM   rN   z&Whether object owns the index pointer.c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexBinaryFromFloat_swiginitnew_IndexBinaryFromFloatr   s     r   rV   IndexBinaryFromFloat.__init__(  rJ  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryFromFloat_addr>  s      r   rH  IndexBinaryFromFloat.add(  r	  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryFromFloat_resetr[   s    r   r  IndexBinaryFromFloat.reset(  r  r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexBinaryFromFloat_searchr[  s          r   r]  IndexBinaryFromFloat.search(  r'  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryFromFloat_trainr>  s      r   r?  IndexBinaryFromFloat.train(  rN  r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   IndexBinaryFromFloat_index_getIndexBinaryFromFloat_index_setr}	  #IndexBinaryFromFloat_own_fields_get#IndexBinaryFromFloat_own_fields_setrR  rV   delete_IndexBinaryFromFloatr   rH  r  r]  r?  r>   r%   r$   r   rr   rr   (  s     -/IOdeGHZ>>
@i@ijE*HH*JxJx  l  mJc!==?;`Ar$   rr   c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      r\" \	R,                  \	R.                  5      rS r\	R4                  rS rS	 rS
 rSS jrS r S r!Sr"g)IndexBinaryHNSWi(  r  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryHNSW.<lambda>(  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r   (  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexBinaryHNSW_swiginitnew_IndexBinaryHNSWr   s     r   rV   IndexBinaryHNSW.__init__(  r  r$   c                 .    [         R                  " U 5      $ r/   )r   %IndexBinaryHNSW_get_distance_computerr[   s    r   r  %IndexBinaryHNSW.get_distance_computer(  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryHNSW_addr>  s      r   rH  IndexBinaryHNSW.add(  r  r$   c                 0    [         R                  " XU5      $ r   )r   IndexBinaryHNSW_trainr>  s      r   r?  IndexBinaryHNSW.train(      //;;r$   Nc           	      4    [         R                  " XX#XEU5      $ r  )r   IndexBinaryHNSW_searchr[  s          r   r]  IndexBinaryHNSW.search(  rs  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryHNSW_reconstructrx  s      r   r{  IndexBinaryHNSW.reconstruct(  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryHNSW_resetr[   s    r   r  IndexBinaryHNSW.reset(  rR  r$   r%   r/   )#r   r   r:   r;   r<   r   r   r   r   r   IndexBinaryHNSW_hnsw_getIndexBinaryHNSW_hnsw_setr  IndexBinaryHNSW_own_fields_getIndexBinaryHNSW_own_fields_setrR  IndexBinaryHNSW_storage_getIndexBinaryHNSW_storage_setr:  IndexBinaryHNSW_init_level0_getIndexBinaryHNSW_init_level0_setr=  (IndexBinaryHNSW_keep_max_size_level0_get(IndexBinaryHNSW_keep_max_size_level0_setru  rV   delete_IndexBinaryHNSWr   r  rH  r?  r]  r{  r  r>   r%   r$   r   r   r   (  s    
 -/IOdeGHJ779\9\]D*CCZEnEnoJz==z?e?efG:EEzGqGqrK#J$W$WYc  ZM  ZM  NY!88F:<[I6r$   r   c                       \ rS rSr\" S S SS9r\rS r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9rS	 rSS jr\	R$                  rSrg
)IndexBinaryHNSWCagrai(  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryHNSWCagra.<lambda>(  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r   (  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexBinaryHNSWCagra_swiginitnew_IndexBinaryHNSWCagrar   s     r   rV   IndexBinaryHNSWCagra.__init__(  rJ  r$   a   
    When set to true, the index is immutable.
    This option is used to copy the knn graph from GpuIndexBinaryCagra
    to the base level of IndexBinaryHNSWCagra without adding upper levels.
    Doing so enables to search the HNSW index, but removes the
    ability to add vectors.
    r~  c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryHNSWCagra_addr>  s      r   rH  IndexBinaryHNSWCagra.add(  r	  r$   Nc           	      4    [         R                  " XX#XEU5      $ r  )r   IndexBinaryHNSWCagra_searchr[  s          r   r]  IndexBinaryHNSWCagra.search(  s    55dqYX^__r$   r%   r/   )r   r   r:   r;   r   r   r   r   rV   r   (IndexBinaryHNSWCagra_base_level_only_get(IndexBinaryHNSWCagra_base_level_only_setr  :IndexBinaryHNSWCagra_num_base_level_search_entrypoints_get:IndexBinaryHNSWCagra_num_base_level_search_entrypoints_setr  rH  r]  delete_IndexBinaryHNSWCagrar   r>   r%   r$   r   r   r   (  s    -/IOdeGHczRRT^  UH  UH N 	O )11v1v  yC  y~  y~ D )	%?` "==r$   r   c                   .   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      rS rS rS	 rS
 rSS jrSS jrS rS r\	R6                  rSrg)IndexBinaryHashi(  *just uses the b first bits as a hash valuec                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryHash.<lambda>(  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r   (  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexBinaryHash_swiginitnew_IndexBinaryHashr   s     r   rV   IndexBinaryHash.__init__(  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryHash_resetr[   s    r   r  IndexBinaryHash.reset(  rR  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryHash_addr>  s      r   rH  IndexBinaryHash.add(  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexBinaryHash_add_with_idsrP  s       r   rR  IndexBinaryHash.add_with_ids(  s    66tHHr$   Nc                 2    [         R                  " XX#XE5      $ r/   )r   IndexBinaryHash_range_searchrf  s         r   rg  IndexBinaryHash.range_search)  r  r$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexBinaryHash_searchr[  s          r   r]  IndexBinaryHash.search)  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryHash_displayr[   s    r   r  IndexBinaryHash.display)  r   r$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryHash_hashtable_sizer[   s    r   hashtable_sizeIndexBinaryHash.hashtable_size
)  r  r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   IndexBinaryHash_invlists_getIndexBinaryHash_invlists_setr   IndexBinaryHash_b_getIndexBinaryHash_b_setr  IndexBinaryHash_nflip_getIndexBinaryHash_nflip_setnfliprV   r  rH  rR  rg  r]  r  r   delete_IndexBinaryHashr   r>   r%   r$   r   r   r   (  s    5-/IOdeGH
??AhAhiH11:3S3STAZ99:;_;_`EY6:I[[8?!88r$   r   c                   8   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      rS rS r\R.                  rSrg	)
IndexBinaryHashStatsi)  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryHashStats.<lambda>)  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r   )  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   IndexBinaryHashStats_swiginitnew_IndexBinaryHashStatsr[   s    r   rV   IndexBinaryHashStats.__init__)  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryHashStats_resetr[   s    r   r  IndexBinaryHashStats.reset)  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   IndexBinaryHashStats_nq_getIndexBinaryHashStats_nq_setr  IndexBinaryHashStats_n0_getIndexBinaryHashStats_n0_setn0IndexBinaryHashStats_nlist_getIndexBinaryHashStats_nlist_setr#  IndexBinaryHashStats_ndis_getIndexBinaryHashStats_ndis_setr  rV   r  delete_IndexBinaryHashStatsr   r>   r%   r$   r   r   r   )  s    -/IOdeGH	*88*:`:`	aB	*88*:`:`	aBZ>>
@i@ijEJ<<j>f>fgD^;!==r$   r   c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  SS9r\" \	R,                  \	R.                  SS9r\" \	R2                  \	R4                  S	S9rS
 r\	R:                  rS rS r SS jr!SS jr"S r#Sr$g)IndexBinaryMultiHashi!)  r   c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryMultiHash.<lambda>$)  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r!  $)  rL   r$   rM   rN   znb of hash mapsznb bits per hash mapz"nb bit flips to use at search timec                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexBinaryMultiHash_swiginitnew_IndexBinaryMultiHashr   s     r   rV   IndexBinaryMultiHash.__init__-)  rJ  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryMultiHash_resetr[   s    r   r  IndexBinaryMultiHash.reset1)  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryMultiHash_addr>  s      r   rH  IndexBinaryMultiHash.add4)  r	  r$   Nc                 2    [         R                  " XX#XE5      $ r/   )r   !IndexBinaryMultiHash_range_searchrf  s         r   rg  !IndexBinaryMultiHash.range_search7)  s    ;;DQPV__r$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexBinaryMultiHash_searchr[  s          r   r]  IndexBinaryMultiHash.search:)  r'  r$   c                 .    [         R                  " U 5      $ r/   )r   #IndexBinaryMultiHash_hashtable_sizer[   s    r   r   #IndexBinaryMultiHash.hashtable_size=)  r/  r$   r%   r/   )%r   r   r:   r;   r<   r   r   r   r   r    IndexBinaryMultiHash_storage_get IndexBinaryMultiHash_storage_setr:  #IndexBinaryMultiHash_own_fields_get#IndexBinaryMultiHash_own_fields_setrR  IndexBinaryMultiHash_maps_getIndexBinaryMultiHash_maps_setmapsIndexBinaryMultiHash_nhash_getIndexBinaryMultiHash_nhash_setnhashIndexBinaryMultiHash_b_getIndexBinaryMultiHash_b_setr  IndexBinaryMultiHash_nflip_getIndexBinaryMultiHash_nflip_setr   rV   delete_IndexBinaryMultiHashr   r  rH  rg  r]  r   r>   r%   r$   r   r!  r!  !)  s    5-/IOdeGHzBBJDoDopG*HH*JxJxyJJ<<j>f>fgDZ>>
@i@i  pF  GE66
8]8]c~AZ>>
@i@i  pY  ZEc!==;?``Dr$   r!  c                       \ rS rSrSr\" S S SS9rS r\r	\
R                  rS rS	 rS
 rS rS rS r\" \
R&                  \
R(                  SS9rSrg)ThreadedIndexBaseiB)  f
A holder of indices in a collection of threads
The interface to this class itself is not thread safe
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ThreadedIndexBase.<lambda>H)  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r/!  H)  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   ThreadedIndexBase.__init__J)  rX   r$   c                 .    [         R                  " X5      $ z
override an index that is managed by ourselves.
WARNING: once an index is added, it becomes unsafe to touch it from any
other thread than that on which is managing it, until we are shut
down. Use runOnIndex to perform work on it instead.
)r   ThreadedIndexBase_addIndexr  s     r   addIndexThreadedIndexBase.addIndexO)  s     44TAAr$   c                 .    [         R                  " X5      $ z
Remove an index that is managed by ourselves.
This will flush all pending work on that index, and then shut
down its managing thread, and will remove the index.
)r   ThreadedIndexBase_removeIndexr  s     r   removeIndexThreadedIndexBase.removeIndexX)  s     77DDr$   c                 0    [         R                  " U /UQ76 $ z
Run a function on all indices, in the thread that the index is
managed in.
Function arguments are (index in collection, index pointer)
)r   ThreadedIndexBase_runOnIndexr   s     r   
runOnIndexThreadedIndexBase.runOnIndex`)  s     66tCdCCr$   c                 .    [         R                  " U 5      $ z4
faiss::Index API
All indices receive the same call
)r   ThreadedIndexBase_resetr[   s    r   r  ThreadedIndexBase.reseth)  s    
 11$77r$   c                 .    [         R                  " U 5      $ z!Returns the number of sub-indices)r   ThreadedIndexBase_countr[   s    r   r7  ThreadedIndexBase.counto)  s    11$77r$   c                 0    [         R                  " U /UQ76 $ zg
*Overload 1:*
Returns the i-th sub-index

|

*Overload 2:*
Returns the i-th sub-index (const version)
)r   ThreadedIndexBase_atr   s     r   r   ThreadedIndexBase.ats)  s     ..t;d;;r$   DWhether or not we are responsible for deleting our contained indicesr%   N)r   r   r:   r;   r<   r   r   rV   r   r   r   delete_ThreadedIndexBaser   r6!  r;!  r@!  r  r7  r   !ThreadedIndexBase_own_indices_get!ThreadedIndexBase_own_indices_setown_indicesr>   r%   r$   r   r,!  r,!  B)  sv    
 -/IOdeGKH!::BED88
< :GGIuIu  |G  HKr$   r,!  c                       \ rS rSrSr\" S S SS9rS r\r	\
R                  rS rS	 rS
 rS rS rS r\" \
R&                  \
R(                  SS9rSrg)ThreadedIndexBaseBinaryi)  r-!  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF    ThreadedIndexBaseBinary.<lambda>)  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rV!  )  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV    ThreadedIndexBaseBinary.__init__)  rX   r$   c                 .    [         R                  " X5      $ r4!  )r    ThreadedIndexBaseBinary_addIndexr  s     r   r6!   ThreadedIndexBaseBinary.addIndex)  s     ::4GGr$   c                 .    [         R                  " X5      $ r9!  )r   #ThreadedIndexBaseBinary_removeIndexr  s     r   r;!  #ThreadedIndexBaseBinary.removeIndex)  s     ==dJJr$   c                 0    [         R                  " U /UQ76 $ r>!  )r   "ThreadedIndexBaseBinary_runOnIndexr   s     r   r@!  "ThreadedIndexBaseBinary.runOnIndex)  s     <<TIDIIr$   c                 .    [         R                  " U 5      $ rC!  )r   ThreadedIndexBaseBinary_resetr[   s    r   r  ThreadedIndexBaseBinary.reset)  s    
 77==r$   c                 .    [         R                  " U 5      $ rG!  )r   ThreadedIndexBaseBinary_countr[   s    r   r7  ThreadedIndexBaseBinary.count)  r  r$   c                 0    [         R                  " U /UQ76 $ rK!  )r   ThreadedIndexBaseBinary_atr   s     r   r   ThreadedIndexBaseBinary.at)  s     44TADAAr$   rN!  r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r   delete_ThreadedIndexBaseBinaryr   r6!  r;!  r@!  r  r7  r   'ThreadedIndexBaseBinary_own_indices_get'ThreadedIndexBaseBinary_own_indices_setrR!  r>   r%   r$   r   rT!  rT!  )  s    
 -/IOdeGKH!@@HKJ>>
B :MMz  PB  PB  HS  TKr$   rT!  c                       \ rS rSrSr\" S S SS9r\rS r	S r
S	 rS
 rS rSS jrS r\" \R"                  \R$                  5      rS r\R*                  rSrg)IndexShardsi)  <Index that concatenates the results from several sub-indexesc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexShards.<lambda>)  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rs!  )  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        ga  
*Overload 1:*

The dimension that all sub-indices must share will be the dimension of
the first sub-index added

:type threaded: boolean, optional
:param threaded:     do we use one thread per sub_index or do
                        queries sequentially?
:type successive_ids: boolean, optional
:param successive_ids: should we shift the returned ids by
                        the size of each sub-index or return them
                        as they are?

|

*Overload 2:*

:type threaded: boolean, optional
:param threaded:     do we use one thread per sub_index or do
                        queries sequentially?
:type successive_ids: boolean, optional
:param successive_ids: should we shift the returned ids by
                        the size of each sub-index or return them
                        as they are?

|

*Overload 3:*

:type threaded: boolean, optional
:param threaded:     do we use one thread per sub_index or do
                        queries sequentially?
:param successive_ids: should we shift the returned ids by
                        the size of each sub-index or return them
                        as they are?

|

*Overload 4:*

:param threaded:     do we use one thread per sub_index or do
                        queries sequentially?
:param successive_ids: should we shift the returned ids by
                        the size of each sub-index or return them
                        as they are?

|

*Overload 5:*
 int version due to the implicit bool conversion ambiguity of int as
 dimension

|

*Overload 6:*
 int version due to the implicit bool conversion ambiguity of int as
 dimension

|

*Overload 7:*
 int version due to the implicit bool conversion ambiguity of int as
 dimension
N)r   IndexShards_swiginitnew_IndexShardsr   s     r   rV   IndexShards.__init__)  s     D 	''j.H.H$.OPr$   c                 .    [         R                  " X5      $ zAlias for addIndex())r   IndexShards_add_shardr  s     r   	add_shardIndexShards.add_shard*  s    //<<r$   c                 .    [         R                  " X5      $ zAlias for removeIndex())r   IndexShards_remove_shardr  s     r   remove_shardIndexShards.remove_shard*  s    224??r$   c                 0    [         R                  " XU5      $ z:supported only for sub-indices that implement add_with_ids)r   IndexShards_addr>  s      r   rH  IndexShards.add*  r  r$   c                 0    [         R                  " XX#5      $ a  
Cases (successive_ids, xids):
- true, non-NULL       ERROR: it makes no sense to pass in ids and
                       request them to be shifted
- true, NULL           OK: but should be called only once (calls add()
                       on sub-indexes).
- false, non-NULL      OK: will call add_with_ids with passed in xids
                       distributed evenly over shards
- false, NULL          OK: will call add_with_ids on each sub-index,
                       starting at ntotal
)r   IndexShards_add_with_idsrP  s       r   rR  IndexShards.add_with_ids*  s     224ADDr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexShards_searchr[  s          r   r]  IndexShards.search&*  rz  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexShards_trainr>  s      r   r?  IndexShards.train)*  rp  r$   c                 .    [         R                  " U 5      $ zL
Synchronize the top-level index (IndexShards) with data in the
sub-indices
)r   IndexShards_syncWithSubIndexesr[   s    r   syncWithSubIndexesIndexShards.syncWithSubIndexes-*  r	  r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   rV   r}!  r!  rH  rR  r]  r?  r   IndexShards_successive_ids_getIndexShards_successive_ids_setsuccessive_idsr!  delete_IndexShardsr   r>   r%   r$   r   rp!  rp!  )  so    G-/IOdeGHBQH=@6EW8jGGIrIrsN? "44r$   rp!  c                       \ rS rSrSr\" S S SS9r\rS r	S r
S	 rS
 rS rSS jrS r\" \R"                  \R$                  5      rS r\R*                  rSrg)IndexBinaryShardsi7*  rq!  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryShards.<lambda>:*  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r!  :*  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        grv!  )r   IndexBinaryShards_swiginitnew_IndexBinaryShardsr   s     r   rV   IndexBinaryShards.__init__=*  s!    D 	--dJ4T4TVZ4[\r$   c                 .    [         R                  " X5      $ r{!  )r   IndexBinaryShards_add_shardr  s     r   r}!  IndexBinaryShards.add_shard*  s    55dBBr$   c                 .    [         R                  " X5      $ r!  )r   IndexBinaryShards_remove_shardr  s     r   r!  IndexBinaryShards.remove_shard*      88EEr$   c                 0    [         R                  " XU5      $ r!  )r   IndexBinaryShards_addr>  s      r   rH  IndexBinaryShards.add*  r   r$   c                 0    [         R                  " XX#5      $ r!  )r   IndexBinaryShards_add_with_idsrP  s       r   rR  IndexBinaryShards.add_with_ids*  s     88!JJr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexBinaryShards_searchr[  s          r   r]  IndexBinaryShards.search*  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryShards_trainr>  s      r   r?  IndexBinaryShards.train*  r  r$   c                 .    [         R                  " U 5      $ r!  )r   $IndexBinaryShards_syncWithSubIndexesr[   s    r   r!  $IndexBinaryShards.syncWithSubIndexes*  s    
 >>tDDr$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   rV   r}!  r!  rH  rR  r]  r?  r   $IndexBinaryShards_successive_ids_get$IndexBinaryShards_successive_ids_setr!  r!  delete_IndexBinaryShardsr   r>   r%   r$   r   r!  r!  7*  sq    G-/IOdeGHB]HCF<K]>jMMzO~O~NE "::r$   r!  c                   n    \ rS rSrSr\" S S SS9r\rSS jr	S r
S	 rS
 rSS jr\R                  rSrg)IndexShardsIVFi*  z
IndexShards with a common coarse quantizer. All the indexes added should be
IndexIVFInterface indexes so that the search_precomputed can be called.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexShardsIVF.<lambda>*  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r!  *  rL   r$   rM   rN   c           	      \    [         R                  " U [         R                  " XX45      5        g r/   )r   IndexShardsIVF_swiginitnew_IndexShardsIVF)r   r  r#  threadedr!  s        r   rV   IndexShardsIVF.__init__*  s     **41N1Nyai1z{r$   c                 .    [         R                  " X5      $ r/   )r   IndexShardsIVF_addIndexr  s     r   r6!  IndexShardsIVF.addIndex*  s    11$>>r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexShardsIVF_add_with_idsrP  s       r   rR  IndexShardsIVF.add_with_ids*  rm  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexShardsIVF_trainr>  s      r   r?  IndexShardsIVF.train*      ..t::r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexShardsIVF_searchr[  s          r   r]  IndexShardsIVF.search*  s    //yRXYYr$   r%   )FTr/   )r   r   r:   r;   r<   r   r   r   r   rV   r6!  rR  r?  r]  r   delete_IndexShardsIVFr   r>   r%   r$   r   r!  r!  *  sG    
 -/IOdeGH|?H;Z!77r$   r!  c                   |    \ rS rSrSr\" S S SS9r\rS r	S r
S	 rS
 rS rSS jrS rS r\R$                  rSrg)IndexReplicasi*  
Takes individual faiss::Index instances, and splits queries for
sending to each Index instance, and joins the results together
when done.
Each index is managed by a separate CPU thread.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexReplicas.<lambda>*  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r!  *  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        ga  
*Overload 1:*
The dimension that all sub-indices must share will be the dimension of
the first sub-index added
:type threaded: boolean, optional
:param threaded: do we use one thread per sub-index or do queries
    sequentially?

|

*Overload 2:*
:type d: int
:param d: the dimension that all sub-indices must share
:type threaded: boolean, optional
:param threaded: do we use one thread per sub index or do queries
    sequentially?

|

*Overload 3:*
:type d: int
:param d: the dimension that all sub-indices must share
:param threaded: do we use one thread per sub index or do queries
    sequentially?

|

*Overload 4:*
int version due to the implicit bool conversion ambiguity of int as
dimension

|

*Overload 5:*
int version due to the implicit bool conversion ambiguity of int as
dimension
N)r   IndexReplicas_swiginitnew_IndexReplicasr   s     r   rV   IndexReplicas.__init__*  s     L 	))$
0L0Ld0STr$   c                 .    [         R                  " X5      $ r{!  )r   IndexReplicas_add_replicar  s     r   add_replicaIndexReplicas.add_replica*      33D@@r$   c                 .    [         R                  " X5      $ r!  )r   IndexReplicas_remove_replicar  s     r   remove_replicaIndexReplicas.remove_replica*  s    66tCCr$   c                 0    [         R                  " XU5      $ rC!  )r   IndexReplicas_trainr>  s      r   r?  IndexReplicas.train+  s    
 --dq99r$   c                 0    [         R                  " XU5      $ rC!  )r   IndexReplicas_addr>  s      r   rH  IndexReplicas.add	+  s    
 ++DQ77r$   Nc           	      4    [         R                  " XX#XEU5      $ zw
faiss::Index API
Query is partitioned into a slice for each sub-index
split by ceil(n / #indices) for our sub-indices
)r   IndexReplicas_searchr[  s          r   r]  IndexReplicas.search+  s     ..tiQWXXr$   c                 0    [         R                  " XU5      $ z!reconstructs from the first index)r   IndexReplicas_reconstructr   r   rK   s      r   r{  IndexReplicas.reconstruct+  s    33DBBr$   c                 .    [         R                  " U 5      $ r!  )r    IndexReplicas_syncWithSubIndexesr[   s    r   r!   IndexReplicas.syncWithSubIndexes+  s    
 ::4@@r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   rV   r!  r!  r?  rH  r]  r{  r!  r   delete_IndexReplicasr   r>   r%   r$   r   r!  r!  *  s\     -/IOdeGH&UPAD:8YCA "66r$   r!  c                   |    \ rS rSrSr\" S S SS9r\rS r	S r
S	 rS
 rS rSS jrS rS r\R$                  rSrg)IndexBinaryReplicasi&+  r!  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryReplicas.<lambda>.+  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r!  .+  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        gr!  )r   IndexBinaryReplicas_swiginitnew_IndexBinaryReplicasr   s     r   rV   IndexBinaryReplicas.__init__1+  s!    L 	//j6X6XZ^6_`r$   c                 .    [         R                  " X5      $ r{!  )r   IndexBinaryReplicas_add_replicar  s     r   r!  IndexBinaryReplicas.add_replicaY+  s    99$FFr$   c                 .    [         R                  " X5      $ r!  )r   "IndexBinaryReplicas_remove_replicar  s     r   r!  "IndexBinaryReplicas.remove_replica]+  s    <<TIIr$   c                 0    [         R                  " XU5      $ rC!  )r   IndexBinaryReplicas_trainr>  s      r   r?  IndexBinaryReplicas.traina+  s    
 33DQ??r$   c                 0    [         R                  " XU5      $ rC!  )r   IndexBinaryReplicas_addr>  s      r   rH  IndexBinaryReplicas.addh+  s    
 11$1==r$   Nc           	      4    [         R                  " XX#XEU5      $ r!  )r   IndexBinaryReplicas_searchr[  s          r   r]  IndexBinaryReplicas.searcho+  s     44TaIW]^^r$   c                 0    [         R                  " XU5      $ r!  )r   IndexBinaryReplicas_reconstructr!  s      r   r{  IndexBinaryReplicas.reconstructw+  s    99$aHHr$   c                 .    [         R                  " U 5      $ r!  )r   &IndexBinaryReplicas_syncWithSubIndexesr[   s    r   r!  &IndexBinaryReplicas.syncWithSubIndexes{+  s    
 @@FFr$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   rV   r!  r!  r?  rH  r]  r{  r!  r   delete_IndexBinaryReplicasr   r>   r%   r$   r   r!  r!  &+  s]     -/IOdeGH&aPGJ@>_IG "<<r$   r!  c                   b   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      rSS jrS rS	 rS
 rSS jrS rS r\	R:                  rSrg)IndexSplitVectorsi+  zt
 splits input vectors in segments and assigns each segment to a sub-index
used to distribute a MultiIndexQuantizer
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexSplitVectors.<lambda>+  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r"  +  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g)zsum of dimensions seen so farN)r   IndexSplitVectors_swiginitnew_IndexSplitVectors)r   r  r!  s      r   rV   IndexSplitVectors.__init__+  s    --dJ4T4TUV4abr$   c                 .    [         R                  " X5      $ r/   )r   IndexSplitVectors_add_sub_indexr   s     r   add_sub_indexIndexSplitVectors.add_sub_index+  r  r$   c                 .    [         R                  " U 5      $ r/   )r   'IndexSplitVectors_sync_with_sub_indexesr[   s    r   sync_with_sub_indexes'IndexSplitVectors.sync_with_sub_indexes+  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexSplitVectors_addr>  s      r   rH  IndexSplitVectors.add+  r  r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexSplitVectors_searchr[  s          r   r]  IndexSplitVectors.search+  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexSplitVectors_trainr>  s      r   r?  IndexSplitVectors.train+  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexSplitVectors_resetr[   s    r   r  IndexSplitVectors.reset+  r   r$   r%   rV  r/   ) r   r   r:   r;   r<   r   r   r   r   r    IndexSplitVectors_own_fields_get IndexSplitVectors_own_fields_setrR  IndexSplitVectors_threaded_getIndexSplitVectors_threaded_setr!  !IndexSplitVectors_sub_indexes_get!IndexSplitVectors_sub_indexes_setsub_indexesIndexSplitVectors_sum_d_getIndexSplitVectors_sum_d_setsum_drV   r&"  r*"  rH  r]  r?  r  delete_IndexSplitVectorsr   r>   r%   r$   r   r"  r"  +  s    
 -/IOdeGH*EEzGrGrsJ
AA:ClClmH:GGIuIuvKZ;;Z=c=cdEcFH<]>8!::r$   r"  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS rSS
 jrS rS r\	R$                  rSrg	)IndexRandomi+  zE
 index that returns random results.
used mainly for time benchmarks
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexRandom.<lambda>+  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rF"  +  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexRandom_swiginitnew_IndexRandomr   s     r   rV   IndexRandom.__init__+  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexRandom_addr>  s      r   rH  IndexRandom.add+  r	  r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexRandom_searchr[  s          r   r]  IndexRandom.search+  rz  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexRandom_reconstructrx  s      r   r{  IndexRandom.reconstruct+  r  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexRandom_resetr[   s    r   r  IndexRandom.reset+  r3  r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   IndexRandom_seed_getIndexRandom_seed_setr  rV   rH  r]  r{  r  delete_IndexRandomr   r>   r%   r$   r   rD"  rD"  +  s_    
 -/IOdeGHJ33Z5T5TUDQ6WE2!44r$   rD"  c                       \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  SS9r\" \
R                  \
R                  S	S9r\
R"                  rS
 rSS jrS rS rSrg)IndexRowwiseMinMaxBasei+  a  
 Index wrapper that performs rowwise normalization to [0,1], preserving
 the coefficients. This is a vector codec index only.

 Basically, this index performs a rowwise scaling to [0,1] of every row
 in an input dataset before calling subindex::train() and
 subindex::sa_encode(). sa_encode() call stores the scaling coefficients
  (scaler and minv) in the very beginning of every output code. The format:
     [scaler][minv][subindex::sa_encode() output]
 The de-scaling in sa_decode() is done using:
     output_rescaled = scaler * output + minv

 An additional ::train_inplace() function is provided in order to do
 an inplace scaling before calling subindex::train() and, thus, avoiding
 the cloning of the input dataset, but modifying the input dataset because
 of the scaling and the scaling back. It is up to user to call
 this function instead of ::train()

 Derived classes provide different data types for scaling coefficients.
 Currently, versions with fp16 and fp32 scaling coefficients are available.
fp16 version adds 4 extra bytes per encoded vector
fp32 version adds 8 extra bytes per encoded vector
 Provides base functions for rowwise normalizing indices.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexRowwiseMinMaxBase.<lambda>+  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r^"  +  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   IndexRowwiseMinMaxBase.__init__+  rX   r$   z	sub-indexz9whether the subindex needs to be freed in the destructor.c                 0    [         R                  " XU5      $ r/   )r   IndexRowwiseMinMaxBase_addr>  s      r   rH  IndexRowwiseMinMaxBase.add+  rN  r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexRowwiseMinMaxBase_searchr[  s          r   r]  IndexRowwiseMinMaxBase.search+  r:  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexRowwiseMinMaxBase_resetr[   s    r   r  IndexRowwiseMinMaxBase.reset+  r  r$   c                 0    [         R                  " XU5      $ r/   )r   $IndexRowwiseMinMaxBase_train_inplacer>  s      r   train_inplace$IndexRowwiseMinMaxBase.train_inplace+  rL  r$   r%   r/   )r   r   r:   r;   r<   r   r   rV   r   r   r    IndexRowwiseMinMaxBase_index_get IndexRowwiseMinMaxBase_index_setr}	  %IndexRowwiseMinMaxBase_own_fields_get%IndexRowwiseMinMaxBase_own_fields_setrR  delete_IndexRowwiseMinMaxBaser   rH  r]  r  rm"  r>   r%   r$   r   r\"  r\"  +  s    2 -/IOdeGKHZ@@*BmBm  tD  EE*JJJL|L|  CC  DJ!??Ab=Kr$   r\"  c                   l    \ rS rSrSr\" S S SS9r\rS r	S r
S	 rS
 rS rS r\R                   rSrg)IndexRowwiseMinMaxFP16i+  z+Stores scaling coefficients as fp16 values.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexRowwiseMinMaxFP16.<lambda>+  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rw"  +  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexRowwiseMinMaxFP16_swiginitnew_IndexRowwiseMinMaxFP16r   s     r   rV   IndexRowwiseMinMaxFP16.__init__+  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexRowwiseMinMaxFP16_trainr>  s      r   r?  IndexRowwiseMinMaxFP16.train,  rZ  r$   c                 0    [         R                  " XU5      $ r/   )r   $IndexRowwiseMinMaxFP16_train_inplacer>  s      r   rm"  $IndexRowwiseMinMaxFP16.train_inplace,  rL  r$   c                 .    [         R                  " U 5      $ r/   )r   #IndexRowwiseMinMaxFP16_sa_code_sizer[   s    r   r  #IndexRowwiseMinMaxFP16.sa_code_size,  r/  r$   c                 0    [         R                  " XX#5      $ r/   )r    IndexRowwiseMinMaxFP16_sa_encoder  s       r   r   IndexRowwiseMinMaxFP16.sa_encode
,  r>  r$   c                 0    [         R                  " XX#5      $ r/   )r    IndexRowwiseMinMaxFP16_sa_decoder  s       r   r   IndexRowwiseMinMaxFP16.sa_decode,  rB  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r?  rm"  r  r  r  r   delete_IndexRowwiseMinMaxFP16r   r>   r%   r$   r   ru"  ru"  +  sK    6-/IOdeGHgCKDNN!??r$   ru"  c                   l    \ rS rSrSr\" S S SS9r\rS r	S r
S	 rS
 rS rS r\R                   rSrg)IndexRowwiseMinMaxi,  z+Stores scaling coefficients as fp32 values.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexRowwiseMinMax.<lambda>,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r"  ,  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexRowwiseMinMax_swiginitnew_IndexRowwiseMinMaxr   s     r   rV   IndexRowwiseMinMax.__init__,  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexRowwiseMinMax_trainr>  s      r   r?  IndexRowwiseMinMax.train,  r	  r$   c                 0    [         R                  " XU5      $ r/   )r    IndexRowwiseMinMax_train_inplacer>  s      r   rm"   IndexRowwiseMinMax.train_inplace,  r3  r$   c                 .    [         R                  " U 5      $ r/   )r   IndexRowwiseMinMax_sa_code_sizer[   s    r   r  IndexRowwiseMinMax.sa_code_size",  r'  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexRowwiseMinMax_sa_encoder  s       r   r  IndexRowwiseMinMax.sa_encode%,  s    66tIIr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexRowwiseMinMax_sa_decoder  s       r   r  IndexRowwiseMinMax.sa_decode(,      66tIIr$   r%   N)r   r   r:   r;   r<   r   r   r   r   rV   r?  rm"  r  r  r  r   delete_IndexRowwiseMinMaxr   r>   r%   r$   r   r"  r"  ,  sJ    6-/IOdeGH_?G@JJ!;;r$   r"  c                   @   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      rSS jrS r\	R0                  rS	rg
)Lineari.,  z minimal translation of nn.Linearc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Linear.<lambda>1,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r"  1,  rL   r$   rM   rN   c                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   Linear_swiginit
new_Linear)r   in_featuresout_featuresrs  s       r   rV   Linear.__init__8,  s     ""4)>)>{Z^)_`r$   c                 .    [         R                  " X5      $ r/   )r   Linear___call__rk   s     r   r  Linear.__call__;,  r  r$   r%   Nr!	  )r   r   r:   r;   r<   r   r   r   r   r   Linear_in_features_getLinear_in_features_setr"  Linear_out_features_getLinear_out_features_setr"  Linear_weight_getLinear_weight_setweightLinear_bias_getLinear_bias_setrs  rV   r  delete_Linearr   r>   r%   r$   r   r"  r"  .,  s    +-/IOdeGH:<<j>_>_`KJ>>
@b@bcLj22J4P4PQFJ..
0J0JKDa3!//r$   r"  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      rS rS rS	 r\	R,                  rS
rg)	EmbeddingiA,  z#minimal translation of nn.Embeddingc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Embedding.<lambda>D,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r"  D,  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   Embedding_swiginitnew_Embedding)r   num_embeddingsembedding_dims      r   rV   Embedding.__init__J,  s    %%dJ,D,D^,cdr$   c                 .    [         R                  " X5      $ r/   )r   Embedding___call__r   s     r   r  Embedding.__call__M,      ,,T88r$   c                 0    [         R                  " U /UQ76 $ r/   )r   Embedding_datar   s     r   r   Embedding.dataP,  s    ((555r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   Embedding_num_embeddings_getEmbedding_num_embeddings_setr"  Embedding_embedding_dim_getEmbedding_embedding_dim_setr"  Embedding_weight_getEmbedding_weight_setr"  rV   r  r   delete_Embeddingr   r>   r%   r$   r   r"  r"  A,  s    .-/IOdeGHjEEzGnGnoNZCCZEkEklMj55z7V7VWFe96!22r$   r"  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS r\	R$                  rS	rg
)FFNiV,  z}
Feed forward layer that expands to a hidden dimension, applies a ReLU non
linearity and maps back to the original dimension
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   FFN.<lambda>\,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r"  \,  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   FFN_swiginitnew_FFN)r   r  r  s      r   rV   FFN.__init__a,  s    j&8&8&>?r$   c                 .    [         R                  " X5      $ r/   )r   FFN___call__rk   s     r   r  FFN.__call__d,      &&t//r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   FFN_linear1_getFFN_linear1_setlinear1FFN_linear2_getFFN_linear2_setlinear2rV   r  
delete_FFNr   r>   r%   r$   r   r"  r"  V,  sf    
 -/IOdeGHz11:3M3MNGz11:3M3MNG@0!,,r$   r"  c                      \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      rS r\" \R,                  \R.                  5      r\" \R2                  \R4                  5      r\" \R8                  \R:                  5      rS rSS
 jr S r!\RD                  r#Sr$g	)	QINCoStepij,  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   QINCoStep.<lambda>k,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r"  k,  rL   r$   rM   rN   zFd: input dim, K: codebook size, L: # of residual blocks, h: hidden dimc           	      \    [         R                  " U [         R                  " XX45      5        g r/   )r   QINCoStep_swiginitnew_QINCoStep)r   r  r  r  r  s        r   rV   QINCoStep.__init__r,  s    %%dJ,D,DQ1,PQr$   c                 .    [         R                  " X5      $ r/   )r   QINCoStep_get_residual_blockr  s     r   get_residual_blockQINCoStep.get_residual_blockx,  r  r$   Nc                 0    [         R                  " XX#5      $ )z}
 encode a set of vectors x with initial estimate xhat. Optionally return
the delta to be added to xhat to form the new xhat
)r   QINCoStep_encode)r   xhatrE   r  s       r   r
  QINCoStep.encode{,  s    
 **4qDDr$   c                 0    [         R                  " XU5      $ r/   )r   QINCoStep_decode)r   r"  r  s      r   r	  QINCoStep.decode,  s    **4u==r$   r%   r/   )%r   r   r:   r;   r   r   r   r   r   QINCoStep_d_getQINCoStep_d_setr  QINCoStep_K_getQINCoStep_K_setr  QINCoStep_L_getQINCoStep_L_setr  QINCoStep_h_getQINCoStep_h_setr  rV   QINCoStep_codebook_getQINCoStep_codebook_setcodebookQINCoStep_MLPconcat_getQINCoStep_MLPconcat_set	MLPconcatQINCoStep_residual_blocks_getQINCoStep_residual_blocks_setresidual_blocksr"  r
  r	  delete_QINCoStepr   r>   r%   r$   r   r"  r"  j,  s    -/IOdeGH++Z-G-G  N[  	\A++Z-G-GHA++Z-G-GHA++Z-G-GHAR
99:;\;\]H;;Z=_=_`IzGGIqIqrO@E>!22r$   r"  c                       \ rS rSr\" S S SS9rS r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS r\	R$                  rS	rg
)NeuralNetCodeci,  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   NeuralNetCodec.<lambda>,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r#  ,  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   NeuralNetCodec.__init__,  rX   r$   c                 .    [         R                  " X5      $ r/   )r   NeuralNetCodec_decoder   r  s     r   r	  NeuralNetCodec.decode,  s    //<<r$   c                 .    [         R                  " X5      $ r/   )r   NeuralNetCodec_encoderk   s     r   r
  NeuralNetCodec.encode,  r   r$   r%   N)r   r   r:   r;   r   r   rV   r   r   r   NeuralNetCodec_d_getNeuralNetCodec_d_setr  NeuralNetCodec_M_getNeuralNetCodec_M_setrX
  r	  r
  delete_NeuralNetCodecr   r>   r%   r$   r   r#  r#  ,  sd    -/IOdeGKH00*2Q2QRA00*2Q2QRA=9!77r$   r#  c                   ~   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      r\" \R*                  \R,                  5      rS rS rS rS	 r\R8                  rS
rg)QINCoi,  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   QINCo.<lambda>,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r(#  ,  rL   r$   rM   rN   c           
      ^    [         R                  " U [         R                  " XX4U5      5        g r/   )r   QINCo_swiginit	new_QINCo)r   r  r  r  rX
  r  s         r   rV   QINCo.__init__,  s!    !!$
(<(<Q1(KLr$   c                 .    [         R                  " X5      $ r/   )r   QINCo_get_stepr  s     r   get_stepQINCo.get_step,  r=  r$   c                 .    [         R                  " X5      $ r/   )r   QINCo_decoder#  s     r   r	  QINCo.decode,  s    &&t33r$   c                 .    [         R                  " X5      $ r/   )r   QINCo_encoderk   s     r   r
  QINCo.encode,  r"  r$   r%   N)r   r   r:   r;   r   r   r   r   r   QINCo_K_getQINCo_K_setr  QINCo_L_getQINCo_L_setr  QINCo_h_getQINCo_h_setr  QINCo_codebook0_getQINCo_codebook0_set	codebook0QINCo_steps_getQINCo_steps_setstepsrV   r0#  r	  r
  delete_QINCor   r>   r%   r$   r   r&#  r&#  ,  s    -/IOdeGH'')?)?@A'')?)?@A'')?)?@A779W9WXIZ//1K1KLEM240!..r$   r&#  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rSS jrS	 rS
 rS rS r\	R*                  rSrg)Tensor2Di,  ;Implements a few neural net layers, mainly to support QINCoc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Tensor2D.<lambda>,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rI#  ,  rL   r$   rM   rN   Nc                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   Tensor2D_swiginitnew_Tensor2Dr   r   r]  r   s       r   rV   Tensor2D.__init__,  s    $$T:+B+B24+PQr$   c                 .    [         R                  " X5      $ r/   )r   Tensor2D___iadd__r   s     r   r   Tensor2D.__iadd__,  s    ++D77r$   c                 .    [         R                  " X5      $ z$get column #j as a 1-column Tensor2D)r   Tensor2D_columnr   r  s     r   columnTensor2D.column,  s    ))$22r$   c                 .    [         R                  " U 5      $ r/   )r   Tensor2D_numelr[   s    r   numelTensor2D.numel,  r  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   Tensor2D_datar   s     r   r   Tensor2D.data,  s    ''4t44r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   Tensor2D_shape_getTensor2D_shape_setshapeTensor2D_v_getTensor2D_v_setrK   rV   r   rW#  r[#  r   delete_Tensor2Dr   r>   r%   r$   r   rF#  rF#  ,  sq    F-/IOdeGHZ22J4Q4QRE**J,E,EFAR83/5!11r$   rF#  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rSS jrS	 rS
 rS rS r\	R*                  rSrg)Int32Tensor2Di,  rG#  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Int32Tensor2D.<lambda>,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   ri#  ,  rL   r$   rM   rN   Nc                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   Int32Tensor2D_swiginitnew_Int32Tensor2DrN#  s       r   rV   Int32Tensor2D.__init__,  s     ))$
0L0LRUY0Z[r$   c                 .    [         R                  " X5      $ r/   )r   Int32Tensor2D___iadd__r   s     r   r   Int32Tensor2D.__iadd__,  r  r$   c                 .    [         R                  " X5      $ rT#  )r   Int32Tensor2D_columnrV#  s     r   rW#  Int32Tensor2D.column,  rY  r$   c                 .    [         R                  " U 5      $ r/   )r   Int32Tensor2D_numelr[   s    r   r[#  Int32Tensor2D.numel,  rw   r$   c                 0    [         R                  " U /UQ76 $ r/   )r   Int32Tensor2D_datar   s     r   r   Int32Tensor2D.data,  s    ,,T9D99r$   r%   r/   )r   r   r:   r;   r<   r   r   r   r   r   Int32Tensor2D_shape_getInt32Tensor2D_shape_setrb#  Int32Tensor2D_v_getInt32Tensor2D_v_setrK   rV   r   rW#  r[#  r   delete_Int32Tensor2Dr   r>   r%   r$   r   rg#  rg#  ,  sq    F-/IOdeGHZ779[9[\E//1O1OPA\=84:!66r$   rg#  c                   
   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      rS rS rS rS	 r\R,                  rS
rg)IndexNeuralNetCodeci,  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexNeuralNetCodec.<lambda>,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r#  ,  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexNeuralNetCodec_swiginitnew_IndexNeuralNetCodecr   s     r   rV   IndexNeuralNetCodec.__init__,      //j6X6XZ^6_`r$   c                 0    [         R                  " XU5      $ r/   )r   IndexNeuralNetCodec_trainr>  s      r   r?  IndexNeuralNetCodec.train,  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexNeuralNetCodec_sa_encode)r   ra   rE   r  s       r   r  IndexNeuralNetCodec.sa_encode,  s    77JJr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexNeuralNetCodec_sa_decoder  s       r   r  IndexNeuralNetCodec.sa_decode,      77JJr$   r%   N)r   r   r:   r;   r   r   r   r   r   IndexNeuralNetCodec_net_getIndexNeuralNetCodec_net_setnetIndexNeuralNetCodec_M_getIndexNeuralNetCodec_M_setrX
  IndexNeuralNetCodec_nbits_getIndexNeuralNetCodec_nbits_setr  rV   r?  r  r  delete_IndexNeuralNetCodecr   r>   r%   r$   r   r#  r#  ,  s    -/IOdeGH
:99:;a;a
bC55z7[7[\AZ==z?g?ghEa@KK!<<r$   r#  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS r\R                  rSrg)	
IndexQINCoi,  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexQINCo.<lambda>,  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r#  ,  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexQINCo_swiginitnew_IndexQINCor   s     r   rV   IndexQINCo.__init__-  rz	  r$   r%   N)r   r   r:   r;   r   r   r   r   r   IndexQINCo_qinco_getIndexQINCo_qinco_setqincorV   delete_IndexQINCor   r>   r%   r$   r   r#  r#  ,  sB    -/IOdeGHZ44j6U6UVEO!33r$   r#  c                   &   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      rS rS rS rS	 rS
 rS rS rSS jr\R4                  rSrg)RaBitQuantizeri	-  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   RaBitQuantizer.<lambda>
-  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r#  
-  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   RaBitQuantizer_swiginitnew_RaBitQuantizerr   s     r   rV   RaBitQuantizer.__init__-  r;  r$   c                 0    [         R                  " XU5      $ r/   )r    RaBitQuantizer_compute_code_size)r   r  num_bitss      r   compute_code_size RaBitQuantizer.compute_code_size-  s    ::4HMMr$   c                 0    [         R                  " XU5      $ r/   )r   RaBitQuantizer_trainr>  s      r   r?  RaBitQuantizer.train-  r!  r$   c                 0    [         R                  " XX#5      $ r/   )r   RaBitQuantizer_compute_codesr	  s       r   r	  RaBitQuantizer.compute_codes-  r"  r$   c                 2    [         R                  " XX#U5      $ r/   )r   !RaBitQuantizer_compute_codes_core)r   rE   r  ra   centroid_ins        r   compute_codes_core!RaBitQuantizer.compute_codes_core-  s    ;;DU{[[r$   c                 0    [         R                  " XX#5      $ r/   )r   RaBitQuantizer_decoder#  s       r   r	  RaBitQuantizer.decode-  s    //QBBr$   c                 2    [         R                  " XX#U5      $ r/   )r   RaBitQuantizer_decode_core)r   r  rE   ra   r#  s        r   decode_coreRaBitQuantizer.decode_core"-  s    44T!TTr$   Nc                 0    [         R                  " XX#5      $ r/   )r   $RaBitQuantizer_get_distance_computer)r   qbcentroidcentereds       r   r  $RaBitQuantizer.get_distance_computer%-  s    >>t\\r$   r%   )r   NF)r   r   r:   r;   r   r   r   r   r   RaBitQuantizer_centroid_getRaBitQuantizer_centroid_setr#  RaBitQuantizer_metric_type_getRaBitQuantizer_metric_type_setr   RaBitQuantizer_nb_bits_getRaBitQuantizer_nb_bits_setnb_bitsrV   r#  r?  r	  r#  r	  r#  r  delete_RaBitQuantizerr   r>   r%   r$   r   r#  r#  	-  s    -/IOdeGH
>>
@f@fgH:DDjFoFopKz<<j>c>cdGWN;J\CU]!77r$   r#  c                      \ rS rSr\" S S SS9rS r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      r\" \	R,                  \	R.                  5      rS rS rS	 rS
 rS r\	R<                  rSr g)RaBitQDistanceComputeri+-  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   RaBitQDistanceComputer.<lambda>,-  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r#  ,-  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   RaBitQDistanceComputer.__init__.-  rX   r$   c                 0    [         R                  " XU5      $ r/   )r   $RaBitQDistanceComputer_symmetric_disr  s      r   r  $RaBitQDistanceComputer.symmetric_dis7-  s    >>t4PPr$   c                 .    [         R                  " X5      $ r/   )r   ,RaBitQDistanceComputer_distance_to_code_1bitr  s     r   distance_to_code_1bit,RaBitQDistanceComputer.distance_to_code_1bit:-      FFtRRr$   c                 .    [         R                  " X5      $ r/   )r   ,RaBitQDistanceComputer_distance_to_code_fullr  s     r   distance_to_code_full,RaBitQDistanceComputer.distance_to_code_full=-  r#  r$   c                 .    [         R                  " X5      $ r/   )r   +RaBitQDistanceComputer_lower_bound_distancer  s     r   lower_bound_distance+RaBitQDistanceComputer.lower_bound_distance@-  s    EEdQQr$   c                 .    [         R                  " X5      $ r/   )r   'RaBitQDistanceComputer_distance_to_coder  s     r   r  'RaBitQDistanceComputer.distance_to_codeC-  r  r$   r%   N)!r   r   r:   r;   r   r   rV   r   r   r   RaBitQDistanceComputer_d_getRaBitQDistanceComputer_d_setr  #RaBitQDistanceComputer_centroid_get#RaBitQDistanceComputer_centroid_setr#  &RaBitQDistanceComputer_metric_type_get&RaBitQDistanceComputer_metric_type_setr   "RaBitQDistanceComputer_nb_bits_get"RaBitQDistanceComputer_nb_bits_setr#  "RaBitQDistanceComputer_g_error_get"RaBitQDistanceComputer_g_error_setg_errorr  r#  r#  r#  r  delete_RaBitQDistanceComputerr   r>   r%   r$   r   r#  r#  +-  s    -/IOdeGKH88*:a:abA
FF
HvHvwH:LLjNN  AKzDDjFsFstGzDDjFsFstGQSSRN!??r$   r#  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS r\	R"                  rSrg	)
BaseFactorsDataiI-  z
 Base factors computed per database vector for RaBitQ distance computation.
Used by both 1-bit and multi-bit RaBitQ variants.
These can be stored either embedded in codes (IndexRaBitQ) or separately
(IndexRaBitQFastScan).
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   BaseFactorsData.<lambda>Q-  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r $  Q-  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   BaseFactorsData_swiginitnew_BaseFactorsDatar[   s    r   rV   BaseFactorsData.__init__V-  rA  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   $BaseFactorsData_or_minus_c_l2sqr_get$BaseFactorsData_or_minus_c_l2sqr_setor_minus_c_l2sqr!BaseFactorsData_dp_multiplier_get!BaseFactorsData_dp_multiplier_setdp_multiplierrV   delete_BaseFactorsDatar   r>   r%   r$   r   r#  r#  I-  sn     -/IOdeGH
 O OQ[  RA  RA  BZII:KwKwxMT!88r$   r#  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS r\	R                  rSrg	)
FactorsDatai\-  z
 Extended factors for multi-bit RaBitQ (nb_bits > 1).
Includes error bound for lower bound computation in two-stage search.
Inherits base factors to maintain layout compatibility.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   FactorsData.<lambda>c-  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r$  c-  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   FactorsData_swiginitnew_FactorsDatar[   s    r   rV   FactorsData.__init__g-  r+  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   FactorsData_f_error_getFactorsData_f_error_setf_errorrV   delete_FactorsDatar   r>   r%   r$   r   r$  r$  \-  sI     -/IOdeGHz99:;];]^GL!44r$   r$  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS r\	R"                  rSrg	)
ExFactorsDataim-  z
 Additional factors for multi-bit RaBitQ (nb_bits > 1).
Used to store normalization and scaling factors for the extra bits
(ex_bits) that encode magnitude information beyond the sign bit.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ExFactorsData.<lambda>t-  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r$  t-  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   ExFactorsData_swiginitnew_ExFactorsDatar[   s    r   rV   ExFactorsData.__init__y-  r   r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   ExFactorsData_f_add_ex_getExFactorsData_f_add_ex_setf_add_exExFactorsData_f_rescale_ex_getExFactorsData_f_rescale_ex_setf_rescale_exrV   delete_ExFactorsDatar   r>   r%   r$   r   r$  r$  m-  sa     -/IOdeGH
==z?d?deHJEEzGpGpqLP!66r$   r$  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      r\" \	R&                  \	R(                  5      r\" \	R,                  \	R.                  5      r\" \	R2                  \	R4                  5      rS r\	R:                  rSrg	)
QueryFactorsDatai-  z
 Query-specific factors computed during search for RaBitQ distance
computation. Used by both IndexRaBitQ and IndexRaBitQFastScan
implementations.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   QueryFactorsData.<lambda>-  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r-$  -  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   QueryFactorsData_swiginitnew_QueryFactorsDatar[   s    r   rV   QueryFactorsData.__init__-  r-  r$   r%   N) r   r   r:   r;   r<   r   r   r   r   r   QueryFactorsData_c1_getQueryFactorsData_c1_setc1QueryFactorsData_c2_getQueryFactorsData_c2_setc2QueryFactorsData_c34_getQueryFactorsData_c34_setc34"QueryFactorsData_qr_to_c_L2sqr_get"QueryFactorsData_qr_to_c_L2sqr_setqr_to_c_L2sqr"QueryFactorsData_qr_norm_L2sqr_get"QueryFactorsData_qr_norm_L2sqr_setqr_norm_L2sqr"QueryFactorsData_int_dot_scale_get"QueryFactorsData_int_dot_scale_setint_dot_scalerV   delete_QueryFactorsDatar   r>   r%   r$   r   r+$  r+$  -  s     -/IOdeGH	*44j6X6X	YB	*44j6X6X	YB
:66
8[8[
\CZJJJLyLyzMZJJJLyLyzMZJJJLyLyzMV!99r$   r+$  c                 0    [         R                  " XX#5      $ )a(  
 Compute factors for a single database vector using RaBitQ algorithm.
This function consolidates the mathematical logic that was duplicated
between IndexRaBitQ and IndexRaBitQFastScan.

:type x: float
:param x:             input vector (d dimensions)
:type d: int
:param d:             dimensionality
:type centroid: float
:param centroid:      database centroid (nullptr if not used)
:type metric_type: int
:param metric_type:   distance metric (L2 or Inner Product)
:rtype: :py:class:`FactorsData`
:return: computed factors for distance computation
)r   compute_vector_factors)rE   r  r#  r   s       r   rG$  rG$  -  s    " ,,Q8IIr$   c                 2    [         R                  " XX#XE5      $ )aP  
 Compute intermediate values needed for vector factor computation.
Separated out to allow different bit packing strategies while sharing
the core mathematical computation.

:type x: float
:param x:             input vector (d dimensions)
:type d: int
:param d:             dimensionality
:type centroid: float
:param centroid:      database centroid (nullptr if not used)
:type norm_L2sqr: float
:param norm_L2sqr:    output: ||or - c||^2
:type or_L2sqr: float
:param or_L2sqr:      output: ||or||^2
:type dp_oO: float
:param dp_oO:         output: sum of |or_i - c_i| (absolute deviations)
)r   "compute_vector_intermediate_values)rE   r  r#  
norm_L2sqror_L2sqrdp_oOs         r   rI$  rI$  -  s    & 88xU]eer$   c                 2    [         R                  " XX#U5      $ )a  
 Compute final factors from intermediate values.
:type norm_L2sqr: float
:param norm_L2sqr:    ||or - c||^2
:type or_L2sqr: float
:param or_L2sqr:      ||or||^2
:type dp_oO: float
:param dp_oO:         sum of |or_i - c_i|
:type d: int
:param d:             dimensionality
:type metric_type: int
:param metric_type:   distance metric
:rtype: :py:class:`FactorsData`
:return: computed factors
)r   "compute_factors_from_intermediates)rJ$  rK$  rL$  r  r   s        r   rN$  rN$  -  s      88uYdeer$   c           
      4    [         R                  " XX#XEXg5      $ )a$  
 Compute query factors for RaBitQ distance computation.
This consolidates the query processing logic shared between implementations.

:type query: float
:param query:         query vector (d dimensions)
:type d: int
:param d:             dimensionality
:type centroid: float
:param centroid:      database centroid (nullptr if not used)
:type qb: uint8_t
:param qb:            number of quantization bits (1-8)
:type centered: boolean
:param centered:      whether to use centered quantization
:type metric_type: int
:param metric_type:   distance metric
:type rotated_q: std::vector< float >
:param rotated_q:     output: query - centroid
:type rotated_qq: std::vector< uint8_t >
:param rotated_qq:    output: quantized query values
:rtype: :py:class:`QueryFactorsData`
:return: computed query factors
)r   compute_query_factors)r  r  r#  r#  r#  r   	rotated_q
rotated_qqs           r   rP$  rP$  -  s    0 ++EhH[dqqr$   c                 .    [         R                  " X5      $ )a$  
 Extract bit value from RaBitQ code in standard format.
Used by IndexRaBitQ which stores bits sequentially.

:type code: uint8_t
:param code:          RaBitQ code data
:type bit_index: int
:param bit_index:     which bit to extract (0 to d-1)
:rtype: boolean
:return: bit value (true/false)
)r   extract_bit_standardr  	bit_indexs     r   rT$  rT$  -       **4;;r$   c                 .    [         R                  " X5      $ )a0  
 Extract bit value from FastScan code format.
Used by IndexRaBitQFastScan which packs bits into 4-bit sub-quantizers.

:type code: uint8_t
:param code:          FastScan code data
:type bit_index: int
:param bit_index:     which bit to extract (0 to d-1)
:rtype: boolean
:return: bit value (true/false)
)r   extract_bit_fastscanrU$  s     r   rY$  rY$  -  rW$  r$   c                 .    [         R                  " X5      $ )z
 Set bit value in standard RaBitQ code format.
:type code: uint8_t
:param code:          RaBitQ code data to modify
:type bit_index: int
:param bit_index:     which bit to set (0 to d-1)
)r   set_bit_standardrU$  s     r   r[$  r[$  .       &&t77r$   c                 .    [         R                  " X5      $ )z
 Set bit value in FastScan code format.
:type code: uint8_t
:param code:          FastScan code data to modify
:type bit_index: int
:param bit_index:     which bit to set (0 to d-1)
)r   set_bit_fastscanrU$  s     r   r^$  r^$  .  r\$  r$   c                 0    [         R                  " XU5      $ )a  
 Extract multi-bit code on-the-fly from packed ex-bit codes.
This inline function extracts a single code value without unpacking the
entire array, enabling efficient on-the-fly decoding during distance
computation.

:type ex_code: uint8_t
:param ex_code:       packed ex-bit codes
:type index: int
:param index:         which code to extract (0 to d-1)
:type ex_bits: int
:param ex_bits:       number of bits per code (1-8)
:rtype: int
:return: extracted code value in range [0, 2^ex_bits - 1]
)r   extract_code_inline)ex_coder}	  ex_bitss      r   r`$  r`$  .  s      ))''BBr$   c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS r\R                   rSrg)	RaBitQSearchParametersi+.  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   RaBitQSearchParameters.<lambda>,.  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rf$  ,.  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   RaBitQSearchParameters_swiginitnew_RaBitQSearchParametersr[   s    r   rV   RaBitQSearchParameters.__init__1.  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   RaBitQSearchParameters_qb_getRaBitQSearchParameters_qb_setr#  #RaBitQSearchParameters_centered_get#RaBitQSearchParameters_centered_setr#  rV   delete_RaBitQSearchParametersr   r>   r%   r$   r   rd$  rd$  +.  sZ    -/IOdeGH	*::J<d<d	eB
FF
HvHvwHb!??r$   rd$  c                   d   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      rS rS rS rS	 rS
 rS rSS jrSS jr\R:                  rSrg)IndexRaBitQi9.  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexRaBitQ.<lambda>:.  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rt$  :.  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexRaBitQ_swiginitnew_IndexRaBitQr   s     r   rV   IndexRaBitQ.__init__A.  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexRaBitQ_trainr>  s      r   r?  IndexRaBitQ.trainD.  rp  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexRaBitQ_sa_encoder  s       r   r  IndexRaBitQ.sa_encodeG.  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexRaBitQ_sa_decoder  s       r   r  IndexRaBitQ.sa_decodeJ.  r  r$   c                 .    [         R                  " U 5      $ r/   )r   )IndexRaBitQ_get_FlatCodesDistanceComputerr[   s    r   rQ  )IndexRaBitQ.get_FlatCodesDistanceComputerM.  r  r$   c                 0    [         R                  " XU5      $ r/   )r   +IndexRaBitQ_get_quantized_distance_computer)r   qb_inr#  s      r   get_quantized_distance_computer+IndexRaBitQ.get_quantized_distance_computerP.  s    EEdS[\\r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexRaBitQ_searchr[  s          r   r]  IndexRaBitQ.searchS.  rz  r$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexRaBitQ_range_searchrf  s         r   rg  IndexRaBitQ.range_searchV.  r~  r$   r%   r/   ) r   r   r:   r;   r   r   r   r   r   IndexRaBitQ_rabitq_getIndexRaBitQ_rabitq_setrabitqIndexRaBitQ_center_getIndexRaBitQ_center_setcenterIndexRaBitQ_qb_getIndexRaBitQ_qb_setr#  IndexRaBitQ_centered_getIndexRaBitQ_centered_setr#  rV   r?  r  r  rQ  r$  r]  rg  delete_IndexRaBitQr   r>   r%   r$   r   rr$  rr$  9.  s    -/IOdeGHj779Z9Z[Fj779Z9Z[F	*//1N1N	OB
;;Z=`=`aHQ8CCJ]WW!44r$   rr$  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  5      rS rS rS rS rS rS rSS jrS r \	RB                  r"Sr#g)IndexRaBitQFastScani\.  a  
 Fast-scan version of RaBitQ index that processes 32 database vectors at a
time using SIMD operations. Similar to IndexPQFastScan but adapted for
RaBitQ's bit-level quantization with factors.

The key differences from IndexRaBitQ:
- Processes vectors in batches of 32
- Uses 4-bit groupings for SIMD optimization (4 dimensions per 4-bit unit)
- Separates factors from quantized bits for efficient processing
- Leverages existing PQ4 FastScan infrastructure where possible
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexRaBitQFastScan.<lambda>i.  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r$  i.  rL   r$   rM   rN   z&RaBitQ quantizer for encoding/decodingz*Center of all points (same as IndexRaBitQ)v
    Extracted factors storage for batch processing
    Size: ntotal, stores factors separately from packed codes
    /Default number of bits to quantize a query withc                 T    [         R                  " U [         R                  " U6 5        g)zg
*Overload 1:*
build from an existing IndexRaBitQ

|

*Overload 2:*
build from an existing IndexRaBitQ
N)r   IndexRaBitQFastScan_swiginitnew_IndexRaBitQFastScanr   s     r   rV   IndexRaBitQFastScan.__init__t.  s      	//j6X6XZ^6_`r$   c                 0    [         R                  " XU5      $ r/   )r   IndexRaBitQFastScan_trainr>  s      r   r?  IndexRaBitQFastScan.train.  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexRaBitQFastScan_addr>  s      r   rH  IndexRaBitQFastScan.add.  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   !IndexRaBitQFastScan_compute_codesr  s       r   r	  !IndexRaBitQFastScan.compute_codes.  s    ;;DNNr$   c                 2    [         R                  " XX#U5      $ r/   )r   %IndexRaBitQFastScan_compute_float_LUTr  s        r   r  %IndexRaBitQFastScan.compute_float_LUT.  s    ??1QXYYr$   c                 0    [         R                  " XX#5      $ r/   )r   IndexRaBitQFastScan_sa_decoder  s       r   r  IndexRaBitQFastScan.sa_decode.  r#  r$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexRaBitQFastScan_searchr[  s          r   r]  IndexRaBitQFastScan.search.  r  r$   c
                 6    [         R                  " XX#XEXgX5
      $ z+Override to create RaBitQ-specific handlers)r   $IndexRaBitQFastScan_make_knn_handler)
r   r  r  ra   rQ  arg6rR  rS  rT  r  s
             r   r  $IndexRaBitQFastScan.make_knn_handler.  s    >>tTVW_hrur$   r%   r/   )$r   r   r:   r;   r<   r   r   r   r   r   IndexRaBitQFastScan_rabitq_getIndexRaBitQFastScan_rabitq_setr$  IndexRaBitQFastScan_center_getIndexRaBitQFastScan_center_setr$  'IndexRaBitQFastScan_factors_storage_get'IndexRaBitQFastScan_factors_storage_setfactors_storageIndexRaBitQFastScan_qb_getIndexRaBitQFastScan_qb_setr#   IndexRaBitQFastScan_centered_get IndexRaBitQFastScan_centered_setr#  rV   r?  rH  r	  r  r  r]  r  delete_IndexRaBitQFastScanr   r>   r%   r$   r   r$  r$  \.  s   
 -/IOdeGHj??AjAj  q^  _Fj??AjAj  qb  cFzQQS]  TF  TF L 	O 
*779^9^  e[  
\B
CCZEpEpqH
a@>OZK_@ "<<r$   r$  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS r\R                   rSrg)	IVFRaBitQSearchParametersi.  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   "IVFRaBitQSearchParameters.<lambda>.  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r$  .  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   "IVFRaBitQSearchParameters_swiginitnew_IVFRaBitQSearchParametersr[   s    r   rV   "IVFRaBitQSearchParameters.__init__.  s    55dJ<d<d<fgr$   r%   N)r   r   r:   r;   r   r   r   r   r    IVFRaBitQSearchParameters_qb_get IVFRaBitQSearchParameters_qb_setr#  &IVFRaBitQSearchParameters_centered_get&IVFRaBitQSearchParameters_centered_setr#  rV    delete_IVFRaBitQSearchParametersr   r>   r%   r$   r   r$  r$  .  sZ    -/IOdeGH	*==z?j?j	kB
II:K|K|}Hh!BBr$   r$  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS rS rSS jrS	 rSS jrS rS rS rS r\R0                  rSrg
)IndexIVFRaBitQi.  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFRaBitQ.<lambda>.  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r$  .  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexIVFRaBitQ_swiginitnew_IndexIVFRaBitQr   s     r   rV   IndexIVFRaBitQ.__init__.  r;  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexIVFRaBitQ_train_encoderr  s       r   r  IndexIVFRaBitQ.train_encoder.  s    66tJJr$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexIVFRaBitQ_encode_vectorsr  s         r   r  IndexIVFRaBitQ.encode_vectors.  s    77eeer$   c                 2    [         R                  " XX#U5      $ r/   )r   IndexIVFRaBitQ_decode_vectorsr  s        r   r  IndexIVFRaBitQ.decode_vectors.  s    77RSTTr$   Nc                 2    [         R                  " XX#XE5      $ r/   )r   IndexIVFRaBitQ_add_corer  s         r   r  IndexIVFRaBitQ.add_core.  s    11$1Okkr$   c                 0    [         R                  " XX#5      $ r/   )r   &IndexIVFRaBitQ_get_InvertedListScannerr	  s       r   r
  &IndexIVFRaBitQ.get_InvertedListScanner.  s    @@TW``r$   c                 0    [         R                  " XX#5      $ r/   )r   &IndexIVFRaBitQ_reconstruct_from_offsetr"  s       r   r#  &IndexIVFRaBitQ.reconstruct_from_offset.  s    @@PV__r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexIVFRaBitQ_sa_decoder  s       r   r  IndexIVFRaBitQ.sa_decode.  s    224EEEr$   c                 .    [         R                  " U 5      $ r/   )r   $IndexIVFRaBitQ_get_distance_computerr[   s    r   r  $IndexIVFRaBitQ.get_distance_computer.  r+  r$   r%   rV  r/   )r   r   r:   r;   r   r   r   r   r   IndexIVFRaBitQ_rabitq_getIndexIVFRaBitQ_rabitq_setr$  IndexIVFRaBitQ_qb_getIndexIVFRaBitQ_qb_setr#  rV   r  r  r  r  r
  r#  r  r  delete_IndexIVFRaBitQr   r>   r%   r$   r   r$  r$  .  s    -/IOdeGHj::J<`<`aF	*22J4T4T	UBWKfUla`FE!77r$   r$  c                   l   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  SS9r\" \	R&                  \	R(                  S	S9rS
 rS rSS jrS rS rS rS rSS jrSS jr\	R>                  r Sr!g)IndexIVFRaBitQFastScani.  a2  
 Fast-scan version of IndexIVFRaBitQ that processes vectors in batches
using SIMD operations. Combines the inverted file structure of IVF
with RaBitQ's bit-level quantization and FastScan's batch processing.

Key features:
- Inherits from IndexIVFFastScan for IVF structure and search algorithms
- Processes 32 database vectors at a time using SIMD
- Separates factors from quantized bits for efficient processing
- Supports both L2 and inner product metrics
- Maintains compatibility with existing IVF search parameters

Implementation details:
- Batch size (bbs) is typically 32 for optimal SIMD performance
- Factors are stored separately from packed codes for cache efficiency
- Query factors are computed once per search and reused across lists
- Uses specialized result handlers for RaBitQ distance corrections
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIVFRaBitQFastScan.<lambda>.  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r%  .  rL   r$   rM   rN   r$  z.Use zero-centered scalar quantizer for queriesr$  c                 T    [         R                  " U [         R                  " U6 5        g)zm
*Overload 1:*
Build from an existing IndexIVFRaBitQ

|

*Overload 2:*
Build from an existing IndexIVFRaBitQ
N)r   IndexIVFRaBitQFastScan_swiginitnew_IndexIVFRaBitQFastScanr   s     r   rV   IndexIVFRaBitQFastScan.__init__.  s      	2249^9^`d9efr$   c                 0    [         R                  " XX#5      $ r/   )r   $IndexIVFRaBitQFastScan_train_encoderr  s       r   r  $IndexIVFRaBitQFastScan.train_encoder.  s    >>tRRr$   c                 2    [         R                  " XX#XE5      $ r/   )r   %IndexIVFRaBitQFastScan_encode_vectorsr  s         r   r  %IndexIVFRaBitQFastScan.encode_vectors.  s    ??V[mmr$   c                 0    [         R                  " XX#5      $ )z1Reconstruct a single vector from an inverted list)r   .IndexIVFRaBitQFastScan_reconstruct_from_offsetr"  s       r   r#  .IndexIVFRaBitQFastScan.reconstruct_from_offset.  s    HHX^ggr$   c                 0    [         R                  " XX#5      $ )z2Override sa_decode to handle RaBitQ reconstruction)r    IndexIVFRaBitQFastScan_sa_decoder  s       r   r   IndexIVFRaBitQFastScan.sa_decode.  s    ::4EMMr$   c                 .    [         R                  " U 5      $ )z;Implementation methods for IVFRaBitQFastScan specialization)r   )IndexIVFRaBitQFastScan_lookup_table_is_3dr[   s    r   r@  )IndexIVFRaBitQFastScan.lookup_table_is_3d/  s    CCDIIr$   c           	      4    [         R                  " XX#XEU5      $ r/   )r   "IndexIVFRaBitQFastScan_compute_LUTrD  s          r   r5  "IndexIVFRaBitQFastScan.compute_LUT/  s    <<TaZahiir$   Nc                 8    [         R                  " XX#XEXgXU
5      $ r/   )r   )IndexIVFRaBitQFastScan_search_preassignedr  s              r   r  )IndexIVFRaBitQFastScan.search_preassigned/  s/    CCDQSYir  }H  RW  X  	Xr$   c
                 6    [         R                  " XX#XEXgX5
      $ r$  )r   'IndexIVFRaBitQFastScan_make_knn_handler)
r   r  r  ra   rQ  rR  rS  rT  r  r  s
             r   r  'IndexIVFRaBitQFastScan.make_knn_handler/  s%    AA$PTYZgmt{  J  	Jr$   r%   rV  r#  r/   )"r   r   r:   r;   r<   r   r   r   r   r   !IndexIVFRaBitQFastScan_rabitq_get!IndexIVFRaBitQFastScan_rabitq_setr$  IndexIVFRaBitQFastScan_qb_getIndexIVFRaBitQFastScan_qb_setr#  #IndexIVFRaBitQFastScan_centered_get#IndexIVFRaBitQFastScan_centered_setr#  *IndexIVFRaBitQFastScan_factors_storage_get*IndexIVFRaBitQFastScan_factors_storage_setr$  rV   r  r  r#  r  r@  r5  r  r  delete_IndexIVFRaBitQFastScanr   r>   r%   r$   r   r$  r$  .  s    & -/IOdeGHjBBJDpDpqF	*::J<d<d  ka  
bB
FF
HvHv  }r  sHzTTV`  WL  WL R 	O

gSnhNJjXJ "??r$   r$  c                   p   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9rSS jrS r\	R6                  rSrg)RangeSearchResulti/  z
The objective is to have a simple result structure while
minimizing the number of mem copies in the result. The method
do_allocation can be overloaded to allocate the result tables in
the matrix type of a scripting language like Lua or Python.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   RangeSearchResult.<lambda>/  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r+%  /  rL   r$   rM   rN   r  zsize (nq + 1)z/result for query i is labels[lims[i]:lims[i+1]]z$corresponding distances (not sorted)zsize of the result buffers usedc                 Z    [         R                  " U [         R                  " X5      5        g)z0lims must be allocated on input to range_search.N)r   RangeSearchResult_swiginitnew_RangeSearchResult)r   r  
alloc_limss      r   rV   RangeSearchResult.__init__"/  s    --dJ4T4TUW4der$   c                 .    [         R                  " U 5      $ )zL
called when lims contains the nb of elements result entries
for each query
)r   RangeSearchResult_do_allocationr[   s    r   do_allocationRangeSearchResult.do_allocation&/  s    
 99$??r$   r%   Nr!	  )r   r   r:   r;   r<   r   r   r   r   r   RangeSearchResult_nq_getRangeSearchResult_nq_setr  RangeSearchResult_lims_getRangeSearchResult_lims_setr  RangeSearchResult_labels_getRangeSearchResult_labels_setrS  RangeSearchResult_distances_getRangeSearchResult_distances_setrR  !RangeSearchResult_buffer_size_get!RangeSearchResult_buffer_size_setbuffer_sizerV   r4%  delete_RangeSearchResultr   r>   r%   r$   r   r)%  r)%  /  s     -/IOdeGH	*55z7Z7Z`t	uBJ99:;`;`fz{Dj==z?f?f  mc  dFCCZEoEo  va  bI:GGIuIu  |b  cKf@ "::r$   r)%  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  SS9rS r\	R(                  rS	 rS
 rS rSrg)
BufferListi0/  zi
List of temporary buffers used to store results before they are
copied to the RangeSearchResult object.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   BufferList.<lambda>6/  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rE%  6/  rL   r$   rM   rN   z!write pointer in the last buffer.c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   BufferList_swiginitnew_BufferList)r   r@%  s     r   rV   BufferList.__init__</  s    &&tZ-F-F{-STr$   c                 .    [         R                  " U 5      $ )zcreate a new buffer)r   BufferList_append_bufferr[   s    r   append_bufferBufferList.append_buffer@/  r  r$   c                 0    [         R                  " XU5      $ )z9add one result, possibly appending a new buffer if needed)r   BufferList_add)r   r<  rF  s      r   rH  BufferList.addD/  s    ((377r$   c                 2    [         R                  " XX#U5      $ )z[
copy elements ofs:ofs+n-1 seen as linear data in the buffers to
tables dest_ids, dest_dis
)r   BufferList_copy_range)r   r  ra   dest_idsdest_diss        r   
copy_rangeBufferList.copy_rangeH/  s    
 //1QQr$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   BufferList_buffer_size_getBufferList_buffer_size_setr@%  BufferList_buffers_getBufferList_buffers_setbuffersBufferList_wp_getBufferList_wp_setwprV   delete_BufferListr   rM%  rH  rV%  r>   r%   r$   r   rC%  rC%  0/  s    
 -/IOdeGH:@@*BgBghKz88*:[:[\G	*..
0L0LRz	{BU!3398Rr$   rC%  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  5      rS rS r\	R*                  rS	rg
)RangeQueryResultiQ/  z#result structure for a single queryc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   RangeQueryResult.<lambda>T/  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rd%  T/  rL   r$   rM   rN   c                 0    [         R                  " XU5      $ )z0called by search function to report a new result)r   RangeQueryResult_add)r   rF  r<  s      r   rH  RangeQueryResult.addZ/  s    ..t"==r$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   RangeQueryResult_swiginitnew_RangeQueryResultr[   s    r   rV   RangeQueryResult.__init__^/  r-  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   RangeQueryResult_qno_getRangeQueryResult_qno_setqnoRangeQueryResult_nres_getRangeQueryResult_nres_setnresRangeQueryResult_pres_getRangeQueryResult_pres_setpresrH  rV   delete_RangeQueryResultr   r>   r%   r$   r   rb%  rb%  Q/  sz    .-/IOdeGH
:66
8[8[
\CJ88*:^:^_DJ88*:^:^_D>V!99r$   rb%  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS r\" \	R                  \	R                  SS9rS	 rS
 rS rSS jr\SS j5       r\	R.                  rSrg)RangeSearchPartialResultid/  z.the entries in the buffers are split per queryc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   !RangeSearchPartialResult.<lambda>g/  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rz%  g/  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " U5      5        g)z.eventually the result will be stored in res_inN)r   !RangeSearchPartialResult_swiginitnew_RangeSearchPartialResult)r   res_ins     r   rV   !RangeSearchPartialResult.__init__k/  s    44T:;b;bci;jkr$   z$query ids + nb of results per query.c                 .    [         R                  " X5      $ )zbegin a new result)r   #RangeSearchPartialResult_new_result)r   ro%  s     r   
new_result#RangeSearchPartialResult.new_resultp/  r	  r$   c                 .    [         R                  " U 5      $ r/   )r   !RangeSearchPartialResult_finalizer[   s    r   finalize!RangeSearchPartialResult.finalizet/  rn  r$   c                 .    [         R                  " U 5      $ )z+called by range_search before do_allocation)r   !RangeSearchPartialResult_set_limsr[   s    r   set_lims!RangeSearchPartialResult.set_limsw/  r)  r$   c                 .    [         R                  " X5      $ )z*called by range_search after do_allocation)r   $RangeSearchPartialResult_copy_result)r   incrementals     r   copy_result$RangeSearchPartialResult.copy_result{/  s    >>tQQr$   c                 .    [         R                  " X5      $ )zc
merge a set of PartialResult's into one RangeSearchResult
on output the partialresults are empty!
)r   RangeSearchPartialResult_merge)partial_results	do_deletes     r   mergeRangeSearchPartialResult.merge/  s     88TTr$   r%   NrV  r!	  )r   r   r:   r;   r<   r   r   r   r   r    RangeSearchPartialResult_res_get RangeSearchPartialResult_res_setr=
  rV   $RangeSearchPartialResult_queries_get$RangeSearchPartialResult_queries_setqueriesr%  r%  r%  r%  r7  r%  delete_RangeSearchPartialResultr   r>   r%   r$   r   rx%  rx%  d/  s    9-/IOdeGH
:>>
@k@k
lCl zFF
HwHw  ~i  jGIBBR U U "AAr$   rx%  c                       \ rS rSr\" S S SS9rS r\rS r	\
R                  r\S 5       r\S	 5       r\S
 5       r\S 5       rSrg)InterruptCallbacki/  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   InterruptCallback.<lambda>/  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r%  /  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   InterruptCallback.__init__/  rX   r$   c                 .    [         R                  " U 5      $ r/   )r    InterruptCallback_want_interruptr[   s    r   want_interrupt InterruptCallback.want_interrupt/  rr  r$   c                  ,    [         R                  " 5       $ r/   )r    InterruptCallback_clear_instancer%   r$   r   clear_instance InterruptCallback.clear_instance/  s    ::<<r$   c                  ,    [         R                  " 5       $ )z
 check if:
- an interrupt callback is set
- the callback returns true
if this is the case, then throw an exception. Should not be called
from multiple threads.
)r   InterruptCallback_checkr%   r$   r   checkInterruptCallback.check/  s     1133r$   c                  ,    [         R                  " 5       $ )zm
same as check() but return true if is interrupted instead of
throwing. Can be called from multiple threads.
)r    InterruptCallback_is_interruptedr%   r$   r   is_interrupted InterruptCallback.is_interrupted/  s     ::<<r$   c                 .    [         R                  " U 5      $ )zr
 assuming each iteration takes a certain number of flops, what
is a reasonable interval to check for interrupts?
)r   !InterruptCallback_get_period_hint)flopss    r   get_period_hint!InterruptCallback.get_period_hint/  s     ;;EBBr$   r%   N)r   r   r:   r;   r   r   rV   r   r   r%  r   delete_InterruptCallbackr   r7  r%  r%  r%  r%  r>   r%   r$   r   r%  r%  /  s    -/IOdeGKHA!::= = 4 4 = = C Cr$   r%  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS rS r\S 5       rS	 r\R(                  rS
rg)TimeoutCallbacki/  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   TimeoutCallback.<lambda>/  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r%  /  rL   r$   rM   rN   c                 .    [         R                  " U 5      $ r/   )r   TimeoutCallback_want_interruptr[   s    r   r%  TimeoutCallback.want_interrupt/  r  r$   c                 .    [         R                  " X5      $ r/   )r   TimeoutCallback_set_timeout)r   timeout_in_secondss     r   set_timeoutTimeoutCallback.set_timeout/  s    55dOOr$   c                 .    [         R                  " U 5      $ r/   )r   TimeoutCallback_reset)r%  s    r   r  TimeoutCallback.reset/  s    //0BCCr$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   TimeoutCallback_swiginitnew_TimeoutCallbackr[   s    r   rV   TimeoutCallback.__init__/  rA  r$   r%   N)r   r   r:   r;   r   r   r   r   r   TimeoutCallback_start_getTimeoutCallback_start_setstartTimeoutCallback_timeout_getTimeoutCallback_timeout_settimeoutr%  r%  r7  r  rV   delete_TimeoutCallbackr   r>   r%   r$   r   r%  r%  /  s{    -/IOdeGHZ99:;_;_`Ez==z?e?efG?P D DT!88r$   r%  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS rS	 rS
 r\	R(                  rSrg)VisitedTablei/  z-set implementation optimized for fast access.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   VisitedTable.<lambda>/  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r%  /  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   VisitedTable_swiginitnew_VisitedTabler  s     r   rV   VisitedTable.__init__/  s    ((z/J/J4/PQr$   c                 .    [         R                  " X5      $ )zset flag #no to true)r   VisitedTable_setr   r)  s     r   r!   VisitedTable.set/      **444r$   c                 .    [         R                  " X5      $ )zget flag #no)r   VisitedTable_getr%  s     r   r  VisitedTable.get/  r%  r$   c                 .    [         R                  " U 5      $ )zreset all flags to false)r   VisitedTable_advancer[   s    r   r   VisitedTable.advance/  rA  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   VisitedTable_visited_getVisitedTable_visited_setvisitedVisitedTable_visno_getVisitedTable_visno_setvisnorV   r!   r  r   delete_VisitedTabler   r>   r%   r$   r   r%  r%  /  sn    8-/IOdeGHz::J<_<_`GZ66
8Y8YZER555 "55r$   r%  c                   T    \ rS rSrSr\" S S SS9rS r\r	S r
\R                  rS	rg
)
IDSelectori/  z$Encapsulates a set of ids to handle.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelector.<lambda>/  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r%  /  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   IDSelector.__init__/  rX   r$   c                 .    [         R                  " X5      $ r/   )r   IDSelector_is_memberr%  s     r   	is_memberIDSelector.is_member/  s    ..t88r$   r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r%  r   delete_IDSelectorr   r>   r%   r$   r   r%  r%  /  s2    /-/IOdeGKH9!33r$   r%  c                   
   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      r\" \	R                   \	R"                  SS9rSS jrS	 rS
 r\	R,                  rSrg)IDSelectorRangei/  zids between [imin, imax)c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelectorRange.<lambda>/  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r &  /  rL   r$   rM   rN   zb
    Assume that the ids to handle are sorted. In some cases this can speed
    up processing
    c                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   IDSelectorRange_swiginitnew_IDSelectorRange)r   iminimaxassume_sorteds       r   rV   IDSelectorRange.__init__0  s!    ++D*2P2PQU]j2klr$   c                 .    [         R                  " X5      $ r/   )r   IDSelectorRange_is_memberr%  s     r   r%  IDSelectorRange.is_member0      33D==r$   c                 2    [         R                  " XX#U5      $ )zO
for sorted ids, find the range of list indices where the valid ids are
stored
)r   &IDSelectorRange_find_sorted_ids_bounds)r   r  r  jminjmaxs        r   find_sorted_ids_bounds&IDSelectorRange.find_sorted_ids_bounds0  s    
 @@RU]abbr$   r%   NrV  )r   r   r:   r;   r<   r   r   r   r   r   IDSelectorRange_imin_getIDSelectorRange_imin_setr&  IDSelectorRange_imax_getIDSelectorRange_imax_setr&  !IDSelectorRange_assume_sorted_get!IDSelectorRange_assume_sorted_setr&  rV   r%  r&  delete_IDSelectorRanger   r>   r%   r$   r   r%  r%  /  s    #-/IOdeGHJ779\9\]DJ779\9\]DZII:KwKw ~ 	M
m>c "88r$   r%  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS r\	R$                  rS	rg
)IDSelectorArrayi0  zp
 Simple array of elements

is_member calls are very inefficient, but some operations can use the ids
directly.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelectorArray.<lambda>0  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r&  0  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g)z
 Construct with an array of ids to process

:type n: int
:param n: number of ids to store
:type ids: int
:param ids: elements to store. The pointer should remain valid during
               IDSelectorArray's lifetime
N)r   IDSelectorArray_swiginitnew_IDSelectorArray)r   ra   r  s      r   rV   IDSelectorArray.__init__0  s      	++D*2P2PQR2XYr$   c                 .    [         R                  " X5      $ r/   )r   IDSelectorArray_is_memberr%  s     r   r%  IDSelectorArray.is_member*0  r&  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IDSelectorArray_n_getIDSelectorArray_n_setra   IDSelectorArray_ids_getIDSelectorArray_ids_setr  rV   r%  delete_IDSelectorArrayr   r>   r%   r$   r   r&  r&  0  sf     -/IOdeGH11:3S3STA
:55z7Y7Y
ZC
Z>!88r$   r&  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS r\	R$                  rS	rg
)IDSelectorBatchi00  aj  
 Ids from a set.

Repetitions of ids in the indices set passed to the constructor does not hurt
performance.

The hash function used for the bloom filter and GCC's implementation of
unordered_set are just the least significant bits of the id. This works fine
for random ids or ids in sequences but will produce many hash collisions if
lsb's are always the same
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelectorBatch.<lambda>=0  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r.&  =0  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g)z
 Construct with an array of ids to process

:type n: int
:param n: number of ids to store
:param ids: elements to store. The pointer can be released after
               construction
N)r   IDSelectorBatch_swiginitnew_IDSelectorBatch)r   ra   r  s      r   rV   IDSelectorBatch.__init__B0  s      	++D*2P2PQR2\]r$   c                 .    [         R                  " X5      $ r/   )r   IDSelectorBatch_is_memberr%  s     r   r%  IDSelectorBatch.is_memberM0  r&  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IDSelectorBatch_nbits_getIDSelectorBatch_nbits_setr  IDSelectorBatch_mask_getIDSelectorBatch_mask_setr  rV   r%  delete_IDSelectorBatchr   r>   r%   r$   r   r,&  r,&  00  sf    
 -/IOdeGHZ99:;_;_`EJ779\9\]D	^>!88r$   r,&  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS r\	R$                  rS	rg
)IDSelectorBitmapiS0  zAOne bit per element. Constructed with a bitmap, size ceil(n / 8).c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelectorBitmap.<lambda>V0  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r?&  V0  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g)z
 Construct with a binary mask

:type n: int
:param n: size of the bitmap array
:type bitmap: uint8_t
:param bitmap: id will be selected iff id / 8 < n and bit number
                  (i%8) of bitmap[floor(i / 8)] is 1.
N)r   IDSelectorBitmap_swiginitnew_IDSelectorBitmap)r   ra   bitmaps      r   rV   IDSelectorBitmap.__init__[0  s      	,,T:3R3RST3]^r$   c                 .    [         R                  " X5      $ r/   )r   IDSelectorBitmap_is_memberr%  s     r   r%  IDSelectorBitmap.is_memberg0  s    44T>>r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IDSelectorBitmap_n_getIDSelectorBitmap_n_setra   IDSelectorBitmap_bitmap_getIDSelectorBitmap_bitmap_setrD&  rV   r%  delete_IDSelectorBitmapr   r>   r%   r$   r   r=&  r=&  S0  sb    L-/IOdeGH22J4U4UVAj<<j>d>deF
_?!99r$   r=&  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS r\	R                  rS	rg
)IDSelectorNotim0  z/reverts the membership test of another selectorc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelectorNot.<lambda>p0  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rQ&  p0  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   IDSelectorNot_swiginitnew_IDSelectorNotrs  s     r   rV   IDSelectorNot.__init__t0  s    ))$
0L0LS0QRr$   c                 .    [         R                  " X5      $ r/   )r   IDSelectorNot_is_memberr%  s     r   r%  IDSelectorNot.is_memberw0      11$;;r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IDSelectorNot_sel_getIDSelectorNot_sel_setrT  rV   r%  delete_IDSelectorNotr   r>   r%   r$   r   rO&  rO&  m0  sJ    :-/IOdeGH
:33Z5U5U
VCS<!66r$   rO&  c                   T    \ rS rSrSr\" S S SS9r\rS r	\
R                  rS rS	rg
)IDSelectorAlli}0  z-selects all entries (useful for benchmarking)c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelectorAll.<lambda>0  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   ra&  0  rL   r$   rM   rN   c                 .    [         R                  " X5      $ r/   )r   IDSelectorAll_is_memberr%  s     r   r%  IDSelectorAll.is_member0  rZ&  r$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   IDSelectorAll_swiginitnew_IDSelectorAllr[   s    r   rV   IDSelectorAll.__init__0  r   r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r%  r   delete_IDSelectorAllr   rV   r>   r%   r$   r   r_&  r_&  }0  s2    8-/IOdeGH<!66Pr$   r_&  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS r\	R$                  rS	rg
)IDSelectorAndi0  zP
does an AND operation on the the two given IDSelector's is_membership
results.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelectorAnd.<lambda>0  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rn&  0  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   IDSelectorAnd_swiginitnew_IDSelectorAndr   lhsrhss      r   rV   IDSelectorAnd.__init__0      ))$
0L0LS0VWr$   c                 .    [         R                  " X5      $ r/   )r   IDSelectorAnd_is_memberr%  s     r   r%  IDSelectorAnd.is_member0  rZ&  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IDSelectorAnd_lhs_getIDSelectorAnd_lhs_setrt&  IDSelectorAnd_rhs_getIDSelectorAnd_rhs_setru&  rV   r%  delete_IDSelectorAndr   r>   r%   r$   r   rl&  rl&  0  f    
 -/IOdeGH
:33Z5U5U
VC
:33Z5U5U
VCX<!66r$   rl&  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS r\	R$                  rS	rg
)IDSelectorOri0  zO
does an OR operation on the the two given IDSelector's is_membership
results.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelectorOr.<lambda>0  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r&  0  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   IDSelectorOr_swiginitnew_IDSelectorOrrs&  s      r   rV   IDSelectorOr.__init__0  s    ((z/J/J3/TUr$   c                 .    [         R                  " X5      $ r/   )r   IDSelectorOr_is_memberr%  s     r   r%  IDSelectorOr.is_member0  s    00::r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IDSelectorOr_lhs_getIDSelectorOr_lhs_setrt&  IDSelectorOr_rhs_getIDSelectorOr_rhs_setru&  rV   r%  delete_IDSelectorOrr   r>   r%   r$   r   r&  r&  0  sf    
 -/IOdeGH
:22J4S4S
TC
:22J4S4S
TCV;!55r$   r&  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS rS r\	R$                  rS	rg
)IDSelectorXOri0  zP
does an XOR operation on the the two given IDSelector's is_membership
results.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelectorXOr.<lambda>0  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r&  0  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   IDSelectorXOr_swiginitnew_IDSelectorXOrrs&  s      r   rV   IDSelectorXOr.__init__0  rw&  r$   c                 .    [         R                  " X5      $ r/   )r   IDSelectorXOr_is_memberr%  s     r   r%  IDSelectorXOr.is_member0  rZ&  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   IDSelectorXOr_lhs_getIDSelectorXOr_lhs_setrt&  IDSelectorXOr_rhs_getIDSelectorXOr_rhs_setru&  rV   r%  delete_IDSelectorXOrr   r>   r%   r$   r   r&  r&  0  r&  r$   r&  c                       \ rS rSr\" S S SS9r\r\" \R                  5      r
\" \R                  \R                  5      rS rS r\R                   rSrg	)
IDSelectorTranslatedi0  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IDSelectorTranslated.<lambda>0  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r&  0  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IDSelectorTranslated_swiginitnew_IDSelectorTranslatedr   s     r   rV   IDSelectorTranslated.__init__0  rJ  r$   c                 .    [         R                  " X5      $ r/   )r   IDSelectorTranslated_is_memberr%  s     r   r%  IDSelectorTranslated.is_member0      88BBr$   r%   N)r   r   r:   r;   r   r   r   r   r   IDSelectorTranslated_id_map_getr  IDSelectorTranslated_sel_getIDSelectorTranslated_sel_setrT  rV   r%  delete_IDSelectorTranslatedr   r>   r%   r$   r   r&  r&  0  sX    -/IOdeGHj@@AF
:::J<c<c
dCcC!==r$   r&  c                   b   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  SS9rS	 rS
 rS rS rSS jrSS jrS rS rS rS rSS jrSS jrS rS r S r!\	RD                  r#S r$Sr%g)
IndexIDMapi0  +Index that translates search results to idsc                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIDMap.<lambda>0  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r&  0  rL   r$   rM   rN   r  *whether pointers are deleted in destructorc                 0    [         R                  " XX#5      $ zQ
:type xids: int
:param xids: if non-null, ids to store for the vectors (size n)
)r   IndexIDMap_add_with_idsrP  s       r   rR  IndexIDMap.add_with_ids0  s    
 11$1CCr$   c                 2    [         R                  " XX#U5      $ r/   )r   IndexIDMap_add_with_ids_exrV  s        r   rW  IndexIDMap.add_with_ids_ex0  s    44TatTTr$   c                 0    [         R                  " XU5      $ z this will fail. Use add_with_ids)r   IndexIDMap_addr>  s      r   rH  IndexIDMap.add0  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexIDMap_add_exrC  s       r   rL  IndexIDMap.add_ex0  s    ++DQEEr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexIDMap_searchr[  s          r   r]  IndexIDMap.search0  s    ++DQ9fUUr$   c           
      4    [         R                  " XX#XEXg5      $ r/   )r   IndexIDMap_search_exra  s           r   rb  IndexIDMap.search_ex0  s    ..tW]ffr$   c                 0    [         R                  " XU5      $ r/   )r   IndexIDMap_trainr>  s      r   r?  IndexIDMap.train0  r`  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexIDMap_train_exrC  s       r   rD  IndexIDMap.train_ex0  s    --dqGGr$   c                 .    [         R                  " U 5      $ r/   )r   IndexIDMap_resetr[   s    r   r  IndexIDMap.reset0  r  r$   c                 .    [         R                  " X5      $ zremove ids adapted to IndexFlat)r   IndexIDMap_remove_idsrs  s     r   rt  IndexIDMap.remove_ids 1  s    //::r$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexIDMap_range_searchrf  s         r   rg  IndexIDMap.range_search1  s    11$1fUUr$   c                 0    [         R                  " XU5      $ r/   )r   IndexIDMap_merge_fromr  s      r   r  IndexIDMap.merge_from1  s    //&IIr$   c                 .    [         R                  " X5      $ r/   )r   %IndexIDMap_check_compatible_for_merger  s     r   r  %IndexIDMap.check_compatible_for_merge
1  s    ??QQr$   c                 .    [         R                  " U 5      $ r/   )r   IndexIDMap_sa_code_sizer[   s    r   r  IndexIDMap.sa_code_size1  r   r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexIDMap_add_sa_codesrP  s       r   r  IndexIDMap.add_sa_codes1  s    11$1CCr$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexIDMap_swiginitnew_IndexIDMapr   s     r   rV   IndexIDMap.__init__1  rz	  r$   r%   r/   r  )&r   r   r:   r;   r<   r   r   r   r   r   IndexIDMap_index_getIndexIDMap_index_setr}	  IndexIDMap_own_fields_getIndexIDMap_own_fields_setrR  IndexIDMap_id_map_getIndexIDMap_id_map_setr  rR  rW  rH  rL  r]  rb  r?  rD  r  rt  rg  r  r  r  r  delete_IndexIDMapr   rV   r>   r%   r$   r   r&  r&  0  s    6-/IOdeGHZ44j6U6UVE*>>
@d@dj~Jj66
8X8X  _P  QFDU5FVg7H1;VJR8D!33Or$   r&  c                   b   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  SS9rS	 rS
 rS rS rSS jrSS jrS rS rS rS rSS jrSS jrS rS r S r!\	RD                  r#S r$Sr%g)IndexBinaryIDMapi1  r&  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryIDMap.<lambda>1  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r&  1  rL   r$   rM   rN   r  r&  c                 0    [         R                  " XX#5      $ r&  )r   IndexBinaryIDMap_add_with_idsrP  s       r   rR  IndexBinaryIDMap.add_with_ids"1  s    
 77IIr$   c                 2    [         R                  " XX#U5      $ r/   )r    IndexBinaryIDMap_add_with_ids_exrV  s        r   rW   IndexBinaryIDMap.add_with_ids_ex)1  s    ::4AUYZZr$   c                 0    [         R                  " XU5      $ r&  )r   IndexBinaryIDMap_addr>  s      r   rH  IndexBinaryIDMap.add,1  r4  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexBinaryIDMap_add_exrC  s       r   rL  IndexBinaryIDMap.add_ex01  s    11$1KKr$   Nc           	      4    [         R                  " XX#XEU5      $ r/   )r   IndexBinaryIDMap_searchr[  s          r   r]  IndexBinaryIDMap.search31  s    11$1TZ[[r$   c           
      4    [         R                  " XX#XEXg5      $ r/   )r   IndexBinaryIDMap_search_exra  s           r   rb  IndexBinaryIDMap.search_ex61  s    44Taq]cllr$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryIDMap_trainr>  s      r   r?  IndexBinaryIDMap.train91  r
  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexBinaryIDMap_train_exrC  s       r   rD  IndexBinaryIDMap.train_ex<1  s    33DQMMr$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryIDMap_resetr[   s    r   r  IndexBinaryIDMap.reset?1  rB  r$   c                 .    [         R                  " X5      $ r&  )r   IndexBinaryIDMap_remove_idsrs  s     r   rt  IndexBinaryIDMap.remove_idsB1      55d@@r$   c                 2    [         R                  " XX#XE5      $ r/   )r   IndexBinaryIDMap_range_searchrf  s         r   rg  IndexBinaryIDMap.range_searchF1  s    77F[[r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryIDMap_merge_fromr  s      r   r  IndexBinaryIDMap.merge_fromI1  s    55dOOr$   c                 .    [         R                  " X5      $ r/   )r   +IndexBinaryIDMap_check_compatible_for_merger  s     r   r  +IndexBinaryIDMap.check_compatible_for_mergeL1  s    EEdWWr$   c                 .    [         R                  " U 5      $ r/   )r   IndexBinaryIDMap_sa_code_sizer[   s    r   r  IndexBinaryIDMap.sa_code_sizeO1  rb  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexBinaryIDMap_add_sa_codesrP  s       r   r  IndexBinaryIDMap.add_sa_codesR1  s    77IIr$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexBinaryIDMap_swiginitnew_IndexBinaryIDMapr   s     r   rV   IndexBinaryIDMap.__init__V1  r  r$   r%   r/   r  )&r   r   r:   r;   r<   r   r   r   r   r   IndexBinaryIDMap_index_getIndexBinaryIDMap_index_setr}	  IndexBinaryIDMap_own_fields_getIndexBinaryIDMap_own_fields_setrR  IndexBinaryIDMap_id_map_getIndexBinaryIDMap_id_map_setr  rR  rW  rH  rL  r]  rb  r?  rD  r  rt  rg  r  r  r  r  delete_IndexBinaryIDMapr   rV   r>   r%   r$   r   r&  r&  1  s    6-/IOdeGHZ::J<a<abE*DDjFpFp  wK  LJj<<j>d>d  k\  ]FJ[;L\m=N7A\PX>J!99[r$   r&  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS rS	 rS
 rS rS rSS jr\	R(                  rS rSrg)IndexIDMap2i[1  c
same as IndexIDMap but also provides an efficient reconstruction
implementation via a 2-way index
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexIDMap2.<lambda>a1  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r8'  a1  rL   r$   rM   rN   c                 .    [         R                  " U 5      $ zmake the rev_map from scratch)r   IndexIDMap2_construct_rev_mapr[   s    r   construct_rev_mapIndexIDMap2.construct_rev_mape1  r  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexIDMap2_add_with_idsrP  s       r   rR  IndexIDMap2.add_with_idsi1  rf  r$   c                 2    [         R                  " XX#U5      $ r/   )r   IndexIDMap2_add_with_ids_exrV  s        r   rW  IndexIDMap2.add_with_ids_exl1  r  r$   c                 .    [         R                  " X5      $ r/   )r   IndexIDMap2_remove_idsrs  s     r   rt  IndexIDMap2.remove_idso1  r\  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexIDMap2_reconstructrx  s      r   r{  IndexIDMap2.reconstructr1  r  r$   c                 .    [         R                  " U 5      $ z1check that the rev_map and the id_map are in sync)r   IndexIDMap2_check_consistencyr[   s    r   check_consistencyIndexIDMap2.check_consistencyu1  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexIDMap2_merge_fromr  s      r   r  IndexIDMap2.merge_fromy1  rp  r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexIDMap2_swiginitnew_IndexIDMap2r   s     r   rV   IndexIDMap2.__init__}1  r  r$   r%   Nr  )r   r   r:   r;   r<   r   r   r   r   r   IndexIDMap2_rev_map_getIndexIDMap2_rev_map_setrev_mapr='  rR  rW  rt  r{  rN'  r  delete_IndexIDMap2r   rV   r>   r%   r$   r   r5'  r5'  [1  sp    
 -/IOdeGHz99:;];]^G>EV<E>K!44Qr$   r5'  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      rS rS rS	 rS
 rS rS rSS jr\	R(                  rS rSrg)IndexBinaryIDMap2i1  r6'  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IndexBinaryIDMap2.<lambda>1  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r^'  1  rL   r$   rM   rN   c                 .    [         R                  " U 5      $ r;'  )r   #IndexBinaryIDMap2_construct_rev_mapr[   s    r   r='  #IndexBinaryIDMap2.construct_rev_map1  r
  r$   c                 0    [         R                  " XX#5      $ r/   )r   IndexBinaryIDMap2_add_with_idsrP  s       r   rR  IndexBinaryIDMap2.add_with_ids1  r  r$   c                 2    [         R                  " XX#U5      $ r/   )r   !IndexBinaryIDMap2_add_with_ids_exrV  s        r   rW  !IndexBinaryIDMap2.add_with_ids_ex1  s    ;;DQVZ[[r$   c                 .    [         R                  " X5      $ r/   )r   IndexBinaryIDMap2_remove_idsrs  s     r   rt  IndexBinaryIDMap2.remove_ids1  r  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryIDMap2_reconstructrx  s      r   r{  IndexBinaryIDMap2.reconstruct1  r  r$   c                 .    [         R                  " U 5      $ rL'  )r   #IndexBinaryIDMap2_check_consistencyr[   s    r   rN'  #IndexBinaryIDMap2.check_consistency1  r
  r$   c                 0    [         R                  " XU5      $ r/   )r   IndexBinaryIDMap2_merge_fromr  s      r   r  IndexBinaryIDMap2.merge_from1  r  r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   IndexBinaryIDMap2_swiginitnew_IndexBinaryIDMap2r   s     r   rV   IndexBinaryIDMap2.__init__1  r  r$   r%   Nr  )r   r   r:   r;   r<   r   r   r   r   r   IndexBinaryIDMap2_rev_map_getIndexBinaryIDMap2_rev_map_setrY'  r='  rR  rW  rt  r{  rN'  r  delete_IndexBinaryIDMap2r   rV   r>   r%   r$   r   r\'  r\'  1  ss    
 -/IOdeGHz??AiAijGDK\BKDQ!::]r$   r\'  c                 .    [         R                  " U 5      $ r/   )r   downcast_indexr}	  s    r   r}'  r}'  1  s    $$U++r$   c                 .    [         R                  " U 5      $ r/   )r   downcast_VectorTransform)r  s    r   r'  r'  1  s    ..r22r$   c                 .    [         R                  " U 5      $ r/   )r   downcast_IndexBinaryr~'  s    r   r'  r'  1  s    **511r$   c                 .    [         R                  " U 5      $ r/   )r   downcast_InvertedLists)r  s    r   r'  r'  1  s    ,,R00r$   c                 .    [         R                  " U 5      $ r/   )r   downcast_AdditiveQuantizerrI  s    r   r'  r'  1  s    0044r$   c                 .    [         R                  " U 5      $ r/   )r   downcast_Quantizerr'  s    r   r'  r'  1  s    ((,,r$   c                  (    [         R                  " U 6 $ r/   )r   write_indexrI  s    r   r'  r'  1  s    !!4((r$   c                  (    [         R                  " U 6 $ r/   )r   write_index_binaryrI  s    r   r'  r'  1  s    (($//r$   c                  (    [         R                  " U 6 $ r/   )r   
read_indexrI  s    r   r'  r'  1  r  r$   c                  (    [         R                  " U 6 $ r/   )r   read_index_binaryrI  s    r   r'  r'  1  s    ''..r$   c                  (    [         R                  " U 6 $ r/   )r   write_VectorTransformrI  s    r   r'  r'  1      ++T22r$   c                  (    [         R                  " U 6 $ r/   )r   read_VectorTransformrI  s    r   r'  r'  1  s    **D11r$   c                  (    [         R                  " U 6 $ r/   )r   read_ProductQuantizerrI  s    r   r'  r'  1  r'  r$   c                  (    [         R                  " U 6 $ r/   )r   write_ProductQuantizerrI  s    r   r'  r'  1      ,,d33r$   c                 .    [         R                  " X5      $ r/   )r   write_InvertedLists)r  r|  s     r   r'  r'  1  s    ))#11r$   c                 .    [         R                  " X5      $ r/   )r   read_InvertedLists)r  r  s     r   r'  r'  1  s    ((::r$   c                 .    [         R                  " U 5      $ r/   )r   clone_indexr  s    r   r'  r'  1  s    !!$''r$   c                   `    \ rS rSrSr\" S S SS9r\rS r	S r
S	 r\R                  rS
 rSrg)Cloneri1  z
 Cloner class, useful to override classes with other cloning
functions. The cloning function above just calls
Cloner::clone_Index.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   Cloner.<lambda>1  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r'  1  rL   r$   rM   rN   c                 .    [         R                  " X5      $ r/   )r   Cloner_clone_VectorTransformr   s     r   clone_VectorTransformCloner.clone_VectorTransform1  rI  r$   c                 .    [         R                  " X5      $ r/   )r   Cloner_clone_Indexr   s     r   clone_IndexCloner.clone_Index1  r"  r$   c                 .    [         R                  " X5      $ r/   )r   Cloner_clone_IndexIVFr   s     r   clone_IndexIVFCloner.clone_IndexIVF1  r/  r$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   Cloner_swiginit
new_Clonerr[   s    r   rV   Cloner.__init__1  r%  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r'  r'  r'  r   delete_Clonerr   rV   r>   r%   r$   r   r'  r'  1  sA     -/IOdeGHC9<!//Br$   r'  c                 .    [         R                  " U 5      $ r/   )r   clone_Quantizer)quants    r   r'  r'  2  s    %%e,,r$   c                 .    [         R                  " U 5      $ r/   )r   clone_binary_indexr~'  s    r   r'  r'  2  s    ((//r$   c                   r   \ rS rSrSr\" S S SS9rS r\r	\" \
R                  \
R                  SS9r\" \
R                  \
R                  S	S9r\" \
R"                  \
R$                  S
S9r\" \
R(                  \
R*                  SS9r\" \
R.                  \
R0                  SS9rS rS r\
R8                  rSrg)AutoTuneCriterioni	2  zQ
Evaluation criterion. Returns a performance measure in [0,1],
higher is better.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   AutoTuneCriterion.<lambda>2  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r'  2  rL   r$   rM   rN   c                     [        S5      erQ   rR   rS   s      r   rV   AutoTuneCriterion.__init__2  rX   r$   z,nb of queries this criterion is evaluated onz'nb of NNs that the query should requestz+nb of GT NNs required to evaluate criterionz)Ground-truth distances (size nq * gt_nnn)z'Ground-truth indexes (size nq * gt_nnn)c                 0    [         R                  " XX#5      $ )z
 Initializes the gt_D and gt_I vectors. Must be called before evaluating

:type gt_D_in: float
:param gt_D_in:  size nq * gt_nnn
:type gt_I_in: int
:param gt_I_in:  size nq * gt_nnn
)r   !AutoTuneCriterion_set_groundtruth)r   gt_nnngt_D_ingt_I_ins       r   set_groundtruth!AutoTuneCriterion.set_groundtruth2  s     ;;D'[[r$   c                 0    [         R                  " XU5      $ )z
 Evaluate the criterion.

:type D: float
:param D:  size nq * nnn
:type I: int
:param I:  size nq * nnn
:rtype: float
:return: the criterion, between 0 and 1. Larger is better.
)r   AutoTuneCriterion_evaluater   r  r
  s      r   r|  AutoTuneCriterion.evaluate%2  s     44Ta@@r$   r%   N)r   r   r:   r;   r<   r   r   rV   r   r   r   AutoTuneCriterion_nq_getAutoTuneCriterion_nq_setr  AutoTuneCriterion_nnn_getAutoTuneCriterion_nnn_setnnnAutoTuneCriterion_gt_nnn_getAutoTuneCriterion_gt_nnn_setr'  AutoTuneCriterion_gt_D_getAutoTuneCriterion_gt_D_setgt_DAutoTuneCriterion_gt_I_getAutoTuneCriterion_gt_I_setgt_Ir'  r|  delete_AutoTuneCriterionr   r>   r%   r$   r   r'  r'  	2  s    
 -/IOdeGKH	*55z7Z7Z  aT  
UB
:779]9]  dR  SCj==z?f?f  m_  `FJ99:;`;`  gW  XDJ99:;`;`  gU  VD	\A "::r$   r'  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS rS r\R                  rSrg	)
OneRecallAtRCriterioni52  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   OneRecallAtRCriterion.<lambda>62  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r'  62  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   OneRecallAtRCriterion_swiginitnew_OneRecallAtRCriterionr   r  r  s      r   rV   OneRecallAtRCriterion.__init__:2      11$
8\8\]_8cdr$   c                 0    [         R                  " XU5      $ r/   )r   OneRecallAtRCriterion_evaluater'  s      r   r|  OneRecallAtRCriterion.evaluate=2  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   OneRecallAtRCriterion_R_getOneRecallAtRCriterion_R_setr  rV   r|  delete_OneRecallAtRCriterionr   r>   r%   r$   r   r'  r'  52  H    -/IOdeGH779_9_`AeE!>>r$   r'  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS rS r\R                  rSrg	)
IntersectionCriterioniC2  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   IntersectionCriterion.<lambda>D2  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r'  D2  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " X5      5        g r/   )r   IntersectionCriterion_swiginitnew_IntersectionCriterionr'  s      r   rV   IntersectionCriterion.__init__H2  r'  r$   c                 0    [         R                  " XU5      $ r/   )r   IntersectionCriterion_evaluater'  s      r   r|  IntersectionCriterion.evaluateK2  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   IntersectionCriterion_R_getIntersectionCriterion_R_setr  rV   r|  delete_IntersectionCriterionr   r>   r%   r$   r   r'  r'  C2  r'  r$   r'  c                   .   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9rS r\	R.                  rSrg)OperatingPointiQ2  a$  
Maintains a list of experimental results. Each operating point is a
(perf, t, key) triplet, where higher perf and lower t is
better. The key field is an arbitrary identifier for the operating point.

Includes primitives to extract the Pareto-optimal operating points in the
(perf, t) space.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   OperatingPoint.<lambda>[2  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r(  [2  rL   r$   rM   rN   z+performance measure (output of a Criterion)z!corresponding execution time (ms)zkey that identifies this op ptzinteger identifierc                 X    [         R                  " U [         R                  " 5       5        g r/   )r   OperatingPoint_swiginitnew_OperatingPointr[   s    r   rV   OperatingPoint.__init__b2  r  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   OperatingPoint_perf_getOperatingPoint_perf_setperfOperatingPoint_t_getOperatingPoint_t_setr  OperatingPoint_key_getOperatingPoint_key_setry  OperatingPoint_cno_getOperatingPoint_cno_setcnorV   delete_OperatingPointr   r>   r%   r$   r   r'  r'  Q2  s     -/IOdeGHJ66
8Z8Z  aS  TD00*2Q2QW  	AA
:44j6W6W  ^C  DC
:44j6W6W]v
wCR!77r$   r'  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  SS9r\" \R                  \R                  SS9rS rS	 rS
 rSS jrS rSS jrS rS r\R.                  rSrg)OperatingPointsih2  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   OperatingPoints.<lambda>i2  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r(  i2  rL   r$   rM   rN   zall operating pointsz(optimal operating points, sorted by perfc                 X    [         R                  " U [         R                  " 5       5        g r/   )r   OperatingPoints_swiginitnew_OperatingPointsr[   s    r   rV   OperatingPoints.__init__n2  rA  r$   c                 0    [         R                  " U /UQ76 $ )zBadd operating points from other to this, with a prefix to the keys)r   OperatingPoints_merge_withr   s     r   
merge_withOperatingPoints.merge_withq2  s    44TADAAr$   c                 .    [         R                  " U 5      $ r/   )r   OperatingPoints_clearr[   s    r   r   OperatingPoints.clearu2  rR  r$   c                 2    [         R                  " XX#U5      $ )z@add a performance measure. Return whether it is an optimal point)r   OperatingPoints_add)r   r	(  r  ry  r(  s        r   rH  OperatingPoints.addx2  s    --d!#FFr$   c                 .    [         R                  " X5      $ )z7get time required to obtain a given performance measure)r   OperatingPoints_t_for_perf)r   r	(  s     r   
t_for_perfOperatingPoints.t_for_perf|2  s    44T@@r$   c                 .    [         R                  " X5      $ )zeasy-to-read output)r   OperatingPoints_display)r   only_optimals     r   r  OperatingPoints.display2  s    11$EEr$   c                 .    [         R                  " X5      $ )z,output to a format easy to digest by gnuplot)r   OperatingPoints_all_to_gnuplotr   fnames     r   all_to_gnuplotOperatingPoints.all_to_gnuplot2  r!  r$   c                 .    [         R                  " X5      $ r/   )r   "OperatingPoints_optimal_to_gnuplotr/(  s     r   optimal_to_gnuplot"OperatingPoints.optimal_to_gnuplot2  r  r$   r%   Nr  r!	  )r   r   r:   r;   r   r   r   r   r   OperatingPoints_all_pts_getOperatingPoints_all_pts_setall_ptsOperatingPoints_optimal_pts_getOperatingPoints_optimal_pts_setoptimal_ptsrV   r(  r   rH  r'(  r  r1(  r5(  delete_OperatingPointsr   r>   r%   r$   r   r(  r(  h2  s    -/IOdeGHz==z?e?e  lG  HG:EEzGqGq  xg  hKTB6GAFFJ!88r$   r(  c                       \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  5      r\" \	R                  \	R                  5      rS r\	R"                  rSrg	)
ParameterRangei2  zLpossible values of a parameter, sorted from least to most expensive/accuratec                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ParameterRange.<lambda>2  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rA(  2  rL   r$   rM   rN   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   ParameterRange_swiginitnew_ParameterRanger[   s    r   rV   ParameterRange.__init__2  r  r$   r%   N)r   r   r:   r;   r<   r   r   r   r   r   ParameterRange_name_getParameterRange_name_setr   ParameterRange_values_getParameterRange_values_setvaluesrV   delete_ParameterRanger   r>   r%   r$   r   r?(  r?(  2  s]    W-/IOdeGHJ66
8Z8Z[Dj::J<`<`aFR!77r$   r?(  c                      \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9r\" \	R,                  \	R.                  SS9r\" \	R2                  \	R4                  SS9rS rS rS rS rS r S r!S r"S r#S r$S r%S r&\	RN                  r(Sr)g)ParameterSpacei2  zKUses a-priori knowledge on the Faiss indexes to extract tunable parameters.c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   ParameterSpace.<lambda>2  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rP(  2  rL   r$   rM   rN   zall tunable parameterszverbosity during explorationz@nb of experiments during optimization (0 = try all combinations)z.maximum number of queries to submit at a time.z_
    use multithreading over batches (useful to benchmark
    independent single-searches)
    zm
    run tests several times until they reach at least this
    duration (to avoid jittering in MT mode)
    c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   ParameterSpace_swiginitnew_ParameterSpacer[   s    r   rV   ParameterSpace.__init__2  r  r$   c                 .    [         R                  " U 5      $ )z-nb of combinations, = product of values sizes)r   ParameterSpace_n_combinationsr[   s    r   n_combinationsParameterSpace.n_combinations2  r  r$   c                 0    [         R                  " XU5      $ )z8returns whether combinations c1 >= c2 in the tuple sense)r   ParameterSpace_combination_ge)r   r5$  r8$  s      r   combination_geParameterSpace.combination_ge2  s    77"EEr$   c                 .    [         R                  " X5      $ )z,get string representation of the combination)r   ParameterSpace_combination_name)r   r(  s     r   combination_nameParameterSpace.combination_name2  s    99$DDr$   c                 .    [         R                  " U 5      $ )zprint a description on stdout)r   ParameterSpace_displayr[   s    r   r  ParameterSpace.display2  s    0066r$   c                 .    [         R                  " X5      $ )z/add a new parameter (or return it if it exists))r   ParameterSpace_add_ranger  s     r   	add_rangeParameterSpace.add_range2  s    224>>r$   c                 .    [         R                  " X5      $ )z3initialize with reasonable parameters for the index)r   ParameterSpace_initializer  s     r   
initializeParameterSpace.initialize2  r!  r$   c                 0    [         R                  " U /UQ76 $ )z
*Overload 1:*
set a combination of parameters on an index

|

*Overload 2:*
set a combination of parameters described by a string
)r   #ParameterSpace_set_index_parametersr   s     r   set_index_parameters#ParameterSpace.set_index_parameters2  s     ==dJTJJr$   c                 0    [         R                  " XX#5      $ )zAset one of the parameters, returns whether setting was successful)r   "ParameterSpace_set_index_parameter)r   r}	  r   r(  s       r   set_index_parameter"ParameterSpace.set_index_parameter2  s    <<T$TTr$   c                 2    [         R                  " XX#U5      $ )zw
 find an upper bound on the performance and a lower bound on t
for configuration cno given another operating point op
)r   ParameterSpace_update_bounds)r   r(  opupper_bound_perflower_bound_ts        r   update_boundsParameterSpace.update_bounds2  s    
 66t"Xeffr$   c                 2    [         R                  " XX#XE5      $ )a<  
 explore operating points
:type index: :py:class:`Index`
:param index:   index to run on
:type xq: float
:param xq:      query vectors (size nq * index.d)
:type crit: :py:class:`AutoTuneCriterion`
:param crit:    selection criterion
:type ops: :py:class:`OperatingPoints`
:param ops:     resulting operating points
)r   ParameterSpace_explore)r   r}	  r  r]  critopss         r   exploreParameterSpace.explore2  s     00bdPPr$   r%   N)*r   r   r:   r;   r<   r   r   r   r   r   #ParameterSpace_parameter_ranges_get#ParameterSpace_parameter_ranges_setparameter_rangesParameterSpace_verbose_getParameterSpace_verbose_setr   ParameterSpace_n_experiments_get ParameterSpace_n_experiments_setn_experimentsParameterSpace_batchsize_getParameterSpace_batchsize_set	batchsize&ParameterSpace_thread_over_batches_get&ParameterSpace_thread_over_batches_setthread_over_batches$ParameterSpace_min_test_duration_get$ParameterSpace_min_test_duration_setmin_test_durationrV   rX(  r\(  r`(  r  rg(  rk(  ro(  rs(  rz(  r(  delete_ParameterSpacer   r>   r%   r$   r   rN(  rN(  2  sH   V-/IOdeGH
 N NPZP~P~  Eb  cz<<j>c>c  jM  NGZHH*JuJu  |C  DM@@*BiBi  pe  fI":#T#TV`  WH  WH N 	 !!P!PR\  SB  SB H 	
R>FE7?A
KUgQ "77r$   rN(  c                  (    [         R                  " U 6 $ )zO
Build an index with the sequence of processing steps described in
the string.
)r   index_factoryrI  s    r   r(  r(  2  s    
 ##T**r$   c                 0    [         R                  " XU5      $ r/   )r   index_binary_factory)r  descriptionr[  s      r   r(  r(  2  s    **1<HHr$   c                   F   \ rS rSrSr\" S S SS9r\rS r	\" \
R                  \
R                  5      r\" \
R                  \
R                  5      r\" \
R"                  \
R$                  5      r\" \
R(                  \
R*                  5      r\" \
R.                  \
R0                  5      r\" \
R4                  \
R6                  5      r\" \
R:                  \
R<                  5      r\" \
R@                  \
RB                  5      r"\" \
RF                  \
RH                  5      r%\" \
RL                  \
RN                  5      r(\" \
RR                  \
RT                  5      r+\" \
RX                  \
RZ                  5      r.\" \
R^                  \
R`                  5      r1S r2\
Rf                  r4S	r5g
)MatrixStatsi2  z
 Reports some statistics on a dataset and comments on them.

It is a class rather than a function so that all stats can also be
accessed from code
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   MatrixStats.<lambda>3  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r(  3  rL   r$   rM   rN   c                 \    [         R                  " U [         R                  " XU5      5        g r/   )r   MatrixStats_swiginitnew_MatrixStats)r   ra   r  rE   s       r   rV   MatrixStats.__init__3  s    ''j.H.Hq.QRr$   c                 .    [         R                  " X5      $ r/   )r   MatrixStats_do_comment)r   fmts     r   
do_commentMatrixStats.do_comment3  r\  r$   r%   N)6r   r   r:   r;   r<   r   r   r   r   rV   r   MatrixStats_comments_getMatrixStats_comments_setcommentsMatrixStats_n_getMatrixStats_n_setra   MatrixStats_d_getMatrixStats_d_setr  MatrixStats_n_collision_getMatrixStats_n_collision_setn_collisionMatrixStats_n_valid_getMatrixStats_n_valid_setn_validMatrixStats_n0_getMatrixStats_n0_setr   MatrixStats_min_norm2_getMatrixStats_min_norm2_set	min_norm2MatrixStats_max_norm2_getMatrixStats_max_norm2_set	max_norm2MatrixStats_hash_value_getMatrixStats_hash_value_set
hash_valueMatrixStats_per_dim_stats_getMatrixStats_per_dim_stats_setper_dim_statsMatrixStats_occurrences_getMatrixStats_occurrences_setoccurrencesMatrixStats_buf_getMatrixStats_buf_setbufMatrixStats_nbuf_getMatrixStats_nbuf_setnbufr(  delete_MatrixStatsr   r>   r%   r$   r   r(  r(  2  sn    -/IOdeGHS
;;Z=`=`aH--z/K/KLA--z/K/KLA:AA:CiCijKz99:;];]^G	*//1N1N	OB==z?c?cdI==z?c?cdI*??AfAfgJZEEzGoGopM:AA:CiCijK
:11:3Q3Q
RCJ33Z5T5TUD<!44r$   r(  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS rS r\R"                  rSrg	)
PyCallbackIOWriteri3  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PyCallbackIOWriter.<lambda>3  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r(  3  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g)zk
Callback: Python function that takes a bytes object and
returns the number of bytes successfully written.
N)r   PyCallbackIOWriter_swiginitnew_PyCallbackIOWriterr   s     r   rV   PyCallbackIOWriter.__init__"3       
 	..tZ5V5VX\5]^r$   c                 0    [         R                  " XX#5      $ r/   )r   PyCallbackIOWriter___call__r   ptrvr   r,  s       r   r  PyCallbackIOWriter.__call__)3      55d$OOr$   r%   N)r   r   r:   r;   r   r   r   r   r   PyCallbackIOWriter_callback_getPyCallbackIOWriter_callback_setcallbackPyCallbackIOWriter_bs_getPyCallbackIOWriter_bs_setbsrV   r  delete_PyCallbackIOWriterr   r>   r%   r$   r   r(  r(  3  `    -/IOdeGH
BBJDnDnoH	*66
8\8\	]B_P!;;r$   r(  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      rS rS r\R"                  rSrg	)
PyCallbackIOReaderi/3  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PyCallbackIOReader.<lambda>03  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r(  03  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g)za
 Callback: Python function that takes a size and returns a
bytes object with the resulting read
N)r   PyCallbackIOReader_swiginitnew_PyCallbackIOReaderr   s     r   rV   PyCallbackIOReader.__init__53  r(  r$   c                 0    [         R                  " XX#5      $ r/   )r   PyCallbackIOReader___call__r(  s       r   r  PyCallbackIOReader.__call__<3  r(  r$   r%   N)r   r   r:   r;   r   r   r   r   r   PyCallbackIOReader_callback_getPyCallbackIOReader_callback_setr(  PyCallbackIOReader_bs_getPyCallbackIOReader_bs_setr(  rV   r  delete_PyCallbackIOReaderr   r>   r%   r$   r   r(  r(  /3  r(  r$   r(  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS rS r\R                  rSrg	)
PyCallbackIDSelectoriB3  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   PyCallbackIDSelector.<lambda>C3  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r(  C3  rL   r$   rM   rN   c                 Z    [         R                  " U [         R                  " U5      5        g r/   )r   PyCallbackIDSelector_swiginitnew_PyCallbackIDSelector)r   r(  s     r   rV   PyCallbackIDSelector.__init__G3  s    00z7Z7Z[c7der$   c                 .    [         R                  " X5      $ r/   )r   PyCallbackIDSelector_is_memberr%  s     r   r%  PyCallbackIDSelector.is_memberJ3  r&  r$   r%   N)r   r   r:   r;   r   r   r   r   r   !PyCallbackIDSelector_callback_get!PyCallbackIDSelector_callback_setr(  rV   r%  delete_PyCallbackIDSelectorr   r>   r%   r$   r   r(  r(  B3  sH    -/IOdeGH
DDjFrFrsHfC!==r$   r(  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS r\R                  rS rSrg	)
PyCallbackShardingFunctioniP3  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   #PyCallbackShardingFunction.<lambda>Q3  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r)  Q3  rL   r$   rM   rN   c                 0    [         R                  " XU5      $ r/   )r   #PyCallbackShardingFunction___call__r  s      r   r  #PyCallbackShardingFunction.__call__U3  s    ==d{SSr$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   #PyCallbackShardingFunction_swiginitnew_PyCallbackShardingFunctionr   s     r   rV   #PyCallbackShardingFunction.__init__Y3  s    66tZ=f=fhl=mnr$   r%   N)r   r   r:   r;   r   r   r   r   r   'PyCallbackShardingFunction_callback_get'PyCallbackShardingFunction_callback_setr(  r  !delete_PyCallbackShardingFunctionr   rV   r>   r%   r$   r   r)  r)  P3  sH    -/IOdeGH
JJJL~L~HT!CCor$   r)  c                   j   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9rS rS rS rSS jrSS jrSS jrS rS rS r\	R>                  r Sr!g)float_minheap_array_ti^3  
 a template structure for a set of [min|max]-heaps it is tailored
so that the actual data of the heaps can just live in compact
arrays.
c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   float_minheap_array_t.<lambda>e3  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r)  e3  rL   r$   rM   rN   number of heapsallocated size per heapidentifiers (size nh * k)/values (distances or similarities), size nh * kc                 .    [         R                  " X5      $ z$Return the list of values for a heap)r   float_minheap_array_t_get_valr   ry  s     r   get_valfloat_minheap_array_t.get_vall3  r  r$   c                 .    [         R                  " X5      $ zCorresponding identifiers)r   float_minheap_array_t_get_idsr )  s     r   r
  float_minheap_array_t.get_idsp3  r  r$   c                 .    [         R                  " U 5      $ z#prepare all the heaps before adding)r   float_minheap_array_t_heapifyr[   s    r   heapifyfloat_minheap_array_t.heapifyt3  r  r$   c                 2    [         R                  " XX#XE5      $ a  
 add nj elements to heaps i0:i0+ni, with sequential ids

:type nj: int
:param nj:    nb of elements to add to each heap
:type vin: float
:param vin:   elements to add, size ni * nj
:type j0: int, optional
:param j0:    add this to the ids that are added
:type i0: int, optional
:param i0:    first heap to update
:type ni: int, optional
:param ni:    nb of elements to update (-1 = use nh)
)r   float_minheap_array_t_addnr   njvinr  r  r  s         r   addnfloat_minheap_array_t.addnx3       44TsOOr$   Nc           	      4    [         R                  " XX#XEU5      $ z
 same as addn

:type id_in: int, optional
:param id_in:     ids of the elements to add, size ni * nj
:type id_stride: int, optional
:param id_stride: stride for id_in
)r   #float_minheap_array_t_addn_with_idsr   r0)  r1)  id_in	id_strider  r  s          r   addn_with_ids#float_minheap_array_t.addn_with_ids3       ==dT]ceffr$   c           	      4    [         R                  " XX#XEU5      $ z
 same as addn_with_ids, but for just a subset of queries

:type nsubset: int
:param nsubset:  number of query entries to update
:type subset: int
:param subset:   indexes of queries to update, in 0..nh-1, size nsubset
)r   0float_minheap_array_t_addn_query_subset_with_idsr   r  r  r0)  r1)  r9)  r:)  s          r   addn_query_subset_with_ids0float_minheap_array_t.addn_query_subset_with_ids3       JJ4Z`fir{||r$   c                 .    [         R                  " U 5      $ zreorder all the heaps)r   float_minheap_array_t_reorderr[   s    r   reorderfloat_minheap_array_t.reorder3  r  r$   c                 0    [         R                  " XU5      $ a  
 this is not really a heap function. It just finds the per-line
  extrema of each line of array D
:type vals_out: float
:param vals_out:    extreme value of each line (size nh, or NULL)
:type idx_out: int
:param idx_out:     index of extreme value (size nh or NULL)
)r   &float_minheap_array_t_per_line_extremar   vals_outidx_outs      r   per_line_extrema&float_minheap_array_t.per_line_extrema3       @@QXYYr$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   float_minheap_array_t_swiginitnew_float_minheap_array_tr[   s    r   rV   float_minheap_array_t.__init__3  r  r$   r%   r   r   rE  Nr   r   rE  Nr   )"r   r   r:   r;   r<   r   r   r   r   r   float_minheap_array_t_nh_getfloat_minheap_array_t_nh_setnhfloat_minheap_array_t_k_getfloat_minheap_array_t_k_setrQ  float_minheap_array_t_ids_getfloat_minheap_array_t_ids_setr  float_minheap_array_t_val_getfloat_minheap_array_t_val_setr(  r!)  r
  r*)  r2)  r;)  rB)  rH)  rP)  rV   delete_float_minheap_array_tr   r>   r%   r$   r   r)  r)  ^3       -/IOdeGH	*99:;b;bh~	B779_9_  fD  	EA
:;;Z=e=e  lL  MC
:;;Z=e=e  lb  cCCC>P"	g	}>	Z`!>>r$   r)  c                   j   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9rS rS rS rSS jrSS jrSS jrS rS rS r\	R>                  r Sr!g)int_minheap_array_ti3  r)  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   int_minheap_array_t.<lambda>3  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rh)  3  rL   r$   rM   rN   r)  r)  r)  r)  c                 .    [         R                  " X5      $ r)  )r   int_minheap_array_t_get_valr )  s     r   r!)  int_minheap_array_t.get_val3  r'  r$   c                 .    [         R                  " X5      $ r$)  )r   int_minheap_array_t_get_idsr )  s     r   r
  int_minheap_array_t.get_ids3  r'  r$   c                 .    [         R                  " U 5      $ r()  )r   int_minheap_array_t_heapifyr[   s    r   r*)  int_minheap_array_t.heapify3  r!  r$   c                 2    [         R                  " XX#XE5      $ a  
 add nj elements to heaps i0:i0+ni, with sequential ids

:type nj: int
:param nj:    nb of elements to add to each heap
:type vin: int
:param vin:   elements to add, size ni * nj
:type j0: int, optional
:param j0:    add this to the ids that are added
:type i0: int, optional
:param i0:    first heap to update
:type ni: int, optional
:param ni:    nb of elements to update (-1 = use nh)
)r   int_minheap_array_t_addnr/)  s         r   r2)  int_minheap_array_t.addn3       224SbMMr$   Nc           	      4    [         R                  " XX#XEU5      $ r6)  )r   !int_minheap_array_t_addn_with_idsr8)  s          r   r;)  !int_minheap_array_t.addn_with_ids3       ;;DcR[acddr$   c           	      4    [         R                  " XX#XEU5      $ r?)  )r   .int_minheap_array_t_addn_query_subset_with_idsrA)  s          r   rB)  .int_minheap_array_t.addn_query_subset_with_ids3       HHX^dgpyzzr$   c                 .    [         R                  " U 5      $ rF)  )r   int_minheap_array_t_reorderr[   s    r   rH)  int_minheap_array_t.reorder3  r!  r$   c                 0    [         R                  " XU5      $ a	  
 this is not really a heap function. It just finds the per-line
  extrema of each line of array D
:type vals_out: int
:param vals_out:    extreme value of each line (size nh, or NULL)
:type idx_out: int
:param idx_out:     index of extreme value (size nh or NULL)
)r   $int_minheap_array_t_per_line_extremarM)  s      r   rP)  $int_minheap_array_t.per_line_extrema3       >>twWWr$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   int_minheap_array_t_swiginitnew_int_minheap_array_tr[   s    r   rV   int_minheap_array_t.__init__4  r  r$   r%   rW)  rX)  rY)  )"r   r   r:   r;   r<   r   r   r   r   r   int_minheap_array_t_nh_getint_minheap_array_t_nh_setr\)  int_minheap_array_t_k_getint_minheap_array_t_k_setrQ  int_minheap_array_t_ids_getint_minheap_array_t_ids_setr  int_minheap_array_t_val_getint_minheap_array_t_val_setr(  r!)  r
  r*)  r2)  r;)  rB)  rH)  rP)  rV   delete_int_minheap_array_tr   r>   r%   r$   r   rf)  rf)  3       -/IOdeGH	*779^9^dz	{B55z7[7[a  	AA
:99:;a;a  hH  IC
:99:;a;a  h^  _CAA<N"	e	{<	X\!<<r$   rf)  c                   j   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9rS rS rS rSS jrSS jrSS jrS rS rS r\	R>                  r Sr!g)float_maxheap_array_ti
4  r)  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   float_maxheap_array_t.<lambda>4  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r)  4  rL   r$   rM   rN   r)  r)  r)  r)  c                 .    [         R                  " X5      $ r)  )r   float_maxheap_array_t_get_valr )  s     r   r!)  float_maxheap_array_t.get_val4  r  r$   c                 .    [         R                  " X5      $ r$)  )r   float_maxheap_array_t_get_idsr )  s     r   r
  float_maxheap_array_t.get_ids4  r  r$   c                 .    [         R                  " U 5      $ r()  )r   float_maxheap_array_t_heapifyr[   s    r   r*)  float_maxheap_array_t.heapify 4  r  r$   c                 2    [         R                  " XX#XE5      $ r-)  )r   float_maxheap_array_t_addnr/)  s         r   r2)  float_maxheap_array_t.addn$4  r4)  r$   Nc           	      4    [         R                  " XX#XEU5      $ r6)  )r   #float_maxheap_array_t_addn_with_idsr8)  s          r   r;)  #float_maxheap_array_t.addn_with_ids54  r=)  r$   c           	      4    [         R                  " XX#XEU5      $ r?)  )r   0float_maxheap_array_t_addn_query_subset_with_idsrA)  s          r   rB)  0float_maxheap_array_t.addn_query_subset_with_ids@4  rD)  r$   c                 .    [         R                  " U 5      $ rF)  )r   float_maxheap_array_t_reorderr[   s    r   rH)  float_maxheap_array_t.reorderK4  r  r$   c                 0    [         R                  " XU5      $ rK)  )r   &float_maxheap_array_t_per_line_extremarM)  s      r   rP)  &float_maxheap_array_t.per_line_extremaO4  rR)  r$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   float_maxheap_array_t_swiginitnew_float_maxheap_array_tr[   s    r   rV   float_maxheap_array_t.__init__Z4  r  r$   r%   rW)  rX)  rY)  )"r   r   r:   r;   r<   r   r   r   r   r   float_maxheap_array_t_nh_getfloat_maxheap_array_t_nh_setr\)  float_maxheap_array_t_k_getfloat_maxheap_array_t_k_setrQ  float_maxheap_array_t_ids_getfloat_maxheap_array_t_ids_setr  float_maxheap_array_t_val_getfloat_maxheap_array_t_val_setr(  r!)  r
  r*)  r2)  r;)  rB)  rH)  rP)  rV   delete_float_maxheap_array_tr   r>   r%   r$   r   r)  r)  
4  rd)  r$   r)  c                   j   \ rS rSrSr\" S S SS9r\r\" \	R                  \	R                  SS9r\" \	R                  \	R                  SS9r\" \	R                   \	R"                  S	S9r\" \	R&                  \	R(                  S
S9rS rS rS rSS jrSS jrSS jrS rS rS r\	R>                  r Sr!g)int_maxheap_array_ti`4  r)  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   int_maxheap_array_t.<lambda>g4  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r)  g4  rL   r$   rM   rN   r)  r)  r)  r)  c                 .    [         R                  " X5      $ r)  )r   int_maxheap_array_t_get_valr )  s     r   r!)  int_maxheap_array_t.get_valn4  r'  r$   c                 .    [         R                  " X5      $ r$)  )r   int_maxheap_array_t_get_idsr )  s     r   r
  int_maxheap_array_t.get_idsr4  r'  r$   c                 .    [         R                  " U 5      $ r()  )r   int_maxheap_array_t_heapifyr[   s    r   r*)  int_maxheap_array_t.heapifyv4  r!  r$   c                 2    [         R                  " XX#XE5      $ rt)  )r   int_maxheap_array_t_addnr/)  s         r   r2)  int_maxheap_array_t.addnz4  rw)  r$   Nc           	      4    [         R                  " XX#XEU5      $ r6)  )r   !int_maxheap_array_t_addn_with_idsr8)  s          r   r;)  !int_maxheap_array_t.addn_with_ids4  r{)  r$   c           	      4    [         R                  " XX#XEU5      $ r?)  )r   .int_maxheap_array_t_addn_query_subset_with_idsrA)  s          r   rB)  .int_maxheap_array_t.addn_query_subset_with_ids4  r)  r$   c                 .    [         R                  " U 5      $ rF)  )r   int_maxheap_array_t_reorderr[   s    r   rH)  int_maxheap_array_t.reorder4  r!  r$   c                 0    [         R                  " XU5      $ r)  )r   $int_maxheap_array_t_per_line_extremarM)  s      r   rP)  $int_maxheap_array_t.per_line_extrema4  r)  r$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   int_maxheap_array_t_swiginitnew_int_maxheap_array_tr[   s    r   rV   int_maxheap_array_t.__init__4  r  r$   r%   rW)  rX)  rY)  )"r   r   r:   r;   r<   r   r   r   r   r   int_maxheap_array_t_nh_getint_maxheap_array_t_nh_setr\)  int_maxheap_array_t_k_getint_maxheap_array_t_k_setrQ  int_maxheap_array_t_ids_getint_maxheap_array_t_ids_setr  int_maxheap_array_t_val_getint_maxheap_array_t_val_setr(  r!)  r
  r*)  r2)  r;)  rB)  rH)  rP)  rV   delete_int_maxheap_array_tr   r>   r%   r$   r   r)  r)  `4  r)  r$   r)  c                 2    [         R                  " XX#XE5      $ z
 partitions the table into 0:q and q:n where all elements above q are >= all
elements below q (for C = CMax, for CMin comparisons are reversed)

Returns the partition threshold. The elements q:n are destroyed on output.
)r   CMin_float_partition_fuzzyr  r  ra   q_minq_maxq_outs         r   r)  r)  4       00AeSSr$   c                 2    [         R                  " XX#XE5      $ r)  )r   CMax_float_partition_fuzzyr)  s         r   r)  r)  4  r)  r$   c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\S 5       rS rS rS	 rS
 rS rS rS rS r\R2                  rSrg)AlignedTableUint8i4  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   AlignedTableUint8.<lambda>4  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r)  4  rL   r$   rM   rN   c                 .    [         R                  " U 5      $ r/   )r    AlignedTableUint8_round_capacityra   s    r   round_capacity AlignedTableUint8.round_capacity4  s    ::1==r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   AlignedTableUint8_swiginitnew_AlignedTableUint8r   s     r   rV   AlignedTableUint8.__init__4  r  r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableUint8_itemsizer[   s    r   itemsizeAlignedTableUint8.itemsize4  r  r$   c                 .    [         R                  " X5      $ r/   )r   AlignedTableUint8_resizer`   s     r   r   AlignedTableUint8.resize4  rL  r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableUint8_clearr[   s    r   r   AlignedTableUint8.clear4  r   r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableUint8_sizer[   s    r   r   AlignedTableUint8.size4  rB  r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableUint8_nbytesr[   s    r   nbytesAlignedTableUint8.nbytes4  r  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   AlignedTableUint8_getr   s     r   r  AlignedTableUint8.get4  s    //<t<<r$   c                 0    [         R                  " U /UQ76 $ r/   )r   AlignedTableUint8_datar   s     r   r   AlignedTableUint8.data4  r   r$   r%   N)r   r   r:   r;   r   r   r   r   r   AlignedTableUint8_tab_getAlignedTableUint8_tab_setr  AlignedTableUint8_numel_getAlignedTableUint8_numel_setr[#  r7  r)  rV   r*  r   r   r   r*  r  r   delete_AlignedTableUint8r   r>   r%   r$   r   r)  r)  4  s    -/IOdeGH
:779]9]
^CZ;;Z=c=cdE> >];<879=>!::r$   r)  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\S 5       rS rS rS	 rS
 rS rS rS rS r\R2                  rSrg)AlignedTableUint16i4  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   AlignedTableUint16.<lambda>4  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r!*  4  rL   r$   rM   rN   c                 .    [         R                  " U 5      $ r/   )r   !AlignedTableUint16_round_capacityr)  s    r   r)  !AlignedTableUint16.round_capacity4  s    ;;A>>r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   AlignedTableUint16_swiginitnew_AlignedTableUint16r   s     r   rV   AlignedTableUint16.__init__4  r  r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableUint16_itemsizer[   s    r   r*  AlignedTableUint16.itemsize4  r  r$   c                 .    [         R                  " X5      $ r/   )r   AlignedTableUint16_resizer`   s     r   r   AlignedTableUint16.resize4  r  r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableUint16_clearr[   s    r   r   AlignedTableUint16.clear 5  r  r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableUint16_sizer[   s    r   r   AlignedTableUint16.size5  r   r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableUint16_nbytesr[   s    r   r*  AlignedTableUint16.nbytes5  r  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   AlignedTableUint16_getr   s     r   r  AlignedTableUint16.get	5  r   r$   c                 0    [         R                  " U /UQ76 $ r/   )r   AlignedTableUint16_datar   s     r   r   AlignedTableUint16.data5      11$>>>r$   r%   N)r   r   r:   r;   r   r   r   r   r   AlignedTableUint16_tab_getAlignedTableUint16_tab_setr  AlignedTableUint16_numel_getAlignedTableUint16_numel_setr[#  r7  r)  rV   r*  r   r   r   r*  r  r   delete_AlignedTableUint16r   r>   r%   r$   r   r*  r*  4  s    -/IOdeGH
:88*:_:_
`CZ<<j>e>efE? ?_<=98:>?!;;r$   r*  c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\S 5       rS rS rS	 rS
 rS rS rS rS r\R2                  rSrg)AlignedTableFloat32i5  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   AlignedTableFloat32.<lambda>5  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rH*  5  rL   r$   rM   rN   c                 .    [         R                  " U 5      $ r/   )r   "AlignedTableFloat32_round_capacityr)  s    r   r)  "AlignedTableFloat32.round_capacity5  s    <<Q??r$   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   AlignedTableFloat32_swiginitnew_AlignedTableFloat32r   s     r   rV   AlignedTableFloat32.__init__5  r#  r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableFloat32_itemsizer[   s    r   r*  AlignedTableFloat32.itemsize5  r  r$   c                 .    [         R                  " X5      $ r/   )r   AlignedTableFloat32_resizer`   s     r   r   AlignedTableFloat32.resize"5  r'  r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableFloat32_clearr[   s    r   r   AlignedTableFloat32.clear%5  r  r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableFloat32_sizer[   s    r   r   AlignedTableFloat32.size(5  r  r$   c                 .    [         R                  " U 5      $ r/   )r   AlignedTableFloat32_nbytesr[   s    r   r*  AlignedTableFloat32.nbytes+5  r  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   AlignedTableFloat32_getr   s     r   r  AlignedTableFloat32.get.5  r?*  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   AlignedTableFloat32_datar   s     r   r   AlignedTableFloat32.data15      224?$??r$   r%   N)r   r   r:   r;   r   r   r   r   r   AlignedTableFloat32_tab_getAlignedTableFloat32_tab_setr  AlignedTableFloat32_numel_getAlignedTableFloat32_numel_setr[#  r7  r)  rV   r*  r   r   r   r*  r  r   delete_AlignedTableFloat32r   r>   r%   r$   r   rF*  rF*  5  s    -/IOdeGH
:99:;a;a
bCZ==z?g?ghE@ @a=>:9;?@!<<r$   rF*  c                   &   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      r\" \R*                  \R,                  5      r\" \R0                  \R2                  5      r\" \R6                  \R8                  5      rS r\S 5       r S r!S	 r"S
 r#S r$S r%S r&S r'S r(S r)\RT                  r+Sr,g)MaybeOwnedVectorUInt8i75  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   MaybeOwnedVectorUInt8.<lambda>85  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   ro*  85  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   MaybeOwnedVectorUInt8_swiginitnew_MaybeOwnedVectorUInt8r   s     r   rV   MaybeOwnedVectorUInt8.__init__B5      11$
8\8\^b8cdr$   c                 0    [         R                  " XU5      $ r/   )r   !MaybeOwnedVectorUInt8_create_viewaddress
n_elementsr  s      r   create_view!MaybeOwnedVectorUInt8.create_viewE5      ;;GQVWWr$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorUInt8_datar   s     r   r   MaybeOwnedVectorUInt8.dataI5      44TADAAr$   c                 .    [         R                  " U 5      $ r/   )r   MaybeOwnedVectorUInt8_sizer[   s    r   r   MaybeOwnedVectorUInt8.sizeL5  r  r$   c                 .    [         R                  " U 5      $ r/   )r   MaybeOwnedVectorUInt8_byte_sizer[   s    r   	byte_sizeMaybeOwnedVectorUInt8.byte_sizeO5  r'  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorUInt8_atr   s     r   r   MaybeOwnedVectorUInt8.atR5  rf*  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorUInt8_beginr   s     r   r\  MaybeOwnedVectorUInt8.beginU5      55dBTBBr$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorUInt8_endr   s     r   r]  MaybeOwnedVectorUInt8.endX5      33D@4@@r$   c                 0    [         R                  " XU5      $ r/   )r   MaybeOwnedVectorUInt8_eraser   r\  r]  s      r   eraseMaybeOwnedVectorUInt8.erase[5      55d3GGr$   c                 .    [         R                  " U 5      $ r/   )r   MaybeOwnedVectorUInt8_clearr[   s    r   r   MaybeOwnedVectorUInt8.clear^5  r  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorUInt8_resizer   s     r   r   MaybeOwnedVectorUInt8.resizea5      66tCdCCr$   r%   N)-r   r   r:   r;   r   r   r   r   r   "MaybeOwnedVectorUInt8_is_owned_get"MaybeOwnedVectorUInt8_is_owned_setis_owned$MaybeOwnedVectorUInt8_owned_data_get$MaybeOwnedVectorUInt8_owned_data_set
owned_data#MaybeOwnedVectorUInt8_view_data_get#MaybeOwnedVectorUInt8_view_data_set	view_data#MaybeOwnedVectorUInt8_view_size_get#MaybeOwnedVectorUInt8_view_size_set	view_sizeMaybeOwnedVectorUInt8_owner_getMaybeOwnedVectorUInt8_owner_setr  MaybeOwnedVectorUInt8_c_ptr_getMaybeOwnedVectorUInt8_c_ptr_setc_ptr MaybeOwnedVectorUInt8_c_size_get MaybeOwnedVectorUInt8_c_size_setc_sizerV   r7  r{*  r   r   r*  r   r\  r]  r*  r   r   delete_MaybeOwnedVectorUInt8r   r>   r%   r$   r   rm*  rm*  75     -/IOdeGH
EEzGtGtuH*II:KzKz{JGGIwIwxIGGIwIwxIZ??AkAklEZ??AkAklEjAA:CnCnoFe X XB;@@CAH<D!>>r$   rm*  c                   &   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      r\" \R*                  \R,                  5      r\" \R0                  \R2                  5      r\" \R6                  \R8                  5      rS r\S 5       r S r!S	 r"S
 r#S r$S r%S r&S r'S r(S r)\RT                  r+Sr,g)MaybeOwnedVectorInt32ig5  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   MaybeOwnedVectorInt32.<lambda>h5  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r*  h5  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r   MaybeOwnedVectorInt32_swiginitnew_MaybeOwnedVectorInt32r   s     r   rV   MaybeOwnedVectorInt32.__init__r5  ru*  r$   c                 0    [         R                  " XU5      $ r/   )r   !MaybeOwnedVectorInt32_create_viewrx*  s      r   r{*  !MaybeOwnedVectorInt32.create_viewu5  r}*  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorInt32_datar   s     r   r   MaybeOwnedVectorInt32.datay5  r*  r$   c                 .    [         R                  " U 5      $ r/   )r   MaybeOwnedVectorInt32_sizer[   s    r   r   MaybeOwnedVectorInt32.size|5  r  r$   c                 .    [         R                  " U 5      $ r/   )r   MaybeOwnedVectorInt32_byte_sizer[   s    r   r*  MaybeOwnedVectorInt32.byte_size5  r'  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorInt32_atr   s     r   r   MaybeOwnedVectorInt32.at5  rf*  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorInt32_beginr   s     r   r\  MaybeOwnedVectorInt32.begin5  r*  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorInt32_endr   s     r   r]  MaybeOwnedVectorInt32.end5  r*  r$   c                 0    [         R                  " XU5      $ r/   )r   MaybeOwnedVectorInt32_eraser*  s      r   r*  MaybeOwnedVectorInt32.erase5  r*  r$   c                 .    [         R                  " U 5      $ r/   )r   MaybeOwnedVectorInt32_clearr[   s    r   r   MaybeOwnedVectorInt32.clear5  r  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorInt32_resizer   s     r   r   MaybeOwnedVectorInt32.resize5  r*  r$   r%   N)-r   r   r:   r;   r   r   r   r   r   "MaybeOwnedVectorInt32_is_owned_get"MaybeOwnedVectorInt32_is_owned_setr*  $MaybeOwnedVectorInt32_owned_data_get$MaybeOwnedVectorInt32_owned_data_setr*  #MaybeOwnedVectorInt32_view_data_get#MaybeOwnedVectorInt32_view_data_setr*  #MaybeOwnedVectorInt32_view_size_get#MaybeOwnedVectorInt32_view_size_setr*  MaybeOwnedVectorInt32_owner_getMaybeOwnedVectorInt32_owner_setr  MaybeOwnedVectorInt32_c_ptr_getMaybeOwnedVectorInt32_c_ptr_setr*   MaybeOwnedVectorInt32_c_size_get MaybeOwnedVectorInt32_c_size_setr*  rV   r7  r{*  r   r   r*  r   r\  r]  r*  r   r   delete_MaybeOwnedVectorInt32r   r>   r%   r$   r   r*  r*  g5  r*  r$   r*  c                   &   \ rS rSr\" S S SS9r\r\" \R                  \R                  5      r\" \R                  \R                  5      r\" \R                  \R                   5      r\" \R$                  \R&                  5      r\" \R*                  \R,                  5      r\" \R0                  \R2                  5      r\" \R6                  \R8                  5      rS r\S 5       r S r!S	 r"S
 r#S r$S r%S r&S r'S r(S r)\RT                  r+Sr,g)MaybeOwnedVectorFloat32i5  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF    MaybeOwnedVectorFloat32.<lambda>5  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r*  5  rL   r$   rM   rN   c                 T    [         R                  " U [         R                  " U6 5        g r/   )r    MaybeOwnedVectorFloat32_swiginitnew_MaybeOwnedVectorFloat32r   s     r   rV    MaybeOwnedVectorFloat32.__init__5  r  r$   c                 0    [         R                  " XU5      $ r/   )r   #MaybeOwnedVectorFloat32_create_viewrx*  s      r   r{*  #MaybeOwnedVectorFloat32.create_view5  s    ==gSXYYr$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorFloat32_datar   s     r   r   MaybeOwnedVectorFloat32.data5  r*  r$   c                 .    [         R                  " U 5      $ r/   )r   MaybeOwnedVectorFloat32_sizer[   s    r   r   MaybeOwnedVectorFloat32.size5  r  r$   c                 .    [         R                  " U 5      $ r/   )r   !MaybeOwnedVectorFloat32_byte_sizer[   s    r   r*  !MaybeOwnedVectorFloat32.byte_size5  rn  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorFloat32_atr   s     r   r   MaybeOwnedVectorFloat32.at5  r*  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorFloat32_beginr   s     r   r\  MaybeOwnedVectorFloat32.begin5  s    77DtDDr$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorFloat32_endr   s     r   r]  MaybeOwnedVectorFloat32.end5  r*  r$   c                 0    [         R                  " XU5      $ r/   )r   MaybeOwnedVectorFloat32_eraser*  s      r   r*  MaybeOwnedVectorFloat32.erase5  s    77SIIr$   c                 .    [         R                  " U 5      $ r/   )r   MaybeOwnedVectorFloat32_clearr[   s    r   r   MaybeOwnedVectorFloat32.clear5  rb  r$   c                 0    [         R                  " U /UQ76 $ r/   )r   MaybeOwnedVectorFloat32_resizer   s     r   r   MaybeOwnedVectorFloat32.resize5  s    88EEEr$   r%   N)-r   r   r:   r;   r   r   r   r   r   $MaybeOwnedVectorFloat32_is_owned_get$MaybeOwnedVectorFloat32_is_owned_setr*  &MaybeOwnedVectorFloat32_owned_data_get&MaybeOwnedVectorFloat32_owned_data_setr*  %MaybeOwnedVectorFloat32_view_data_get%MaybeOwnedVectorFloat32_view_data_setr*  %MaybeOwnedVectorFloat32_view_size_get%MaybeOwnedVectorFloat32_view_size_setr*  !MaybeOwnedVectorFloat32_owner_get!MaybeOwnedVectorFloat32_owner_setr  !MaybeOwnedVectorFloat32_c_ptr_get!MaybeOwnedVectorFloat32_c_ptr_setr*  "MaybeOwnedVectorFloat32_c_size_get"MaybeOwnedVectorFloat32_c_size_setr*  rV   r7  r{*  r   r   r*  r   r\  r]  r*  r   r   delete_MaybeOwnedVectorFloat32r   r>   r%   r$   r   r*  r*  5  s   -/IOdeGH
GGIxIxyH*KKZM~M~JII:K{K{|III:K{K{|IZAA:CoCopEZAA:CoCopEjCCZErErsFi Z ZD=BBECJ>F!@@r$   r*  c                  (    [         R                  " U 6 $ r/   )r   CMin_uint16_partition_fuzzyrI  s    r   r$+  r$+  5      11488r$   c                  (    [         R                  " U 6 $ r/   )r   CMax_uint16_partition_fuzzyrI  s    r   r'+  r'+  5  r%+  r$   c                  (    [         R                  " U 6 $ r/   )r   merge_knn_results_CMinrI  s    r   r)+  r)+  5  r'  r$   c                  (    [         R                  " U 6 $ r/   )r   merge_knn_results_CMaxrI  s    r   r++  r++  5  r'  r$   c                       \ rS rSr\" S S SS9r\r\" \R                  \R                  5      rS rS rS rS	 r\R                   rS
rg)MapLong2Longi5  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF   MapLong2Long.<lambda>5  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   r/+  5  rL   r$   rM   rN   c                 0    [         R                  " XX#5      $ r/   )r   MapLong2Long_addr   ra   r  r  s       r   rH  MapLong2Long.add5  s    **4D??r$   c                 .    [         R                  " X5      $ r/   )r   MapLong2Long_searchr )  s     r   r]  MapLong2Long.search5  s    --d88r$   c                 0    [         R                  " XX#5      $ r/   )r   MapLong2Long_search_multipler3+  s       r   search_multipleMapLong2Long.search_multiple5  s    66tKKr$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r   MapLong2Long_swiginitnew_MapLong2Longr[   s    r   rV   MapLong2Long.__init__5  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r   MapLong2Long_map_getMapLong2Long_map_setr  rH  r]  r:+  rV   delete_MapLong2Longr   r>   r%   r$   r   r-+  r-+  5  sS    -/IOdeGH
:22J4S4S
TC@9LN!55r$   r-+  c                 .    [         R                  " U 5      $ r/   )r   omp_set_num_threads)num_threadss    r   rD+  rD+  5  s    ))+66r$   c                  ,    [         R                  " 5       $ r/   )r   omp_get_max_threadsr%   r$   r   rG+  rG+  5  s    ))++r$   c                 0    [         R                  " XU5      $ r/   )r   memcpy)destr  ra   s      r   rI+  rI+  5  s    T**r$   c                   `    \ rS rSr\" S S SS9r\rS r\	S 5       r
S r\R                  rS	rg
)PythonInterruptCallbacki5  c                 6    U R                   R                  5       $ r/   rC   rD   s    r   rF    PythonInterruptCallback.<lambda>5  rH   r$   c                 8    U R                   R                  U5      $ r/   rC   rJ   s     r   rF   rN+  5  rL   r$   rM   rN   c                 .    [         R                  " U 5      $ r/   )r   &PythonInterruptCallback_want_interruptr[   s    r   r%  &PythonInterruptCallback.want_interrupt5  r  r$   c                  ,    [         R                  " 5       $ r/   )r   PythonInterruptCallback_resetr%   r$   r   r  PythonInterruptCallback.reset5  s    7799r$   c                 X    [         R                  " U [         R                  " 5       5        g r/   )r    PythonInterruptCallback_swiginitnew_PythonInterruptCallbackr[   s    r   rV    PythonInterruptCallback.__init__5  r  r$   r%   N)r   r   r:   r;   r   r   r   r   r%  r7  r  rV   r   delete_PythonInterruptCallbackr   r>   r%   r$   r   rL+  rL+  5  sD    -/IOdeGHG : :d!@@r$   rL+  c                 .    [         R                  " U 5      $ r/   )r   swig_ptr)r  s    r   r\+  r\+  6  s    q!!r$   c                  (    [         R                  " U 6 $ r/   )r   rev_swig_ptrrI  s    r   r^+  r^+  6  s    ""D))r$   c                 .    [         R                  " U 5      $ r/   )r   cast_integer_to_uint8_ptrrD   s    r   r`+  r`+  6      //22r$   c                 .    [         R                  " U 5      $ r/   )r   cast_integer_to_float_ptrrD   s    r   rc+  rc+  6  ra+  r$   c                 .    [         R                  " U 5      $ r/   )r   cast_integer_to_idx_t_ptrrD   s    r   re+  re+  6  ra+  r$   c                 .    [         R                  " U 5      $ r/   )r   cast_integer_to_int_ptrrD   s    r   rg+  rg+  6  s    --a00r$   c                 .    [         R                  " U 5      $ r/   )r   cast_integer_to_void_ptrrD   s    r   ri+  ri+  6  s    ..q11r$   c                  ,    [         R                  " 5       $ r/   )r   swig_versionr%   r$   r   rk+  rk+  6  rt  r$   r/   r   )Tr   )Fr  )rE  rE  rE  rF  r  r#  r?  rV  r!	  (W  sysr   _swig_python_version_info__package__r   r   r   builtinsr   ImportErrorr   r&   r,   r6   r   r8   objectr@   SwigPyIterator_swigregisterSHARED_PTR_DISOWNr   Float32Vector_swigregisterr   Float64Vector_swigregisterr   Int8Vector_swigregisterr"  Int16Vector_swigregisterrI  Int32Vector_swigregisterri  Int64Vector_swigregisterr  UInt8Vector_swigregisterr  UInt16Vector_swigregisterr  UInt32Vector_swigregisterr  UInt64Vector_swigregisterr	   Float32VectorVector_swigregisterr/  UInt8VectorVector_swigregisterrT  Int32VectorVector_swigregisterrs  Int64VectorVector_swigregisterr  "VectorTransformVector_swigregisterr  !OperatingPointVector_swigregisterr  #InvertedListsPtrVector_swigregisterr  RepeatVector_swigregisterr  +ClusteringIterationStatsVector_swigregisterr?  !ParameterRangeVector_swigregisterr^  (MaybeOwnedVectorUInt8Vector_swigregisterr  (MaybeOwnedVectorInt32Vector_swigregisterr  *MaybeOwnedVectorFloat32Vector_swigregisterr   OnDiskOneListVector_swigregisterr  r  r  PartitionStats_swigregisterr  r  r
  r  r  r  BitstringWriter_swigregistercvarr.  BitstringReader_swigregisterrB  rH  rK  rP  rV  rZ  rb  re  rh  rj  rl  rn  rq  rs  rv  rx  rz  r|  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  CodeSet_swigregisterhamdis_tab_ham_bytesr  "CombinerRangeKNNfloat_swigregisterr  "CombinerRangeKNNint16_swigregisterrE  rI  rK  rM  rO  rZ  r\  rc  rg  ri  rm  rp  rr  rt  ry  r{  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  RandomGenerator_swigregisterr  &SplitMix64RandomGenerator_swigregisterr  r  r  r  r  r   r  r  r  r  r  r  r  r  r  METRIC_INNER_PRODUCT	METRIC_L2	METRIC_L1METRIC_Linf	METRIC_LpMETRIC_CanberraMETRIC_BrayCurtisMETRIC_JensenShannonMETRIC_JaccardMETRIC_NaNEuclideanMETRIC_GOWERr  FAISS_VERSION_MAJORFAISS_VERSION_MINORFAISS_VERSION_PATCHVERSION_STRINGFloat32Float16UInt8Int8r"  r%  SearchParameters_swigregisterr2  Index_swigregisterr  DistanceComputer_swigregisterr  %NegativeDistanceComputer_swigregisterr  &FlatCodesDistanceComputer_swigregisterr"  IOReader_swigregisterr8  IOWriter_swigregisterrH  VectorIOReader_swigregisterr[  VectorIOWriter_swigregisterrj  FileIOReader_swigregisterr  FileIOWriter_swigregisterr  BufferedIOReader_swigregisterr  BufferedIOWriter_swigregisterr  r  r  r  "MaybeOwnedVectorOwner_swigregisterr  $MmappedFileMappingOwner_swigregisterr  MappedFileIOReader_swigregisterr  ZeroCopyIOReader_swigregisterr3  IndexFlatCodes_swigregisterry  IndexFlat_swigregisterr  IndexFlatIP_swigregisterr  IndexFlatL2_swigregisterr  IndexFlatPanorama_swigregisterr   IndexFlatL2Panorama_swigregisterr	  IndexFlat1D_swigregisterr(	  !ClusteringParameters_swigregisterrW	  %ClusteringIterationStats_swigregisterro	  Clustering_swigregisterr	  Clustering1D_swigregisterr	  /ProgressiveDimClusteringParameters_swigregisterr	  'ProgressiveDimIndexFactory_swigregisterr	  %ProgressiveDimClustering_swigregisterr	  r	  r	  r	  r	  Quantizer_swigregisterr	  ProductQuantizer_swigregisterr
  PQEncoderGeneric_swigregisterr
  PQEncoder8_swigregisterr
  PQEncoder16_swigregisterr
  PQDecoderGeneric_swigregisterr
  PQDecoder8_swigregisterr
  PQDecoder16_swigregisterr
  AdditiveQuantizer_swigregisterr  r  r  !RefineBeamMemoryPool_swigregisterr  r  $RefineBeamLUTMemoryPool_swigregisterr  r  3ComputeCodesAddCentroidsLUT0MemoryPool_swigregisterr  r  3ComputeCodesAddCentroidsLUT1MemoryPool_swigregisterr  r  ResidualQuantizer_swigregisterrB  !LocalSearchQuantizer_swigregisterr  IcmEncoder_swigregisterr  IcmEncoderFactory_swigregisterr  LSQTimer_swigregisterr  LSQTimerScope_swigregisterr  %ProductAdditiveQuantizer_swigregisterr+  (ProductLocalSearchQuantizer_swigregisterr5  %ProductResidualQuantizer_swigregisterr?  CodePacker_swigregisterrf  CodePackerFlat_swigregisterr|  Panorama_swigregisterr  PanoramaStats_swigregisterr  VectorTransform_swigregisterr  LinearTransform_swigregisterr  !RandomRotationMatrix_swigregisterr,  PCAMatrix_swigregisterrZ  ITQMatrix_swigregisterro  ITQTransform_swigregisterr  OPQMatrix_swigregisterr  %RemapDimensionsTransform_swigregisterr  #NormalizationTransform_swigregisterr  CenteringTransform_swigregisterr  )SearchParametersPreTransform_swigregisterr  IndexPreTransform_swigregisterrU  (IndexRefineSearchParameters_swigregisterre  IndexRefine_swigregisterr  IndexRefineFlat_swigregisterr  IndexLSH_swigregisterr  )SimulatedAnnealingParameters_swigregisterr  !PermutationObjective_swigregisterr  (ReproduceDistancesObjective_swigregisterrB  (SimulatedAnnealingOptimizer_swigregisterrb  PolysemousTraining_swigregisterr  IndexPQ_swigregisterr  SearchParametersPQ_swigregisterr  IndexPQStats_swigregisterr   MultiIndexQuantizer_swigregisterr  !MultiIndexQuantizer2_swigregisterr/  #IndexAdditiveQuantizer_swigregisterrL  #IndexResidualQuantizer_swigregisterr_  &IndexLocalSearchQuantizer_swigregisterrn  *IndexProductResidualQuantizer_swigregisterr  -IndexProductLocalSearchQuantizer_swigregisterr  $AdditiveCoarseQuantizer_swigregisterr  4SearchParametersResidualCoarseQuantizer_swigregisterr  $ResidualCoarseQuantizer_swigregisterr  'LocalSearchCoarseQuantizer_swigregisterr  "InvertedListsIterator_swigregisterr  InvertedLists_swigregisterry  ArrayInvertedLists_swigregisterr  'ArrayInvertedListsPanorama_swigregisterr  "ReadOnlyInvertedLists_swigregisterr   HStackInvertedLists_swigregisterr  SliceInvertedLists_swigregisterr:   VStackInvertedLists_swigregisterra   MaskedInvertedLists_swigregisterr  #StopWordsInvertedLists_swigregisterr   InvertedListsIOHook_swigregisterr  BlockInvertedLists_swigregisterr
  r  r  r  DirectMap_swigregisterrN  DirectMapAdd_swigregisterri  Level1Quantizer_swigregisterr   SearchParametersIVF_swigregisterr  IndexIVFInterface_swigregisterr  IndexIVF_swigregisterrj   InvertedListScanner_swigregisterr  IndexIVFStats_swigregisterr  r  r  r  r  r  r  SlidingIndexWindow_swigregisterr  r  r  r  r  r  r  ShardingFunction_swigregisterr  $DefaultShardingFunction_swigregisterr  r  r  ScalarQuantizer_swigregisterri  !IndexScalarQuantizer_swigregisterr  $IndexIVFScalarQuantizer_swigregisterr  !IndexIVFSpectralHash_swigregisterr  &IndexIVFAdditiveQuantizer_swigregisterr  &IndexIVFResidualQuantizer_swigregisterr  )IndexIVFLocalSearchQuantizer_swigregisterr  -IndexIVFProductResidualQuantizer_swigregisterr#  0IndexIVFProductLocalSearchQuantizer_swigregisterr/  !SearchParametersHNSW_swigregisterrB  HNSW_swigregisterr  HNSWStats_swigregisterr  r  r  r  r  IndexHNSW_swigregisterrB  IndexHNSWFlat_swigregisterrM  IndexHNSWPQ_swigregisterrZ  IndexHNSWSQ_swigregisterrd  IndexHNSW2Level_swigregisterrv  IndexHNSWCagra_swigregisterr  r  r  Neighbor_swigregisterr  Nhood_swigregisterr  NNDescent_swigregisterr&  IndexNNDescent_swigregisterrF  IndexNNDescentFlat_swigregisterrP  IndexIVFFlat_swigregisterrm  IndexIVFFlatDedup_swigregisterr  !IndexIVFFlatPanorama_swigregisterr  r  NSG_swigregisterr  NSG_Graph_int_swigregisterr  IndexNSG_swigregisterrK  IndexNSGFlat_swigregisterrU  IndexNSGPQ_swigregisterrc  IndexNSGSQ_swigregisterrm  OnDiskOneList_swigregisterr~   OnDiskInvertedLists_swigregisterr  ZnSphereSearch_swigregisterr  EnumeratedVectors_swigregisterr  Repeat_swigregisterr-  Repeats_swigregisterrG  ZnSphereCodec_swigregisterrc  ZnSphereCodecRec_swigregisterr  ZnSphereCodecAlt_swigregisterr  IndexLattice_swigregisterr  "IVFPQSearchParameters_swigregisterr  IndexIVFPQ_swigregisterr7  r9  IndexIVFPQStats_swigregisterrR  IndexIVFPQR_swigregisterr  Index2Layer_swigregisterr  +FastScanDistancePostProcessing_swigregisterr  IndexFastScan_swigregisterr&  FastScanStats_swigregisterr>  +IndexAdditiveQuantizerFastScan_swigregisterri  +IndexResidualQuantizerFastScan_swigregisterrv  .IndexLocalSearchQuantizerFastScan_swigregisterr  2IndexProductResidualQuantizerFastScan_swigregisterr  5IndexProductLocalSearchQuantizerFastScan_swigregisterr  IndexPQFastScan_swigregisterr  simd16uint16_swigregisterr  SIMDResultHandler_swigregisterr  %SIMDResultHandlerToFloat_swigregisterr   DummyResultHandler_swigregisterr  StoreResultHandler_swigregisterr-  IndexIVFFastScan_swigregisterr  IVFFastScanStats_swigregisterr  .IndexIVFAdditiveQuantizerFastScan_swigregisterr  1IndexIVFLocalSearchQuantizerFastScan_swigregisterr  .IndexIVFResidualQuantizerFastScan_swigregisterr  8IndexIVFProductLocalSearchQuantizerFastScan_swigregisterr  5IndexIVFProductResidualQuantizerFastScan_swigregisterr%  )IndexIVFIndependentQuantizer_swigregisterrE  IndexIVFPQFastScan_swigregisterrk  ro  rq  rw  rz  r|  IndexBinary_swigregisterr  IndexBinaryFlat_swigregisterr  IndexBinaryIVF_swigregisterr[   &BinaryInvertedListScanner_swigregisterrr   !IndexBinaryFromFloat_swigregisterr   IndexBinaryHNSW_swigregisterr   !IndexBinaryHNSWCagra_swigregisterr   IndexBinaryHash_swigregisterr   !IndexBinaryHashStats_swigregisterr!  !IndexBinaryMultiHash_swigregisterr,!  ThreadedIndexBase_swigregisterrT!  $ThreadedIndexBaseBinary_swigregisterrp!  IndexShards_swigregisterr!  IndexBinaryShards_swigregisterr!  IndexShardsIVF_swigregisterr!  IndexReplicas_swigregisterr!   IndexBinaryReplicas_swigregisterr"  IndexSplitVectors_swigregisterrD"  IndexRandom_swigregisterr\"  #IndexRowwiseMinMaxBase_swigregisterru"  #IndexRowwiseMinMaxFP16_swigregisterr"  IndexRowwiseMinMax_swigregisterr"  Linear_swigregisterr"  Embedding_swigregisterr"  FFN_swigregisterr"  QINCoStep_swigregisterr#  NeuralNetCodec_swigregisterr&#  QINCo_swigregisterrF#  Tensor2D_swigregisterrg#  Int32Tensor2D_swigregisterr#   IndexNeuralNetCodec_swigregisterr#  IndexQINCo_swigregisterr#  RaBitQuantizer_swigregisterr#  #RaBitQDistanceComputer_swigregisterr#  BaseFactorsData_swigregisterr$  FactorsData_swigregisterr$  ExFactorsData_swigregisterr+$  QueryFactorsData_swigregisterrG$  rI$  rN$  rP$  rT$  rY$  r[$  r^$  r`$  rd$  #RaBitQSearchParameters_swigregisterZ_MAX_BY_QBrr$  IndexRaBitQ_swigregisterr$   IndexRaBitQFastScan_swigregisterr$  &IVFRaBitQSearchParameters_swigregisterr$  IndexIVFRaBitQ_swigregisterr$  #IndexIVFRaBitQFastScan_swigregisterr)%  RangeSearchResult_swigregisterrC%  BufferList_swigregisterrb%  RangeQueryResult_swigregisterrx%  %RangeSearchPartialResult_swigregisterr%  InterruptCallback_swigregisterr%  TimeoutCallback_swigregisterr%  VisitedTable_swigregisterr%  IDSelector_swigregisterr%  IDSelectorRange_swigregisterr&  IDSelectorArray_swigregisterr,&  IDSelectorBatch_swigregisterr=&  IDSelectorBitmap_swigregisterrO&  IDSelectorNot_swigregisterr_&  IDSelectorAll_swigregisterrl&  IDSelectorAnd_swigregisterr&  IDSelectorOr_swigregisterr&  IDSelectorXOr_swigregisterr&  !IDSelectorTranslated_swigregisterr&  IndexIDMap_swigregisterr&  IndexBinaryIDMap_swigregisterr5'  IndexIDMap2_swigregisterr\'  IndexBinaryIDMap2_swigregister
EXACT_TOPKAPPROX_TOPK_BUCKETS_B32_D2APPROX_TOPK_BUCKETS_B8_D3APPROX_TOPK_BUCKETS_B16_D2APPROX_TOPK_BUCKETS_B8_D2r}'  r'  r'  r'  r'  r'  r'  r'  r'  r'  r'  r'  r'  r'  r'  r'  r'  r'  Cloner_swigregisterIO_FLAG_SKIP_STORAGEIO_FLAG_READ_ONLYIO_FLAG_ONDISK_SAME_DIRIO_FLAG_SKIP_IVF_DATAIO_FLAG_SKIP_PRECOMPUTE_TABLEIO_FLAG_PQ_SKIP_SDC_TABLEIO_FLAG_MMAPIO_FLAG_MMAP_IFCr'  r'  r'  AutoTuneCriterion_swigregisterr'  "OneRecallAtRCriterion_swigregisterr'  "IntersectionCriterion_swigregisterr'  OperatingPoint_swigregisterr(  OperatingPoints_swigregisterr?(  ParameterRange_swigregisterrN(  ParameterSpace_swigregisterr(  r(  r(  MatrixStats_swigregisterr(  PyCallbackIOWriter_swigregisterr(  PyCallbackIOReader_swigregisterr(  !PyCallbackIDSelector_swigregisterr)  'PyCallbackShardingFunction_swigregisterr)  "float_minheap_array_t_swigregisterrf)   int_minheap_array_t_swigregisterr)  "float_maxheap_array_t_swigregisterr)   int_maxheap_array_t_swigregisterr)  r)  r)  AlignedTableUint8_swigregisterr*  AlignedTableUint16_swigregisterrF*   AlignedTableFloat32_swigregisterrm*  "MaybeOwnedVectorUInt8_swigregisterr*  "MaybeOwnedVectorInt32_swigregisterr*  $MaybeOwnedVectorFloat32_swigregisterr$+  r'+  r)+  r++  r-+  MapLong2Long_swigregisterrD+  rG+  rI+  rL+  $PythonInterruptCallback_swigregisterr\+  r^+  r`+  rc+  re+  rg+  ri+  rk+  r%   r$   r   <module>r,     sI*   :#/"[
L$ L
8V 8v  & &~ 600 7F 7<  % %m 47F 7<  % %m 44 4<  " ": .5& 5<  # #K 05& 5<  # #K 05& 5<  # #K 05& 5<  # #K 066 6<  $ $\ 266 6<  $ $\ 266 6<  $ $\ 2=& =<  + +,? @; ;<  ) )*; <; ;<  ) )*; <; ;<  ) )*; <?F ?<  - -.C D>6 ><  , ,-A B@V @<  . ./E F66 6<  $ $\ 2HV H<  6 67U V>6 ><  , ,-A BE& E<  3 34O PE& E<  3 34O PGF G<  5 56S T=& =<  + +,? @BC8V 8  & &~ 6)00+=9f 9  ' ' 89f 9  ' ' 8A-*BW0VNRIT-6/6$$%+*-,$%)#1)8A[".2	:**2J&55+%1f 1    (00 %?F %?P  - -.C D%?F %?P  - -.C D*2')_WL(>6TOo,	58/D&8+K$C$F"N"+/ZF'Ph$b$O Wk0; 9f  9F  ' ' 8&C &CR  1 12K L-.-,6/:92;G 86HVY!66  #  	   	 $$   	 1,, 00 !66 ** E 44  0&&
8 !44  44  44 **





:Vv V"  ( ()9 :zCF zCz	   e $:v :@  ( ()9 :B/ B0  0 01I JC 0 C$  1 12K L2v 2       *2v 2       *8X 8  & &~ 6
8X 
8  & &~ 6<8 <"  $ $\ 2<8 <"  $ $\ 2:x :4  ( ()9 ::x :$  ( ()9 :$(.`F `  - -.C D=3 =  / /0G H< <(  * *+= >@x @0  ( ()9 :F8U F8R  & &~ 6,3 ,3^  ! !) ,5) 5  # #K 05) 5.  # #K 01;	 1;h  ) )*; <=+ ="  + +,? @5+ 5<  # #K 0,>6 ,>^  , ,-A BBv B  0 01I J<4% <4~  " ": .6: 6$  $ $\ 2L)= L  : :;] ^j j  2 23M NBA B>  0 01I J?&f`M(3 (3V  ! !) ,b:y b:J  ( ()9 ::v :   ( ()9 :
4 
4  " ": .
5& 
5  # #K 0:v :"  ( ()9 :4 4  " ": .5& 5  # #K 0z;	 z;z  ) )*; < 5D9,>6 >  , ,-A Bx
Af 
A  / /0G HvPV P  > >?e f`PV P  > >?e f`n;) n;b  ) )*; <WQ, WQt  , ,-A BO O@  " ": .	X 	X  ) )*; <2v 20      *7F 7   % %m 4]`0 ]`@  0 01I JE": E2  3 34O PB7 B2  0 01I J4 4>  " ": .8Z 8.  & &~ 692v 92x      *7F 72  % %m 4<9f <9~  ' ' 8-9o -9`  ' ' 8>? >&  , ,-A B(3 (3V  ! !) ,3 32  ! !) ,6? 62  $ $\ 23 3@  ! !) ,'B 'BT  0 01I J@_ @,  . ./E F< <6  * *+= >F#3 F  4 45Q RY; Y;x  ) )*; <l"2 l  3 34O P35% 35l  # #K 09k 9$  ' ' 8-@~ -@`      *F6 F&  4 45Q R>6 >$  , ,-A B!E"6 !EH  3 34O PE"> E.  3 34O P,<5 ,<^  * *+= >P1n P1f    (
<) 
<  * *+= >66 6(  $ $\ 2#=% #=L  + +,? @>. >&  , ,-A B@^ @0  . ./E F!@3 !@H  . ./E FC 6 C<  1 12K L!G$: !GH  5 56S T!J'= !JH  8 89Y ZAe AD  / /0G HD.> D  ? ?@g h0A5 0Af  / /0G HD!8 D6  2 23M NGF G.  - -.C DE=F E=P  % %m 4#< #<L  * *+= >.D!3 .Db  2 23M N?M ?(  - -.C D"=/ "=J  + +,? @#<. #<L  * *+= >!=/ !=H  + +,? @(=/ (=V  + +,? @%@2 %@P  . ./E F6J& 6Jr  + +,? @1< 1<h  * *+= >0$$63 63r  ! !) ,66 6*  $ $\ 2%9f %9P  ' ' 8
\* 
\  + +,? @@; @;F  ) )*; <e@u' e@P	      *D=& D=N  + +,? @7F 7*  % %m 4A/3<A@< <>  * *+= >7<nn@W	:v 	:  ( ()9 :	A. 	A  / /0G H7.>P9i P9f  ' ' 8">> ">J  , ,-A B&Ah &AR  / /0G H=>8 =>@  , ,-A B"C "CJ  1 12K LC 9 C0  1 12K LF#< F2  4 45Q RJ'@ J6  8 89Y ZM*C M6  ; ;<_ `	^+ 	^  , ,-A Bf.6 f.R   T "3 3(  ! !) ,mSW}F@ F@R  ! !) ,7I 7  % %m 45) 5"  # #K 05) 5  # #K 09i 9$  ' ' 8!8Y !8H  & &~ 66";02v 2      */F /$   e $3g 3gl  ! !) ,5U 5D  & &~ 6< <  * *+= >68 6B  $ $\ 2%; %;P  ) )*; <%>< %>P  , ,-A B93-& 3-l   C  JF J&  % %m 40Ju 0Jf      *68 6  $ $\ 24 4"  " ": .4 4  " ": .	7F 	7  % %m 4aa- aaH  + +,? @'8V '8T  & &~ 6; ;8  ) )*; <0V 0   v &1f 14    (7N$5 7<  % %m 4+:( +:\  ( ()9 ::} :,  ( ()9 :6> 6:  $ $\ 2?/ ?  - -.C Dh4 h4V  " ": .H9f 9*  ' ' 8(5* (5V  # #K 0&C. &CR  # #K 0HV H@  6 67U VJ7E J7Z  % %m 47F 7   % %m 4BV] BVJ  6 67U V"H%C "HJ  6 67U V"K(F "KJ  9 9:[ \&O,J &OR  = =>c d&R/M &RR  @ @Ai j)9m )9X  ' ' 866 6  $ $\ 2; ;2  ) )*; <"B0 "BJ  0 01I JZ* Z*  * *+= ><* <2  * *+= >{Hx {H|  ( ()9 ::v :6  ( ()9 :7u(8 7ut  9 9:[ \N+L N  < <=a bK(I K  9 9:[ \U2S U  C CDo pR/P R  @ @Ai jF5 F>  4 45Q R4<) 4<n  * *+= >FOr&~CI& ID  # #K 0&9k &9R  ' ' 8pI[ pIf  & &~ 6)C )CX  1 12K LA; A@  , ,-A B$6k $6N  ' ' 8>? >:  , ,-A B 9k  9F  ' ' 8>6 >   , ,-A BD; D@  , ,-A B<H <H~  ) )*; <<Tk <T~  / /0G Hq5# q5h  # #K 0q;/ q;h  ) )*; <8[/ 84  & &~ 6[7% [7|  % %m 4[=1 [=|  + +,? @"; ";J  ) )*; <5% 56  # #K 0-KU -K`  . ./E F@3 @4  . ./E F</ <4  * *+= >0V 0$   v &3 3(  ! !) ,-& -&   C  3 3:  ! !) ,8V 8"  & &~ 6/N /.   e $2v 24      *7F 74  % %m 4=. =*  + +,? @4$ 4  " ": .8Y 8B  & &~ 6@6 @:  . ./E F9f 9$  ' ' 85/ 5   # #K 07F 7"  % %m 4:v :*  ( ()9 :J&f*f$r4<<88C"@- @  . ./E F5. 5D  # #K 09=- 9=x  + +,? @C 3 C  1 12K L 8X  8F  & &~ 6E@- E@P  . ./E F; ;:  ) )*; <R R@  " ": .:v :$  ( ()9 :"Bz "BJ  0 01I J(C (CV  ) )*; <9' 9*  ' ' 866 62  $ $\ 24 4  " ": .9j 96  ' ' 89j 9<  ' ' 89j 9D  ' ' 8:z :2  ( ()9 :7J 7  % %m 4PJ P  % %m 47J 7&  % %m 46: 6&  $ $\ 27J 7&  % %m 4>: >  , ,-A B>O >OB  " ": .>[{ >[B  ( ()9 :#Q* #QL  # #K 0#]( #]L  ) )*; <""
'BB &@@ 'BB &@@ ,3215-)0(/32342;(BV B0   v &00 ** 66 22  $ B B  ::   (( -0(; (;V  ) )*; <
?- 
?  - -.C D
?- 
?  - -.C D8V 8,  & &~ 6"9f "9J  ' ' 8
8V 
8  & &~ 6Q8V Q8h  & &~ 6+I5& 5@  # #K 0< <$  * *+= >< <$  * *+= >
>: 
>  , ,-A B
o!1 
o  2 23M NR?F R?j  - -.C DR=& R=j  + +,? @R?F R?j  - -.C DR=& R=j  + +,? @TT!; !;H  ) )*; <!< !<H  * *+= >!=& !=H  + +,? @,?F ,?^  - -.C D,?F ,?^  - -.C D,Af ,A^  / /0G H994466 6&  $ $\ 27,+A/ A   / /0G H"*33312%Op  s   Bv  v 
Bv.v-Bv.