check_modulo.cc

Go to the documentation of this file.
00001 
00006 // only for testing the functions
00007 
00008 
00009 #include "modulo.cc"
00010 
00011 using namespace std;
00012 using namespace numtheory;
00013 
00014 
00015 bool test01()
00016 {
00017   unsigned int v=0;
00018   for (unsigned int p=10000001; p<10020000; p+=2)
00019    {
00020      if (!probab_prime(p)) continue;
00021      for (unsigned int a=7000000 ; a<7015000; ++a)
00022       //v|=powmod(a,p-2,p);
00023       v|=invmod(a,p);
00024    }
00025   cout << v << endl;
00026   return true;
00027 }
00028 
00029 int main()
00030 {
00031  //test01();
00032  //return 0;
00033 
00034 #if 0
00035  // test oddgcd
00036  cout << oddgcd(100,200) << endl;
00037  cout << oddgcd(20,81) << endl;
00038  cout << oddgcd(35,25) << " " << oddgcd(25,35) << endl;
00039  cout << oddgcd(5551150,11350) << " " << oddgcd(5551150,11350) << endl;
00040  return 1;
00041 #endif
00042 
00043 #if 1
00044  while(true)
00045   {
00046     unsigned int x,m;
00047     cout << "x= " << flush; cin >> x;
00048     cout << "m= " << flush; cin >> m;
00049     cout << "coprime: " << coprime(x,m) << endl;
00050     unsigned int y;
00051     y=invmod(x,m);
00052     cout << "invmod: " << y << " = 1/" << x << " (mod " << m << ")" << endl;
00053     cout << "valid? " << (mulmod(x,y,m)==1) << endl;
00054     y=bininvmod(x,m);
00055     cout << "bininvmod: " << y << " = 1/" << x << " (mod " << m << ")" << endl;
00056     cout << "valid? " << (mulmod(x,y,m)==1) << endl;
00057     y=montgominvmod(x,m);
00058     cout << "montgominvmod: " << y << " = 1/" << x << " (mod " << m << ")" << endl;
00059     cout << "valid? " << (mulmod(x,y,m)==1) << endl;
00060   }
00061 #endif
00062 
00063 #if 0
00064  signed int a,m;
00065   cout << "a= " << flush; cin >> a;
00066   cout << "m= " << flush; cin >> m;
00067 //  cout << a%m << " <-> " << normalized_signed_mod(a,m) << endl;
00068   a=normalized_signed_mod(a,m);
00069   cout << a << endl;
00070 #endif
00071   return 0;
00072 }

Generated on Wed Nov 7 23:29:25 2007 for Qsieve by  doxygen 1.5.4