17 #include "DGtal/arithmetic/LighterSternBrocot.h"
22 using namespace DGtal;
26 void usage(
int,
char** argv )
28 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <p> <q>" << std::endl;
29 std::cerr <<
"\t - computes the successive convergent of the fraction p / q." << std::endl;
35 int main(
int argc,
char** argv )
42 std::string inputP = argv[ 1 ];
43 std::string inputQ = argv[ 2 ];
49 typedef SB::Fraction Fraction;
50 typedef Fraction::ConstIterator ConstIterator;
51 typedef Fraction::Value Value;
63 ConstIterator itbegin = f.begin(), itend = f.end();
64 for ( ConstIterator it = itbegin; it != itend; ++it )
67 std::cout << ( ( it == itbegin ) ?
"[" :
"," )
70 std::cout <<
"]" << std::endl;
75 for ( ConstIterator it = itbegin; it != itend; ++it )
78 std::cout <<
"z_" << u.second <<
" = ";
80 std::cout << g.p() <<
" / " << g.q() << std::endl;