Rational Reconstruction.
#include <iostream>
#include <givaro/zring.h>
#include <linbox/algorithms/rational-reconstruction-base.h>
#include <linbox/util/matrix-stream.h>
typedef Givaro::ZRing<Integer> Ints;
int main (int argc, char **argv)
{
srand48( time(NULL) );
x = x*rand()*rand()*rand()*rand()*rand()*rand();
m = m*rand()*rand()*rand()*rand()*rand()*rand()*rand()*rand();
if (x > m) {
integer t=x; x=m; m=t;}
cout << "Searching a,b: a =" << x << "b mod " << m << endl << flush;
cout << "size of m" << m.bitsize() << endl << flush;
Ints Z;
WangClassicRationalReconstruction<Ints> RRB(Z,true,false);
LinBox::UserTimer t;
t.clear();
t.start();
for (int i=0; i < 1 ; ++i) {
if (RR.reconstructRational(a,b,x,m,5)) {
cout << "Found a,b: "<< a <<"=" << x << "x" << b << " mod " << m << endl << flush;
cout << "Does agree with bounds\n";
}
else {
cout << "Found a,b: "<< a <<"=" << x << "x" << b << " mod " << m << endl << flush;
cout << "Does not agree with bounds\n";
}
}
t.stop();
cout << "Time:";
t.print(cout);
cout << endl;
return 0 ;
}