Beispiel #1
0
void  Cmod<zz,zp,zpx,zzv,fftrep,zpContext>::FFT(zzv &y, const ZZX& x) const
{
  context.restore();
  zp rt;
  zpx in, out;

  conv(in,x);      // convert input to zpx format
  conv(rt, root);  // convert root to zp format

  BluesteinFFT(out, in, getM(), rt, *powers, *Rb); // call the FFT routine

  // copy the result to the output vector y, keeping only the
  // entries corresponding to primitive roots of unity
  y.SetLength(zmStar->phiM());
  unsigned i,j;
  for (i=j=0; i<getM(); i++)
    if (zmStar->inZmStar(i)) y[j++] = rep(coeff(out,i));
}
Beispiel #2
0
void Cmod<type>::FFT(zzv &y, const ZZX& x) const
{
  FHE_TIMER_START;
  zpBak bak; bak.save();
  context.restore();
  zp rt;
  zpx& tmp = getScratch();

  conv(tmp,x);      // convert input to zpx format
  conv(rt, root);  // convert root to zp format

  BluesteinFFT(tmp, getM(), rt, *powers, powers_aux, *Rb, Rb_aux, *Ra); // call the FFT routine

  // copy the result to the output vector y, keeping only the
  // entries corresponding to primitive roots of unity
  y.SetLength(zMStar->getPhiM());
  long i,j;
  long m = getM();
  for (i=j=0; i<m; i++)
    if (zMStar->inZmStar(i)) y[j++] = rep(coeff(tmp,i));
  FHE_TIMER_STOP;
}