#include <iostream>
#include "DGtal/arithmetic/LighterSternBrocot.h"
Go to the source code of this file.
|
void | usage (int, char **argv) |
|
int | main (int argc, char **argv) |
|
- Author
- Jacques-Olivier Lachaud (
jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr
) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
- Date
- 2012/02/06
An example file named convergents.
This file is part of the DGtal library.
Definition in file convergents.cpp.
◆ main()
int main |
( |
int | argc, |
|
|
char ** | argv ) |
Main.
[convergents-types]
[convergents-types]
[convergents-instantiation]
[convergents-instantiation]
[convergents-cfrac]
[convergents-cfrac]
[convergents-convergents]
[convergents-convergents]
Definition at line 55 of file convergents.cpp.
56{
57 if ( argc < 3 )
58 {
59 usage( argc, argv );
60 return 1;
61 }
62
65 typedef SB::Fraction Fraction;
67 typedef Fraction::Value
Value;
69
73 Fraction f( p, q );
75
77
78 std::cout << "z = ";
81 {
83 std::cout << ( ( it == itbegin ) ? "[" : "," )
84 << u.first;
85 }
86 std::cout << "]" << std::endl;
88
90 Fraction g;
92 {
94 std::cout << "z_" << u.second << " = ";
95 g.push_back( u );
96 std::cout << g.p() << " / " << g.q() << std::endl;
97 }
99 return 0;
100}
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
MyDigitalSurface::ConstIterator ConstIterator
boost::int64_t int64_t
signed 94-bit integer.
◆ usage()
void usage |
( |
int | , |
|
|
char ** | argv ) |
Definition at line 46 of file convergents.cpp.
47{
48 std::cerr << "Usage: " << argv[ 0 ] << " <p> <q>" << std::endl;
49 std::cerr << "\t - computes the successive convergent of the fraction p / q." << std::endl;
50}