DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testStandardDSLQ0-smartDSS-benchmark.cpp File Reference
#include <cstdlib>
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/CPointPredicate.h"
#include "DGtal/arithmetic/IntegerComputer.h"
#include "DGtal/arithmetic/SternBrocot.h"
#include "DGtal/arithmetic/Pattern.h"
#include "DGtal/arithmetic/StandardDSLQ0.h"

Go to the source code of this file.

Functions

template<typename DSL >
bool checkSubStandardDSLQ0 (const DSL &D, const typename DSL::Point &A, const typename DSL::Point &B)
 
template<typename Fraction >
bool testSubStandardDSLQ0 (unsigned int nbtries, typename Fraction::Integer moda, typename Fraction::Integer modb, typename Fraction::Integer modx)
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2012/03/05

Functions for testing class SternBrocot.

This file is part of the DGtal library.

Definition in file testStandardDSLQ0-smartDSS-benchmark.cpp.

Function Documentation

◆ checkSubStandardDSLQ0()

template<typename DSL >
bool checkSubStandardDSLQ0 ( const DSL &  D,
const typename DSL::Point A,
const typename DSL::Point B 
)

Definition at line 49 of file testStandardDSLQ0-smartDSS-benchmark.cpp.

52{
53
54
55 DSL S = D.smartDSS( A, B );
56 // std::cout << D.a() << " " << D.b() << " " << D.mu() << " "
57 // << S.a() << " " << S.b() << " " << S.mu() << " "
58 // << A[0] << " " << A[1] << " " << B[0] << " " << B[1]
59 // << std::endl;
60 return true;
61}

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 115 of file testStandardDSLQ0-smartDSS-benchmark.cpp.

116{
118 typedef SB::Fraction Fraction;
119 typedef Fraction::Integer Integer;
120 unsigned int nbtries = ( argc > 1 ) ? atoi( argv[ 1 ] ) : 10000;
121 // Integer moda = ( argc > 2 ) ? atoll( argv[ 2 ] ) : 100000000000;
122 // Integer modb = ( argc > 3 ) ? atoll( argv[ 3 ] ) : 100000000000;
123 // Integer modx = ( argc > 4 ) ? atoll( argv[ 4 ] ) : 1000;
124 // testSubStandardDSLQ0<Fraction>( nbtries, moda, modb, modx );
125
126
127
128 Integer modb = 1000000000000;
129 Integer moda = modb;
130
131 for(Integer modx = 10; modx < modb/2;modx*=2)
132 {
133 testSubStandardDSLQ0<Fraction>( nbtries, moda, modb, modx );
134 }
135
136
137
138
139 return true;
140}
Aim: The Stern-Brocot tree is the tree of irreducible fractions. This class allows to construct it pr...
Definition: SternBrocot.h:78

◆ testSubStandardDSLQ0()

template<typename Fraction >
bool testSubStandardDSLQ0 ( unsigned int  nbtries,
typename Fraction::Integer  moda,
typename Fraction::Integer  modb,
typename Fraction::Integer  modx 
)

Definition at line 64 of file testStandardDSLQ0-smartDSS-benchmark.cpp.

68{
69 typedef StandardDSLQ0<Fraction> DSL;
70 typedef typename Fraction::Integer Integer;
71 typedef typename DSL::Point Point;
73
74 //std::cout << "# a b mu a1 b1 mu1 Ax Ay Bx By" << std::endl;
75
76 clock_t timeBegin, timeEnd;
77 timeBegin = clock();
78
79 for ( unsigned int i = 0; i < nbtries; ++i )
80 {
81 Integer b( rand() % modb + 1 );
82 Integer a( rand() % b + 1 );
83 if ( ic.gcd( a, b ) == 1 )
84 {
85 for ( Integer mu = 0; mu < 5; ++mu )
86 {
87 DSL D( a, b, rand() % (moda+modb) );
88 for ( Integer x = 0; x < 10; ++x )
89 {
90 Integer x1 = rand() % modx;
91 Integer x2 = x1 + 1 + ( rand() % modx );
92 Point A = D.lowestY( x1 );
93 Point B = D.lowestY( x2 );
94 checkSubStandardDSLQ0<DSL>( D, A, B );
95 }
96 }
97 }
98 }
99
100 timeEnd = clock();
101 long double CPUTime;
102 CPUTime = ((double)timeEnd-(double)timeBegin)/((double)CLOCKS_PER_SEC);
103
104 //std::cout << "SmartDSS: CPU Time ellapsed = " << CPUTime << " - Time/test = = " << (long double) CPUTime/(nbtries*5*10) << std::endl;
105
106 std::cout << modx << " " << (long double) CPUTime/(nbtries*5*10) << std::endl;
107
108
109return true;
110}
Aim: This class gathers several types and methods to make computation with integers.
Integer gcd(IntegerParamType a, IntegerParamType b) const
Aim: Represents a digital straight line with slope in the first quadrant (Q0: x >= 0,...
Definition: StandardDSLQ0.h:80
MyPointD Point
Definition: testClone2.cpp:383

References DGtal::IntegerComputer< TInteger >::gcd().