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