Esempio n. 1
0
int main() {
  TLSHash LSH(7, 7, DIM, TLSHash::EUCLIDEAN);
  LSH.Init();

  TRnd Gen;
  Gen.Randomize();

  TVec<TFltV> DataV;
  for (int i=0; i<1000000; i++) {
    TFltV Datum;
    for (int j=0; j<3; j++) {
      Datum.Add(Gen.GetUniDev()*2100);
    }
    DataV.Add(Datum);
  }
  LSH.AddV(DataV);
  
  TVec<TPair<TFltV, TFltV> > NeighborsV = LSH.GetAllCandidatePairs();
  printf("Number of Candidates: %d\n", NeighborsV.Len());

  NeighborsV = LSH.GetAllNearPairs();
  printf("Number of Close Pairs: %d\n", NeighborsV.Len());
  for (int i=0; i<NeighborsV.Len(); i++) {
    outputPoint(NeighborsV[i].GetVal1());
    printf(" ");
    outputPoint(NeighborsV[i].GetVal2());
    printf("\n");
  }
  return 0;
}
Esempio n. 2
0
void TLSHash::Init() {
  TRnd Gen;
  Gen.Randomize();

  for (int i=0; i<Bands*Rows; i++) {
    if (Type == JACCARD) {
      HashFuncV.Add(TPt<HashFunc>(new JaccardHash(Gen, Dim)));
    } else if (Type == COSINE) {
      HashFuncV.Add(TPt<HashFunc>(new CosineHash(Gen, Dim)));
    } else {
      HashFuncV.Add(TPt<HashFunc>(new EuclideanHash(Gen, Dim)));
    }
  }

  for (int i=0; i<Bands; i++) {
    SigBucketVHV.Add(THash<TInt, TIntV> (ExpectedSz, true));
  }
}