DGtal  1.5.beta
testInHalfPlane-benchmark.cpp File Reference
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/PointVector.h"
#include "DGtal/geometry/tools/determinant/C2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/Simple2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/SimpleIncremental2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/AvnaimEtAl2x2DetSignComputer.h"
#include "DGtal/geometry/tools/determinant/Filtered2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/COrientationFunctor2.h"
#include "DGtal/geometry/tools/determinant/InHalfPlaneBy2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
Include dependency graph for testInHalfPlane-benchmark.cpp:

Go to the source code of this file.

Functions

DGtal::int32_t randomInt15 ()
 
DGtal::int32_t randomInt26 ()
 
DGtal::int32_t randomInt30 ()
 
DGtal::int64_t randomInt52 ()
 
double randomDouble52 ()
 
DGtal::int64_t randomInt62 ()
 
DGtal::BigInteger randomBigInt62 ()
 
DGtal::int32_t signedRandomInt15 ()
 
DGtal::int32_t signedRandomInt26 ()
 
DGtal::int32_t signedRandomInt30 ()
 
DGtal::int64_t signedRandomInt52 ()
 
double signedRandomDouble52 ()
 
DGtal::int64_t signedRandomInt62 ()
 
DGtal::BigInteger signedRandomBigInt62 ()
 
