Пример #1
0
 string multiply(string num1, string num2) {
     bigint x, y, z;
     string result;
     
     to_bigint(num1, x);
     to_bigint(num2, y);
     
     multiply(x, y, z);
     to_string(z, result);
     if (result.size() == 0) result += '0';  // result is zero
     return result;
 }
Пример #2
0
ostream& operator<<(ostream& s,const Ring_Element& e)
{
  s << "[";
  if (e.rep==polynomial) { s << "P "; }
  else                   { s << "E "; }
  bigint te;
  for (int i=0; i<(*e.FFTD).phi_m(); i++) 
    { to_bigint(te,e.element[i],(*e.FFTD).get_prD());
      s << te << " ";
    }
  s << "]";
  return s;
}
Пример #3
0
void modp::output(ostream& s,const Zp_Data& ZpD,bool human) const
{
  if (human)
    { bigint te;
      to_bigint(te,*this,ZpD);
      if (te < ZpD.pr / 2)
          s << te;
      else
          s << (te - ZpD.pr);
    }
  else
    { s.write((char*) x,ZpD.t*sizeof(mp_limb_t)); }
}