#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-biginteger.
This file is part of the DGtal library.
Definition in file convergents-biginteger.cpp.
◆ main()
int main |
( |
int | argc, |
|
|
char ** | argv ) |
Main.
[convergents-biginteger-types]
[convergents-biginteger-types]
[convergents-biginteger-instantiation]
[convergents-biginteger-instantiation]
[convergents-biginteger-cfrac]
[convergents-biginteger-cfrac]
[convergents-biginteger-convergents]
[convergents-biginteger-convergents]
Definition at line 61 of file convergents-biginteger.cpp.
62{
63 if ( argc < 3 )
64 {
65 usage( argc, argv );
66 return 1;
67 }
68 std::string inputP = argv[ 1 ];
69 std::string inputQ = argv[ 2 ];
70
75 typedef SB::Fraction Fraction;
77 typedef Fraction::Value
Value;
79
83 Fraction f( p, q );
85
87
88 std::cout << "z = ";
91 {
93 std::cout << ( ( it == itbegin ) ? "[" : "," )
94 << u.first;
95 }
96 std::cout << "]" << std::endl;
98
100 Fraction g;
102 {
104 std::cout << "z_" << u.second << " = ";
105 g.push_back( u );
106 std::cout << g.p() << " / " << g.q() << std::endl;
107 }
109 return 0;
110}
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
Point::Coordinate Integer
MyDigitalSurface::ConstIterator ConstIterator
boost::int64_t int64_t
signed 94-bit integer.
mpz_class BigInteger
Multi-precision integer with GMP implementation.
◆ usage()
void usage |
( |
int | , |
|
|
char ** | argv ) |
Definition at line 52 of file convergents-biginteger.cpp.
53{
54 std::cerr << "Usage: " << argv[ 0 ] << " <p> <q>" << std::endl;
55 std::cerr << "\t - computes the successive convergent of the fraction p / q." << std::endl;
56}