finished ContFrac implementation

This commit is contained in:
2022-02-22 15:46:07 +01:00
parent a032344c66
commit 6c5f0eb68e
3 changed files with 178 additions and 22 deletions

45
t.cc
View File

@@ -2483,7 +2483,7 @@ ContFrac<int> z= x*Rational<int>({2,3});
cout<<Rational<int>(z)<<endl;
}
if(1)
if(0)
{
ContFrac<int> x(11,101);
ContFrac<int> v(3,7);
@@ -2497,6 +2497,49 @@ cout<<Rational<int>(zz)<<endl;
cout<<(Rational<int>(x)+3)*(Rational<int>(v)+4)/(Rational<int>(x)-Rational<int>(v))<<endl;
}
if(0)
{
double x;
cin >>x;
ContFrac<int> xx(x,15,100000);
cout <<xx<<endl;
ContFrac<int> xm= -xx;
cout<< xm<<endl;
cout<<xx+xm<<endl;
}
if(0)
{
Rational<int> x;
cin >>x;
ContFrac<int> xx(x);
cout<<xx;
ContFrac<int> xm= -xx;
cout<< xm;
ContFrac<int> yy(-x);
cout<<yy;
ContFrac<int> ym= -yy;
cout<< ym;
cout <<"ZEROs\n"<<xx+xm<<" "<<yy+ym<<" "<<xx+yy<<" "<<xm+ym<<endl;
}
if(1)
{
double x;
cin >>x;
ContFrac<int> xx(x,25,100000);
ContFrac<int> xx1(x+1e-4,25,100000);
ContFrac<int> xx2(x-1e-4,25,100000);
xx.canonicalize();
xx1.canonicalize();
xx2.canonicalize();
cout<<"small "<<xx2<<endl;
cout<<"middle "<<xx<<endl;
cout<<"big "<<xx1<<endl;
cout << "TEST "<<(xx<xx1) <<" "<<(xx>xx2) <<endl;
}
}