#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include "DGtal/arithmetic/IntegerComputer.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 extended-euclid.
This file is part of the DGtal library.
Definition in file extended-euclid.cpp.
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Main.
[extended-euclid-types]
[extended-euclid-types]
[extended-euclid-instantiation]
[extended-euclid-instantiation]
[extended-euclid-process]
[extended-euclid-process]
Definition at line 57 of file extended-euclid.cpp.
76 if ( ic.isZero( a ) || ic.isZero( b ) )
78 std::cerr <<
"[Error] parameters a and b should be non-null." << std::endl;
81 if ( ic.isNotZero( c % g ) )
83 std::cerr <<
"[Error] parameter c should be a multiple of gcd(a,b)." << std::endl;
89 IC::Vector2I X = ic.extendedEuclid( a, b, c );
90 std::cout <<
"x=" << X[ 0 ] <<
" y=" << X[ 1 ] << std::endl;
91 Integer d = a*X[ 0 ] + b*X[ 1 ];
94 std::cerr <<
"[Internal Error] Output of extended Euclid algorithm is incorrect: " << d <<
" != " << c
95 <<
". This should not happen." << std::endl;
Point::Coordinate Integer
void usage(int, char **argv)
mpz_class BigInteger
Multi-precision integer with GMP implementation.
References usage().
◆ usage()
void usage |
( |
int |
, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 47 of file extended-euclid.cpp.
49 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <a> <b> <c>" << std::endl;
50 std::cerr <<
"\t - solves the diophantine equation ax+by=c by the extended Euclid algorithm." << std::endl;
51 std::cerr <<
"\t - note: c should be a multiple of gcd(a,b)." << std::endl;
Referenced by main().