template<typename OrientationFunctor , typename RandomFunctor >
bool randomTest (OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
 
template<typename OrientationFunctor , typename RandomFunctor >
bool nullSameVectorsTest (OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
 
template<typename OrientationFunctor , typename RandomFunctor >
bool nullZeroVectorTest (OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
 
template<typename OrientationFunctor , typename RandomFunctor >
bool nullTest (OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
 
template<typename OrientationFunctor , typename RandomFunctor >
bool quasiNullTest (OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
 
template<typename OrientationFunctor >
bool incTest (OrientationFunctor f, const DGtal::int32_t n=1000000)
 
bool incTestComparison ()
 
bool randomTest30All ()
 
bool randomTest52All ()
 
bool randomTest62All ()
 
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
Tristan Roussillon (trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2013/11/22

This file is part of the DGtal library.

Definition in file testInHalfPlane-benchmark.cpp.

Function Documentation

◆ incTest()

template<typename OrientationFunctor >
bool incTest ( OrientationFunctor  f,
const DGtal::int32_t  n = 1000000 
)

Function that traces to the standard output the running time of a given orientation functor f for n computations. The orientation functor is initialized with 2 points given once for all. We then compute the orientation of a random sequence of adjacent points with respect to these two points.

Parameters
fa functor to run
nnumber of tries
Template Parameters
OrientationFunctora model of COrientationFunctor2

Definition at line 458 of file testInHalfPlane-benchmark.cpp.

459 {
461 
462  typedef typename OrientationFunctor::Point Point;
463  Point P, Q, R;
464 
465  typedef typename Point::Coordinate Coordinate;
466  Coordinate dx, dy;
467 
468  Coordinate max = 1073741824;
469  P = Point(0,0);
470  Q = Point(max, max);
471  R = Point(max/2, max/2);
472  f.init(P, Q);
473 
474  clock_t timeBegin, timeEnd;
475  timeBegin = clock();
476 
477  for (DGtal::int32_t i = 0; (i < n); ++i)
478  {
479  dx = (rand() % 3) - 1;
480  dy = (rand() % 3) - 1;
481  R[0] += dx;
482  ASSERT( R[0] >= -max );
483  ASSERT( R[0] < max );
484  R[1] += dy;
485  ASSERT( R[0] >= -max );
486  ASSERT( R[0] < max );
487  f( R );
488  }
489 
490  timeEnd = clock();
491  long double time, CPUTime;
492  time = ((double)timeEnd-(double)timeBegin);
493  CPUTime = time/((double)CLOCKS_PER_SEC);
494  std::cout << CPUTime << " ";
495 
496  return true;
497 }
boost::int32_t int32_t
signed 32-bit integer.
Definition: BasicTypes.h:72
Aim: This concept is a refinement of COrientationFunctor, useful for simple algebraic curves that can...
int max(int a, int b)
MyPointD Point
Definition: testClone2.cpp:383

References max().

Referenced by incTestComparison().

◆ incTestComparison()

bool incTestComparison ( )

Function that traces to the standard output the running time of all available functors for random points whose coordinates are within [-2^30 ; 2^30[.

Definition at line 504 of file testInHalfPlane-benchmark.cpp.

505 {
507 
508  long seed = time(NULL);
509 
510  std::cout << "# incremental input " << std::endl;
511  std::cout << "# running times in s. for 1 million tries" << std::endl;
512 
513  {
514  srand(seed);
515  std::cout << "2x2-int32-int64 ";
518  incTest( F() );
519  std::cout << std::endl;
520  }
521  {
522  srand(seed);
523  std::cout << "2x2-inc-int32-int64 ";
526  incTest( F() );
527  std::cout << std::endl;
528  }
529  {
530  srand(seed);
531  std::cout << "2x2-avnaim++-int32-double ";
532  typedef AvnaimEtAl2x2DetSignComputer<double> DetComputer;
533  typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
535  incTest( F() );
536  std::cout << std::endl;
537  }
538 #ifdef WITH_BIGINTEGER
539  {
540  srand(seed);
541  std::cout << "2x2-int32-BigInt ";
544  incTest( F() );
545  std::cout << std::endl;
546  }
547  {
548  srand(seed);
549  std::cout << "2x2-inc-int32-BigInt ";
552  incTest( F() );
553  std::cout << std::endl;
554  }
555 #endif
556  return true;
557 }
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Aim: Small class useful to compute the determinant of a 2x2 matrix from its four coefficients,...
Aim: Small class useful to compute, in an incremental way, the determinant of a 2x2 matrix from its f...
srand(0)
bool incTest(OrientationFunctor f, const DGtal::int32_t n=1000000)

References incTest(), and srand().

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 918 of file testInHalfPlane-benchmark.cpp.

919 {
920  trace.beginBlock ( "Testing class InHalfPlane-benchmark" );
921  trace.info() << "Args:";
922  for ( int i = 0; i < argc; ++i )
923  trace.info() << " " << argv[ i ];
924  trace.info() << endl;
925 
927  randomTest30All();
928  randomTest52All();
929  randomTest62All();
930 
931  bool res = true;
932  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
933  trace.endBlock();
934  return res ? 0 : 1;
935 }
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:153
bool randomTest30All()
bool incTestComparison()
bool randomTest62All()
bool randomTest52All()

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), incTestComparison(), DGtal::Trace::info(), randomTest30All(), randomTest52All(), randomTest62All(), and DGtal::trace.

◆ nullSameVectorsTest()

template<typename OrientationFunctor , typename RandomFunctor >
bool nullSameVectorsTest ( OrientationFunctor  f,
RandomFunctor  gen,
const DGtal::int32_t  n = 1000000 
)

Function that traces to the standard output the running time of a given orientation functor f for n computations for three points P, Q, R such that Q = R. The coordinates of P and Q are randomly chosen by gen.

Parameters
fa functor to run
gena generator providing random numbers
nnumber of tries
Template Parameters
OrientationFunctora model of COrientationFunctor2

Definition at line 273 of file testInHalfPlane-benchmark.cpp.

274 {
276 
277  typedef typename OrientationFunctor::Point Point;
278  Point P, Q;
279 
280  clock_t timeBegin, timeEnd;
281  timeBegin = clock();
282 
283  for (DGtal::int32_t i = 0; (i < n); ++i)
284  {
285  P[0] = gen();
286  P[1] = gen();
287  Q[0] = gen();
288  Q[1] = gen();
289  f.init(P, Q);
290  f( Q );
291  }
292 
293  timeEnd = clock();
294  long double time, CPUTime;
295  time = ((double)timeEnd-(double)timeBegin);
296  CPUTime = time/((double)CLOCKS_PER_SEC);
297  std::cout << CPUTime << " ";
298 
299  return true;
300 }

Referenced by randomTest30All(), randomTest52All(), and randomTest62All().

◆ nullTest()

template<typename OrientationFunctor , typename RandomFunctor >
bool nullTest ( OrientationFunctor  f,
RandomFunctor  gen,
const DGtal::int32_t  n = 1000000 
)

Function that traces to the standard output the running time of a given orientation functor f for n computations for three collinear points P, Q, R such that Q-P = ku and R-P = lu. P is set to (0,0), the components of u, k and l are randomly chosen by gen.

Parameters
fa functor to run
gena generator providing random numbers
nnumber of tries
Template Parameters
OrientationFunctora model of COrientationFunctor2

Definition at line 354 of file testInHalfPlane-benchmark.cpp.

355 {
357 
358  typedef typename OrientationFunctor::Point Point;
359  Point P, Q, R;
360  P = Point(0,0);
361 
362  typedef typename Point::Coordinate Coordinate;
363  Coordinate k, l, u0, u1;
364 
365  clock_t timeBegin, timeEnd;
366  timeBegin = clock();
367 
368  for (DGtal::int32_t i = 0; (i < n); ++i)
369  {
370  k = gen();
371  l = gen();
372  u0 = gen();
373  u1 = gen();
374  Q[0] = k*u0;
375  Q[1] = k*u1;
376  R[0] = l*u0;
377  R[1] = l*u1;
378  f.init(P, Q);
379  f( R );
380  }
381 
382  timeEnd = clock();
383  long double time, CPUTime;
384  time = ((double)timeEnd-(double)timeBegin);
385  CPUTime = time/((double)CLOCKS_PER_SEC);
386  std::cout << CPUTime << " ";
387 
388  return true;
389 }

Referenced by randomTest30All(), randomTest52All(), and randomTest62All().

◆ nullZeroVectorTest()

template<typename OrientationFunctor , typename RandomFunctor >
bool nullZeroVectorTest ( OrientationFunctor  f,
RandomFunctor  gen,
const DGtal::int32_t  n = 1000000 
)

Function that traces to the standard output the running time of a given orientation functor f for n computations for three points P, Q, R such that R = P. The coordinates of P and R are randomly chosen by gen.

Parameters
fa functor to run
gena generator providing random numbers
nnumber of tries
Template Parameters
OrientationFunctora model of COrientationFunctor2

Definition at line 313 of file testInHalfPlane-benchmark.cpp.

314 {
316 
317  typedef typename OrientationFunctor::Point Point;
318  Point P, Q;
319 
320  clock_t timeBegin, timeEnd;
321  timeBegin = clock();
322 
323  for (DGtal::int32_t i = 0; (i < n); ++i)
324  {
325  P[0] = gen();
326  P[1] = gen();
327  Q[0] = gen();
328  Q[1] = gen();
329  f.init(P, Q);
330  f( P );
331  }
332 
333  timeEnd = clock();
334  long double time, CPUTime;
335  time = ((double)timeEnd-(double)timeBegin);
336  CPUTime = time/((double)CLOCKS_PER_SEC);
337  std::cout << CPUTime << " ";
338 
339  return true;
340 }

Referenced by randomTest30All(), randomTest52All(), and randomTest62All().

◆ quasiNullTest()

template<typename OrientationFunctor , typename RandomFunctor >
bool quasiNullTest ( OrientationFunctor  f,
RandomFunctor  gen,
const DGtal::int32_t  n = 1000000 
)

Function that traces to the standard output the running time of a given orientation functor f for n computations for three quasi-collinear points P, Q, R defined such that Q-P = ku + epsilon and R-P = lu + epsilon where espilon is a random integer between -2 and 2.
P is set to (0,0), the components of u, k and l are randomly chosen by gen.

Parameters
fa functor to run
gena generator providing random numbers
nnumber of tries
Template Parameters
OrientationFunctora model of COrientationFunctor2

Definition at line 404 of file testInHalfPlane-benchmark.cpp.

405 {
407 
408  typedef typename OrientationFunctor::Point Point;
409  Point P, Q, R;
410  P = Point(0,0);
411 
412  typedef typename Point::Coordinate Coordinate;
413  Coordinate k, l, u0, u1;
414 
415  clock_t timeBegin, timeEnd;
416  timeBegin = clock();
417 
418  for (DGtal::int32_t i = 0; (i < n); ++i)
419  {
420  k = gen();
421  l = gen();
422  u0 = gen();
423  u1 = gen();
424  Q[0] = k*u0;
425  Q[0] += (rand()%5)-2;
426  Q[1] = k*u1;
427  Q[1] += (rand()%5)-2;
428  R[0] = l*u0;
429  R[0] += (rand()%5)-2;
430  R[1] = l*u1;
431  R[1] += (rand()%5)-2;
432  f.init(P, Q);
433  f( R );
434  }
435 
436  timeEnd = clock();
437  long double time, CPUTime;
438  time = ((double)timeEnd-(double)timeBegin);
439  CPUTime = time/((double)CLOCKS_PER_SEC);
440  std::cout << CPUTime << " ";
441 
442  return true;
443 }

Referenced by randomTest30All(), randomTest52All(), and randomTest62All().

◆ randomBigInt62()

DGtal::BigInteger randomBigInt62 ( )
Returns
a random integer of type DGtal::BigInteger lying in the range [0 ; 2^62[

Definition at line 132 of file testInHalfPlane-benchmark.cpp.

133 {
134  return
135  static_cast<DGtal::BigInteger>(rand() % 4) +
136  ( static_cast<DGtal::BigInteger>(randomInt30()) +
137  ( static_cast<DGtal::BigInteger>(randomInt30()) )
138  * 1073741824 )
139  * 4;
140 }
mpz_class BigInteger
Multi-precision integer with GMP implementation.
Definition: BasicTypes.h:79
DGtal::int32_t randomInt30()

References randomInt30().

Referenced by signedRandomBigInt62().

◆ randomDouble52()

double randomDouble52 ( )
Returns
a random integer of type double lying in the range [0 ; 2^52[

Definition at line 102 of file testInHalfPlane-benchmark.cpp.

103 {
104  return
105  static_cast<double>(rand() % 128) +
106  ( static_cast<double>(randomInt15()) +
107  ( static_cast<double>(randomInt30()) )
108  * 32768 )
109  * 128;
110 }
DGtal::int32_t randomInt15()

References randomInt15(), and randomInt30().

Referenced by signedRandomDouble52().

◆ randomInt15()

DGtal::int32_t randomInt15 ( )
Returns
a random integer of type DGtal::int32_t lying in the range [0 ; 2^15[

Definition at line 59 of file testInHalfPlane-benchmark.cpp.

60 {
61  return static_cast<DGtal::int32_t>(rand() % 32768);
62 }

Referenced by randomDouble52(), randomInt26(), randomInt30(), randomInt52(), and signedRandomInt15().

◆ randomInt26()

DGtal::int32_t randomInt26 ( )
Returns
a random integer of type DGtal::int32_t lying in the range [0 ; 2^26[

Definition at line 68 of file testInHalfPlane-benchmark.cpp.

69 {
70  return static_cast<DGtal::int32_t>(rand() % 2048) +
71  ( randomInt15() * 2048 );
72 }

References randomInt15().

Referenced by signedRandomInt26().

◆ randomInt30()

DGtal::int32_t randomInt30 ( )
Returns
a random integer of type DGtal::int32_t lying in the range [0 ; 2^30[

Definition at line 78 of file testInHalfPlane-benchmark.cpp.

79 {
80  return randomInt15() +
81  ( randomInt15() * 32768 );
82 }

References randomInt15().

Referenced by randomBigInt62(), randomDouble52(), randomInt52(), randomInt62(), and signedRandomInt30().

◆ randomInt52()

DGtal::int64_t randomInt52 ( )
Returns
a random integer of type DGtal::int64_t lying in the range [0 ; 2^52[

Definition at line 88 of file testInHalfPlane-benchmark.cpp.

89 {
90  return
91  static_cast<DGtal::int64_t>(rand() % 128) +
92  ( static_cast<DGtal::int64_t>(randomInt15()) +
93  ( static_cast<DGtal::int64_t>(randomInt30()) )
94  * 32768 )
95  * 128;
96 }
boost::int64_t int64_t
signed 94-bit integer.
Definition: BasicTypes.h:74

References randomInt15(), and randomInt30().

Referenced by signedRandomInt52().

◆ randomInt62()

DGtal::int64_t randomInt62 ( )
Returns
a random integer of type DGtal::int64_t lying in the range [0 ; 2^62[

Definition at line 116 of file testInHalfPlane-benchmark.cpp.

117 {
118  return
119  static_cast<DGtal::int64_t>(rand() % 4) +
120  ( static_cast<DGtal::int64_t>(randomInt30()) +
121  ( static_cast<DGtal::int64_t>(randomInt30()) )
122  * 1073741824 )
123  * 4;
124 }

References randomInt30().

Referenced by signedRandomInt62().

◆ randomTest()

template<typename OrientationFunctor , typename RandomFunctor >
bool randomTest ( OrientationFunctor  f,
RandomFunctor  gen,
const DGtal::int32_t  n = 1000000 
)

Function that traces to the standard output the running time of a given functor f for n computations over points whose coordinates are randomly chosen by gen.

Parameters
fa functor to run
gena generator providing random numbers
nnumber of tries
Template Parameters
OrientationFunctora model of COrientationFunctor2

Definition at line 231 of file testInHalfPlane-benchmark.cpp.

232 {
234 
235  typedef typename OrientationFunctor::Point Point;
236  Point P, Q, R;
237 
238  clock_t timeBegin, timeEnd;
239  timeBegin = clock();
240 
241  for (DGtal::int32_t i = 0; (i < n); ++i)
242  {
243  P[0] = gen();
244  P[1] = gen();
245  Q[0] = gen();
246  Q[1] = gen();
247  f.init(P, Q);
248  R[0] = gen();
249  R[1] = gen();
250  f( R );
251  }
252 
253  timeEnd = clock();
254  long double time, CPUTime;
255  time = ((double)timeEnd-(double)timeBegin);
256  CPUTime = time/((double)CLOCKS_PER_SEC);
257  std::cout << CPUTime << " ";
258 
259  return true;
260 }

Referenced by randomTest30All(), randomTest52All(), and randomTest62All().

◆ randomTest30All()

bool randomTest30All ( )

Function that traces to the standard output the running time of all available functors for random points whose coordinates are within [-2^30 ; 2^30[.

Definition at line 564 of file testInHalfPlane-benchmark.cpp.

565 {
567 
568  std::cout << "# random integers within [-2^30 ; 2^30[" << std::endl;
569  std::cout << "# running times in s. for 1 million tries" << std::endl;
570  std::cout << "# columns: random, null1, null2, null3, quasi-null " << std::endl;
571  std::cout << "# NB. double has " << std::numeric_limits<double>::digits << " bits in the mantissa " << std::endl;
572 
573  long seed = time(NULL);
574 
575  {
576  srand(seed);
577  std::cout << "3x3-int32-int64 ";
582  nullTest( F(), signedRandomInt15 );
584  std::cout << std::endl;
585  }
586 #ifdef WITH_BIGINTEGER
587  {
588  srand(seed);
589  std::cout << "3x3-int32-BigInt ";
594  nullTest( F(), signedRandomInt15 );
596  std::cout << std::endl;
597 }
598 #endif
599  {
600  srand(seed);
601  std::cout << "2x2-int32-int64 ";
607  nullTest( F(), signedRandomInt15 );
609  std::cout << std::endl;
610  }
611 #ifdef WITH_BIGINTEGER
612  {
613  srand(seed);
614  std::cout << "2x2-int32-BigInt ";
620  nullTest( F(), signedRandomInt15 );
622  std::cout << std::endl;
623  }
624 #endif
625  {
626  srand(seed);
627  std::cout << "2x2-inc-int32-int64 ";
633  nullTest( F(), signedRandomInt15 );
635  std::cout << std::endl;
636  }
637 #ifdef WITH_BIGINTEGER
638  {
639  srand(seed);
640  std::cout << "2x2-inc-int32-BigInt ";
646  nullTest( F(), signedRandomInt15 );
648  std::cout << std::endl;
649  }
650 #endif
651  {
652  srand(seed);
653  std::cout << "2x2-avnaim-int32-int32 ";
659  nullTest( F(), signedRandomInt15 );
661  std::cout << std::endl;
662  }
663  {
664  srand(seed);
665  std::cout << "2x2-avnaim-int32-double ";
666  typedef AvnaimEtAl2x2DetSignComputer<double> DetComputer;
671  nullTest( F(), signedRandomInt15 );
673  std::cout << std::endl;
674  }
675  {
676  srand(seed);
677  std::cout << "2x2-avnaim++-int32-double ";
678  typedef AvnaimEtAl2x2DetSignComputer<double> DetComputer;
679  typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
684  nullTest( F(), signedRandomInt15 );
686  std::cout << std::endl;
687  }
688 
689  return true;
690 }
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
bool nullZeroVectorTest(OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
DGtal::int32_t signedRandomInt30()
DGtal::int32_t signedRandomInt15()
bool randomTest(OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
bool quasiNullTest(OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
bool nullSameVectorsTest(OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
bool nullTest(OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)

References nullSameVectorsTest(), nullTest(), nullZeroVectorTest(), quasiNullTest(), randomTest(), signedRandomInt15(), signedRandomInt30(), and srand().

Referenced by main().

◆ randomTest52All()

bool randomTest52All ( )

Function that traces to the standard output the running time of all available functors for random points whose coordinates are within [-2^52 ; 2^52[.

BigInt cannot be constructed from a DGtal::int64_t

Definition at line 697 of file testInHalfPlane-benchmark.cpp.

698 {
699  std::cout << "# random integers within [-2^52 ; 2^52[" << std::endl;
700  std::cout << "# running times in s. for 1 million tries" << std::endl;
701  std::cout << "# columns: random, null1, null2, null3, quasi-null " << std::endl;
702  std::cout << "# NB. double has " << std::numeric_limits<double>::digits << " bits in the mantissa " << std::endl;
703 
704  long seed = time(NULL);
705 
706 #ifdef WITH_BIGINTEGER
707  {
708  srand(seed);
709  std::cout << "3x3-double-BigInt ";
710  typedef PointVector<2, double> Point;
715  nullTest( F(), signedRandomInt26 );
717  std::cout << std::endl;
718  }
719  {
720  srand(seed);
721  std::cout << "2x2-double-BigInt ";
722  typedef PointVector<2, double> Point;
728  nullTest( F(), signedRandomInt26 );
730  std::cout << std::endl;
731  }
732  {
733  srand(seed);
734  std::cout << "2x2-inc-double-BigInt ";
735  typedef PointVector<2, double> Point;
741  nullTest( F(), signedRandomInt26 );
743  std::cout << std::endl;
744  }
745 #endif
746  {
747  srand(seed);
748  std::cout << "2x2-avnaim-int64-int64 ";
755  nullTest( F(), signedRandomInt26 );
757  std::cout << std::endl;
758  }
759  {
760  srand(seed);
761  std::cout << "2x2-avnaim-double-int64 ";
762  typedef PointVector<2, double> Point;
768  nullTest( F(), signedRandomInt26 );
770  std::cout << std::endl;
771  }
772  {
773  srand(seed);
774  std::cout << "2x2-avnaim-int64-double ";
776  typedef AvnaimEtAl2x2DetSignComputer<double> DetComputer;
781  nullTest( F(), signedRandomInt26 );
783  std::cout << std::endl;
784  }
785  {
786  srand(seed);
787  std::cout << "2x2-avnaim-double-double ";
788  typedef PointVector<2, double> Point;
789  typedef AvnaimEtAl2x2DetSignComputer<double> DetComputer;
794  nullTest( F(), signedRandomInt26 );
796  std::cout << std::endl;
797  }
798  {
799  srand(seed);
800  std::cout << "2x2-avnaim++-int64-double ";
802  typedef AvnaimEtAl2x2DetSignComputer<double> DetComputer;
803  typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
808  nullTest( F(), signedRandomInt26 );
810  std::cout << std::endl;
811  }
812  {
813  srand(seed);
814  std::cout << "2x2-avnaim++-double-double ";
815  typedef PointVector<2, double> Point;
816  typedef AvnaimEtAl2x2DetSignComputer<double> DetComputer;
817  typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
822  nullTest( F(), signedRandomInt26 );
824  std::cout << std::endl;
825  }
826 
827  return true;
828 }
DGtal::int64_t signedRandomInt52()
double signedRandomDouble52()
DGtal::int32_t signedRandomInt26()

References nullSameVectorsTest(), nullTest(), nullZeroVectorTest(), quasiNullTest(), randomTest(), signedRandomDouble52(), signedRandomInt26(), signedRandomInt52(), and srand().

Referenced by main().

◆ randomTest62All()

bool randomTest62All ( )

Function that traces to the standard output the running time of all available functors for random points whose coordinates are within [-2^62 ; 2^62[.

BigInt cannot be constructed from a DGtal::int64_t

Definition at line 835 of file testInHalfPlane-benchmark.cpp.

836 {
837  std::cout << "# random integers within [-2^62 ; 2^62[" << std::endl;
838  std::cout << "# running times in s. for 1 million tries" << std::endl;
839  std::cout << "# columns: random, null1, null2, null3, quasi-null " << std::endl;
840  std::cout << "# NB. long double has " << std::numeric_limits<long double>::digits << " bits in the mantissa " << std::endl;
841 
842  long seed = time(NULL);
843 
844 #ifdef WITH_BIGINTEGER
845  {
846  srand(seed);
847  std::cout << "3x3-BigInt-BigInt ";
853  nullTest( F(), signedRandomInt30 );
855  std::cout << std::endl;
856  }
857  {
858  srand(seed);
859  std::cout << "2x2-BigInt-BigInt ";
866  nullTest( F(), signedRandomInt30 );
868  std::cout << std::endl;
869  }
870  {
871  srand(seed);
872  std::cout << "2x2-inc-BigInt-BigInt ";
879  nullTest( F(), signedRandomInt30 );
881  std::cout << std::endl;
882  }
883 #endif
884  {
885  srand(seed);
886  std::cout << "2x2-avnaim-int64-int64 ";
893  nullTest( F(), signedRandomInt30 );
895  std::cout << std::endl;
896  }
897  {
898  srand(seed);
899  std::cout << "2x2-avnaim++-int64-longdouble ";
901  typedef AvnaimEtAl2x2DetSignComputer<long double> DetComputer;
902  typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
907  nullTest( F(), signedRandomInt30 );
909  std::cout << std::endl;
910  }
911 
912  return true;
913 }
DGtal::BigInteger signedRandomBigInt62()
DGtal::int64_t signedRandomInt62()

References nullSameVectorsTest(), nullTest(), nullZeroVectorTest(), quasiNullTest(), randomTest(), signedRandomBigInt62(), signedRandomInt30(), signedRandomInt62(), and srand().

Referenced by main().

◆ signedRandomBigInt62()

DGtal::BigInteger signedRandomBigInt62 ( )
Returns
a random (signed) integer of type DGtal::BigInteger lying in the range [-2^62 ; 2^62[

Definition at line 208 of file testInHalfPlane-benchmark.cpp.

209 {
211  if (rand() % 2)
212  return x;
213  else
214  return -x;
215 }
DGtal::BigInteger randomBigInt62()

References randomBigInt62().

Referenced by randomTest62All().

◆ signedRandomDouble52()

double signedRandomDouble52 ( )
Returns
a random (signed) integer of type double lying in the range [-2^52 ; 2^52[

Definition at line 187 of file testInHalfPlane-benchmark.cpp.

188 {
189  double x = randomDouble52();
190  return ((rand() % 2) ? x : -x);
191 }
double randomDouble52()

References randomDouble52().

Referenced by randomTest52All().

◆ signedRandomInt15()

DGtal::int32_t signedRandomInt15 ( )
Returns
a random (signed) integer of type DGtal::int32_t lying in the range [-2^15 ; 2^15[

Definition at line 147 of file testInHalfPlane-benchmark.cpp.

148 {
150  return ((rand() % 2) ? x : -x);
151 }

References randomInt15().

Referenced by randomTest30All().

◆ signedRandomInt26()

DGtal::int32_t signedRandomInt26 ( )
Returns
a random (signed) integer of type DGtal::int32_t lying in the range [-2^26 ; 2^26[

Definition at line 157 of file testInHalfPlane-benchmark.cpp.

158 {
160  return ((rand() % 2) ? x : -x);
161 }
DGtal::int32_t randomInt26()

References randomInt26().

Referenced by randomTest52All().

◆ signedRandomInt30()

DGtal::int32_t signedRandomInt30 ( )
Returns
a random (signed) integer of type DGtal::int32_t lying in the range [-2^30 ; 2^30[

Definition at line 167 of file testInHalfPlane-benchmark.cpp.

168 {
170  return ((rand() % 2) ? x : -x);
171 }

References randomInt30().

Referenced by randomTest30All(), and randomTest62All().

◆ signedRandomInt52()

DGtal::int64_t signedRandomInt52 ( )
Returns
a random (signed) integer of type DGtal::int64_t lying in the range [-2^52 ; 2^52[

Definition at line 177 of file testInHalfPlane-benchmark.cpp.

178 {
180  return ((rand() % 2) ? x : -x);
181 }
DGtal::int64_t randomInt52()

References randomInt52().

Referenced by randomTest52All().

◆ signedRandomInt62()

DGtal::int64_t signedRandomInt62 ( )
Returns
a random (signed) integer of type DGtal::int64_t lying in the range [-2^62 ; 2^62[

Definition at line 197 of file testInHalfPlane-benchmark.cpp.

198 {
200  return ((rand() % 2) ? x : -x);
201 }
DGtal::int64_t randomInt62()

References randomInt62().

Referenced by randomTest62All().