DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
pattern.cpp
Go to the documentation of this file.
1
13
31
34
#include <cstdlib>
35
#include <cmath>
36
#include <iostream>
37
#include <iomanip>
38
#include <string>
39
#include "DGtal/arithmetic/LighterSternBrocot.h"
40
#include "DGtal/arithmetic/Pattern.h"
42
44
45
using namespace
DGtal
;
46
48
49
void
usage
(
int
,
char
** argv )
50
{
51
std::cerr <<
"Usage: "
<< argv[ 0 ] <<
" <p> <q> [SUB]"
<< std::endl;
52
std::cerr <<
"\t - computes the pattern of slope p / q and displays it."
<< std::endl;
53
std::cerr <<
"\t - the optional [SUB] parameter displays the pattern with its recursive Berstel decomposition."
<< std::endl;
54
}
55
59
int
main
(
int
argc,
char
** argv )
60
{
61
if
( argc < 3 )
62
{
63
usage
( argc, argv );
64
return
1;
65
}
66
68
typedef
DGtal::int32_t
Integer
;
69
typedef
DGtal::int32_t
Quotient;
70
typedef
LighterSternBrocot<Integer, Quotient, StdMapRebinder>
SB;
// the type of the Stern-Brocot tree
71
typedef
SB::Fraction Fraction;
// the type for fractions
72
typedef
Pattern<Fraction>
MyPattern;
// the type for patterns
74
76
DGtal::int32_t
p = atoi( argv[ 1 ] );
77
DGtal::int32_t
q = atoi( argv[ 2 ] );
78
MyPattern pattern( p, q );
80
82
bool
sub = ( argc > 3 ) && ( std::string( argv[ 3 ] ) ==
"SUB"
);
83
std::cout << ( ! sub ? pattern.rE() : pattern.rEs(
"(|)"
) ) << std::endl;
85
return
0;
86
}
DGtal::LighterSternBrocot
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
Definition
LighterSternBrocot.h:109
DGtal::Pattern
Aim: This class represents a pattern, i.e. the path between two consecutive upper leaning points on a...
Definition
Pattern.h:79
Integer
Point::Coordinate Integer
Definition
examplePlaneProbingParallelepipedEstimator.cpp:44
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::int32_t
std::int32_t int32_t
signed 32-bit integer.
Definition
BasicTypes.h:71
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
usage
void usage(int, char **argv)
Definition
testPolynomial.cpp:58
examples
arithmetic
pattern.cpp
Generated on
for DGtal by
1.18.0