34 #include "DGtal/base/Common.h"
35 #include "DGtal/kernel/CPointPredicate.h"
36 #include "DGtal/arithmetic/IntegerComputer.h"
37 #include "DGtal/arithmetic/LightSternBrocot.h"
38 #include "DGtal/arithmetic/Pattern.h"
39 #include "DGtal/arithmetic/StandardDSLQ0.h"
43 using namespace DGtal;
49 template <
typename DSL>
50 bool checkSubStandardDSLQ0(
const DSL & D,
51 const typename DSL::Point & A,
52 const typename DSL::Point & B )
54 typedef typename DSL::Fraction Fraction;
55 typedef typename DSL::Integer
Integer;
56 typedef typename DSL::Quotient Quotient;
57 typedef typename DSL::Point
Point;
58 typedef typename DSL::ConstIterator ConstIterator;
59 typedef typename DSL::Point2I Point2I;
60 typedef typename DSL::Vector2I Vector2I;
62 DSL S = D.reversedSmartDSS( A, B );
63 std::cout << D.a() <<
" " << D.b() <<
" " << D.mu() <<
" "
64 << S.a() <<
" " << S.b() <<
" " << S.mu() <<
" "
65 << A[0] <<
" " << A[1] <<
" " << B[0] <<
" " << B[1]
70 template <
typename Fraction>
71 bool testSubStandardDSLQ0(
unsigned int nbtries,
72 typename Fraction::Integer moda,
73 typename Fraction::Integer modb,
74 typename Fraction::Integer modx )
77 typedef typename Fraction::Integer Integer;
78 typedef typename Fraction::Quotient Quotient;
79 typedef typename DSL::Point Point;
80 typedef typename DSL::ConstIterator ConstIterator;
81 typedef typename DSL::Point2I Point2I;
82 typedef typename DSL::Vector2I Vector2I;
85 std::cout <<
"# a b mu a1 b1 mu1 Ax Ay Bx By" << std::endl;
86 for (
unsigned int i = 0; i < nbtries; ++i )
88 Integer a( random() % moda + 1 );
89 Integer b( random() % modb + 1 );
90 if ( ic.
gcd( a, b ) == 1 )
92 for ( Integer mu = 0; mu < 5; ++mu )
94 DSL D( a, b, random() % (moda+modb) );
95 for ( Integer x = 0; x < 10; ++x )
97 Integer x1 = random() % modx;
98 Integer x2 = x1 + 1 + ( random() % modx );
99 Point A = D.lowestY( x1 );
100 Point B = D.lowestY( x2 );
101 checkSubStandardDSLQ0<DSL>( D, A, B );
113 int main(
int argc,
char** argv)
116 typedef SB::Fraction Fraction;
117 typedef Fraction::Integer Integer;
118 unsigned int nbtries = ( argc > 1 ) ? atoi( argv[ 1 ] ) : 10000;
119 Integer moda = ( argc > 2 ) ? atoll( argv[ 2 ] ) : 12000;
120 Integer modb = ( argc > 3 ) ? atoll( argv[ 3 ] ) : 12000;
121 Integer modx = ( argc > 4 ) ? atoll( argv[ 4 ] ) : 1000;
122 testSubStandardDSLQ0<Fraction>( nbtries, moda, modb, modx );