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"
39 #include "DGtal/geometry/curves/ArithmeticalDSS.h"
43 using namespace DGtal;
49 template <
typename DSL>
50 bool checkSubArithmeticDSS(
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;
63 ConstIterator it = D.
begin( A );
64 ConstIterator it_end = D.end( B );
67 while ( ( dss.end() != it_end )
68 && ( dss.extendForward() ) ) {}
69 std::cout << D.a() <<
" " << D.b() <<
" " << D.mu() <<
" "
70 << dss.getA() <<
" " << dss.getB() <<
" " << dss.getMu() <<
" "
71 << A[0] <<
" " << A[1] <<
" " << B[0] <<
" " << B[1]
113 template <
typename Fraction>
114 bool testSubStandardDSLQ0(
unsigned int nbtries,
115 typename Fraction::Integer moda,
116 typename Fraction::Integer modb,
117 typename Fraction::Integer modx )
120 typedef typename Fraction::Integer Integer;
121 typedef typename Fraction::Quotient Quotient;
122 typedef typename DSL::Point Point;
123 typedef typename DSL::ConstIterator ConstIterator;
124 typedef typename DSL::Point2I Point2I;
125 typedef typename DSL::Vector2I Vector2I;
129 std::cout <<
"# a b mu a1 b1 mu1 Ax Ay Bx By" << std::endl;
130 for (
unsigned int i = 0; i < nbtries; ++i )
132 Integer a( random() % moda + 1 );
133 Integer b( random() % modb + 1 );
134 if ( ic.
gcd( a, b ) == 1 )
136 for ( Integer mu = 0; mu < 5; ++mu )
138 DSL D( a, b, random() % (moda+modb) );
139 for ( Integer x = 0; x < 10; ++x )
141 Integer x1 = random() % modx;
142 Integer x2 = x1 + 1 + ( random() % modx );
143 Point A = D.lowestY( x1 );
144 Point B = D.lowestY( x2 );
145 checkSubArithmeticDSS<DSL>( D, A, B );
157 int main(
int argc,
char** argv)
160 typedef SB::Fraction Fraction;
161 typedef Fraction::Integer Integer;
162 unsigned int nbtries = ( argc > 1 ) ? atoi( argv[ 1 ] ) : 10000;
163 Integer moda = ( argc > 2 ) ? atoll( argv[ 2 ] ) : 12000;
164 Integer modb = ( argc > 3 ) ? atoll( argv[ 3 ] ) : 12000;
165 Integer modx = ( argc > 4 ) ? atoll( argv[ 4 ] ) : 1000;
166 testSubStandardDSLQ0<Fraction>( nbtries, moda, modb, modx );