34#include "DGtal/base/Common.h" 
   35#include "DGtal/kernel/CPointPredicate.h" 
   36#include "DGtal/arithmetic/IntegerComputer.h" 
   37#include "DGtal/arithmetic/SternBrocot.h" 
   38#include "DGtal/arithmetic/LightSternBrocot.h" 
   39#include "DGtal/arithmetic/LighterSternBrocot.h" 
   40#include "DGtal/arithmetic/Pattern.h" 
   42#include <boost/version.hpp> 
   43#include <boost/random/mersenne_twister.hpp> 
   44#include <boost/random/uniform_smallint.hpp> 
   45#include <boost/random/variate_generator.hpp> 
   55template <
typename Fraction1, 
typename Fraction2>
 
   61  Fraction2 f2( f1.p(), f1.q() );
 
   64  f1.selfDisplay( std::cerr );
 
   65  std::cerr << std::endl;
 
   67  f1.reduced(1).selfDisplay( std::cerr );
 
   68  std::cerr << std::endl;
 
   70  f1.reduced(2).selfDisplay( std::cerr );
 
   71  std::cerr << std::endl;
 
   75  std::cerr << 
"p1=" << p1.rE() << std::endl;
 
   76  std::cerr << 
"p2=" << p2.rE() << std::endl;
 
   77  std::cerr << 
"p1=" << p1.rEs( 
"(|)" ) << std::endl;
 
   78  std::cerr << 
"p2=" << p2.rEs( 
"(|)" ) << std::endl;
 
   79  return p1.rE() == p2.rE();
 
 
   82template <
typename Fraction1, 
typename Fraction2>
 
   86  unsigned int nbtests = 100;
 
   88  unsigned int nbok = 0;
 
   90  f1 = Fraction1( 5, 8 );
 
   93  std::cerr << 
"(" << nbok << 
"/" << nb << 
") f1=";
 
   94  f1.selfDisplay( std::cerr );
 
   96  f1 = Fraction1( 31, 24 );
 
   99  std::cerr << 
"(" << nbok << 
"/" << nb << 
") f1=";
 
  100  f1.selfDisplay( std::cerr );
 
  102  f1 = Fraction1( 5, 13 );
 
  105  std::cerr << 
"(" << nbok << 
"/" << nb << 
") f1=";
 
  106  f1.selfDisplay( std::cerr );
 
  110  for ( 
unsigned int i = 0; i < nbtests; ++i )
 
  112      unsigned int p = 1 + std::rand() % 999;
 
  113      unsigned int q = 1 + std::rand() % 999;
 
  114      unsigned int g = ic.
gcd( p, q );
 
  116      std::cerr << 
"*- p / q = " << p << 
"/" << q << std::endl;
 
  117      f1 = Fraction1( p, q );
 
  120      std::cerr << 
"(" << nbok << 
"/" << nb << 
") f1=";
 
  121      f1.selfDisplay( std::cerr );
 
 
  135  typedef SB::Fraction Fraction;
 
  136  typedef LSB::Fraction LFraction;
 
  137  typedef LLSB::Fraction LLFraction;
 
  142  trace.
emphase() << ( res ? 
"Passed." : 
"Error." ) << endl;
 
 
Aim: This class gathers several types and methods to make computation with integers.
 
Integer gcd(IntegerParamType a, IntegerParamType b) const
 
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
 
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
 
Aim: This class represents a pattern, i.e. the path between two consecutive upper leaning points on a...
 
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
 
void beginBlock(const std::string &keyword="")
 
DGtal is the top-level namespace which contains all DGtal functions and types.