DGtal  1.1.0
Functions
pattern.cpp File Reference
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include "DGtal/arithmetic/LighterSternBrocot.h"
#include "DGtal/arithmetic/Pattern.h"
Include dependency graph for pattern.cpp:

Go to the source code of this file.

Functions

void usage (int, char **argv)
 
int main (int argc, char **argv)
 

Detailed Description

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 pattern.

This file is part of the DGtal library.

Definition in file pattern.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Main.

[pattern-types]

[pattern-types]

[pattern-instantiation]

[pattern-instantiation]

[pattern-process]

[pattern-process]

Definition at line 59 of file pattern.cpp.

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 }

References usage().

◆ usage()

void usage ( int  ,
char **  argv 
)

Definition at line 49 of file pattern.cpp.

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 }

Referenced by main().

DGtal::int32_t
boost::int32_t int32_t
signed 32-bit integer.
Definition: BasicTypes.h:72
usage
void usage(int, char **argv)
Definition: pattern.cpp:49
DGtal::Z2i::Integer
DGtal::int32_t Integer
Definition: StdDefs.h:74
DGtal::Pattern< Fraction >
DGtal::LighterSternBrocot
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
Definition: LighterSternBrocot.h:109