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 )
45 typedef SB::Fraction Fraction;
46 typedef Fraction::ConstIterator ConstIterator;
47 typedef Fraction::Value Value;
59 ConstIterator itbegin = f.begin(), itend = f.end();
60 for ( ConstIterator it = itbegin; it != itend; ++it )
63 std::cout << ( ( it == itbegin ) ?
"[" :
"," )
66 std::cout <<
"]" << std::endl;
71 for ( ConstIterator it = itbegin; it != itend; ++it )
74 std::cout <<
"z_" << u.second <<
" = ";
76 std::cout << g.p() <<
" / " << g.q() << std::endl;