00001
00007 #include "at_startup.H"
00008 #include <fstream>
00009 #include <sstream>
00010 #include <gmp.h>
00011 #include "qsieve.H"
00012 #include "StaticFactorbase.H"
00013
00014 using namespace std;
00015
00016 const string RecoveryFile = "recovery.dat";
00017 const string StaticRelationsFile = "static_relations.dat";
00018 const string SpecialRelationsFile = "special_relations.dat";
00019
00020
00021
00022 filebuf Recovery_buffer;
00023 ostream Recovery_to_file (&Recovery_buffer);
00024 istream Recovery_from_file (&Recovery_buffer);
00025
00026
00027 mpz_t n,
00028 kN;
00029
00030
00031
00032 #include "StaticRelations.H"
00033 #include "Sieving.H"
00034 CRelation* StaticRelations::GLS[StaticFactorbase::MaxSize] = {NULL};
00035 int StaticRelations::Filling_GLS = 0;
00036
00037
00038
00039 CmpqsFactor CRelation::combine(istream&)
00040 {
00041 return CmpqsFactor();
00042 }
00043
00044 CmpqsFactor CRelation::multi_combine_main(istream &)
00045 {
00046 return CmpqsFactor();
00047 }
00048
00049
00050 #include "ConfigFile.cc"
00051
00052
00053
00054 int main(const int argc, const char* const *)
00055 {
00056
00057 PrintHeader("Qsieve relation validator");
00058 cout.setf(ios::fixed);
00059
00060 if (argc!=1) exit(1);
00061
00062 mpz_init(n);
00063 mpz_init(kN);
00064
00065 Read_ConfigFile();
00066
00067 Recovery_buffer.open(RecoveryFile.c_str(),ios::in|ios::out|ios::ate);
00068
00069
00070 if (Recovery_from_file) Recovery_from_file.seekg(0,ios::end);
00071 #ifdef STL_STREAM_workaround
00072 if ( (!Recovery_from_file) || (Recovery_from_file.tellg()==std::streampos(0)) || (Recovery_from_file.tellg()==std::streampos(-1)) )
00073
00074
00075
00076
00077
00078 #else
00079 if ( (!Recovery_from_file) || (Recovery_from_file.tellg()<1) )
00080 #endif
00081 {
00082 cerr << "No recovery data found. Cannot validate!" << endl;
00083 exit(1);
00084 }
00085
00086 Recovery_from_file.seekg(0,ios::beg);
00087 Recovery_to_file.seekp(0,ios::beg);
00088 Recovery_from_file >> n;
00089 Recovery_from_file.ignore(1,'\n');
00090
00091 cout << "Checking relations for" << endl;
00092 cout << n << endl;
00093
00094 determine_best_MPQS_Multiplier(n,kN,MPQS_Multiplier);
00095 tune_parameters(mpz_sizeinbase(n,10));
00096
00097 #ifdef VERBOSE_NOTICE
00098 cout << "n=" << n << endl;
00099 cout << "Size of static factorbase: " << StaticFactorbase::Size() << endl;
00100 cout << "Factor-Threshold (Exponent): " << Factor_Threshold << endl;
00101 cout << "Sieveinterval per polynomial: [" << -LogicalSieveSize << "," << LogicalSieveSize << "]" << endl;
00102 #endif
00103
00104 if ( sqrt(mpz_get_d(kN)) < PhysicalSieveSize )
00105 {
00106 cerr << "Sieve size too big (you may want to reduce its size)!" << endl;
00107 exit(1);
00108 }
00109
00110 StaticFactorbase::compute_StaticFactorbase();
00111
00112
00113 CRelation::SanityCheckRelationsFile(StaticRelationsFile);
00114 CRelation::SanityCheckRelationsFile(DynamicRelationsFile);
00115 CRelation::SanityCheckRelationsFile(SpecialRelationsFile);
00116 return 0;
00117 }