Computes a pattern from a given slope p / q.
- See also
- Patterns
# Pattern 5 / 12
$ ./examples/arithmetic/pattern 5 12
00010010001001001
# Pattern 5 / 12 with its recursive subdivision
$ ./examples/arithmetic/pattern 5 12 SUB
((0|(00|1)(00|1))(0|(00|1)(00|1))|(00|1))
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include "DGtal/arithmetic/LighterSternBrocot.h"
#include "DGtal/arithmetic/Pattern.h"
void usage(
int,
char** argv )
{
std::cerr << "Usage: " << argv[ 0 ] << " <p> <q> [SUB]" << std::endl;
std::cerr << "\t - computes the pattern of slope p / q and displays it." << std::endl;
std::cerr << "\t - the optional [SUB] parameter displays the pattern with its recursive Berstel decomposition." << std::endl;
}
int main(
int argc,
char** argv )
{
if ( argc < 3 )
{
return 1;
}
typedef LighterSternBrocot<Integer, Quotient, StdMapRebinder> SB;
typedef SB::Fraction Fraction;
typedef Pattern<Fraction> MyPattern;
MyPattern pattern( p, q );
bool sub = ( argc > 3 ) && ( std::string( argv[ 3 ] ) == "SUB" );
std::cout << ( ! sub ? pattern.rE() : pattern.rEs( "(|)" ) ) << std::endl;
return 0;
}
void usage(int, char **argv)
Point::Coordinate Integer
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::int32_t int32_t
signed 32-bit integer.
int main(int argc, char **argv)