10 #ifndef FAISS_VECTOR_TRANSFORM_H
11 #define FAISS_VECTOR_TRANSFORM_H
49 virtual void train (idx_t n,
const float *x);
55 float *
apply (idx_t n,
const float * x)
const;
90 bool have_bias =
false);
93 void apply_noalloc(idx_t n,
const float* x,
float* xt)
const override;
102 float *x)
const override;
204 explicit OPQMatrix (
int d = 0,
int M = 1,
int d2 = -1);
226 void apply_noalloc(idx_t n,
const float* x,
float* xt)
const override;
242 void apply_noalloc(idx_t n,
const float* x,
float* xt)
const override;
260 void apply_noalloc(idx_t n,
const float* x,
float* xt)
const override;
264 float *x)
const override;
273 std::vector<VectorTransform *> chain;
289 void add(
idx_t n,
const float* x)
override;
293 void reset()
override;
304 idx_t* labels)
const override;
318 float *distances,
idx_t *labels,
319 float *recons)
const override;
Randomly rotate a set of vectors.
int niter
Number of outer training iterations.
RandomRotationMatrix(int d_in, int d_out)
both d_in > d_out and d_out < d_in are supported
void init(int seed)
must be called before the transform is used
int niter_pq
Number of training iterations for the PQ.
void train(Index::idx_t n, const float *x) override
std::vector< float > mean
Mean, size d_in.
std::vector< float > PCAMat
PCA matrix, size d_in * d_in.
long idx_t
all indices are this type
void train(Index::idx_t n, const float *x) override
int balanced_bins
try to distribute output eigenvectors in this many bins
void train(Index::idx_t n, const float *x) override
int niter_pq_0
same, for the first outer iteration
size_t max_train_points
if there are too many training points, resample
void copy_from(const PCAMatrix &other)
copy pre-trained PCA matrix
OPQMatrix(int d=0, int M=1, int d2=-1)
if d2 != -1, output vectors of this dimension
void prepare_Ab()
called after mean, PCAMat and eigenvalues are computed
std::vector< float > eigenvalues
eigenvalues of covariance matrix (= squared singular values)
bool random_rotation
random rotation after PCA
size_t max_points_per_d
ratio between # training vectors and dimension