예제 #1
0
/// Sample random point from the surface of a Dim-dimensional unit sphere.
void GetSphereDev(const int& Dim, TRnd& Rnd, TFltV& ValV) {
  if (ValV.Len() != Dim) { ValV.Gen(Dim); }
  double Length = 0.0;
  for (int i = 0; i < Dim; i++) {
    ValV[i] = Rnd.GetNrmDev();
    Length += TMath::Sqr(ValV[i]); }
  Length = 1.0 / sqrt(Length);
  for (int i = 0; i < Dim; i++) {
    ValV[i] *= Length;
  }
}
예제 #2
0
파일: lsh.cpp 프로젝트: EDzhangjianyu/snap
TLSHash::EuclideanHash::EuclideanHash(TRnd &Gen, int Dim) {
  for (int j=0; j<Dim; j++) {
    Line.Add(Gen.GetNrmDev());
  }
  Line.Add(Gen.GetUniDevInt(Gap));
}