33#include "DGtal/base/Common.h"
35#include "DGtal/kernel/PointVector.h"
37#include "DGtal/geometry/tools/determinant/C2x2DetComputer.h"
38#include "DGtal/geometry/tools/determinant/Simple2x2DetComputer.h"
39#include "DGtal/geometry/tools/determinant/SimpleIncremental2x2DetComputer.h"
40#include "DGtal/geometry/tools/determinant/AvnaimEtAl2x2DetSignComputer.h"
41#include "DGtal/geometry/tools/determinant/Filtered2x2DetComputer.h"
43#include "DGtal/geometry/tools/determinant/COrientationFunctor2.h"
44#include "DGtal/geometry/tools/determinant/InHalfPlaneBy2x2DetComputer.h"
45#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
105 static_cast<double>(rand() % 128) +
127#ifdef WITH_BIGINTEGER
150 return ((rand() % 2) ? x : -x);
160 return ((rand() % 2) ? x : -x);
170 return ((rand() % 2) ? x : -x);
180 return ((rand() % 2) ? x : -x);
190 return ((rand() % 2) ? x : -x);
200 return ((rand() % 2) ? x : -x);
203#ifdef WITH_BIGINTEGER
230template<
typename OrientationFunctor,
typename RandomFunctor>
235 typedef typename OrientationFunctor::Point
Point;
238 clock_t timeBegin, timeEnd;
254 long double time, CPUTime;
255 time = ((double)timeEnd-(
double)timeBegin);
256 CPUTime = time/((double)CLOCKS_PER_SEC);
257 std::cout << CPUTime <<
" ";
272template<
typename OrientationFunctor,
typename RandomFunctor>
277 typedef typename OrientationFunctor::Point
Point;
280 clock_t timeBegin, timeEnd;
294 long double time, CPUTime;
295 time = ((double)timeEnd-(
double)timeBegin);
296 CPUTime = time/((double)CLOCKS_PER_SEC);
297 std::cout << CPUTime <<
" ";
312template<
typename OrientationFunctor,
typename RandomFunctor>
317 typedef typename OrientationFunctor::Point
Point;
320 clock_t timeBegin, timeEnd;
334 long double time, CPUTime;
335 time = ((double)timeEnd-(
double)timeBegin);
336 CPUTime = time/((double)CLOCKS_PER_SEC);
337 std::cout << CPUTime <<
" ";
353template<
typename OrientationFunctor,
typename RandomFunctor>
358 typedef typename OrientationFunctor::Point
Point;
362 typedef typename Point::Coordinate Coordinate;
363 Coordinate k, l, u0, u1;
365 clock_t timeBegin, timeEnd;
383 long double time, CPUTime;
384 time = ((double)timeEnd-(
double)timeBegin);
385 CPUTime = time/((double)CLOCKS_PER_SEC);
386 std::cout << CPUTime <<
" ";
403template<
typename OrientationFunctor,
typename RandomFunctor>
408 typedef typename OrientationFunctor::Point
Point;
412 typedef typename Point::Coordinate Coordinate;
413 Coordinate k, l, u0, u1;
415 clock_t timeBegin, timeEnd;
425 Q[0] += (rand()%5)-2;
427 Q[1] += (rand()%5)-2;
429 R[0] += (rand()%5)-2;
431 R[1] += (rand()%5)-2;
437 long double time, CPUTime;
438 time = ((double)timeEnd-(
double)timeBegin);
439 CPUTime = time/((double)CLOCKS_PER_SEC);
440 std::cout << CPUTime <<
" ";
457template<
typename OrientationFunctor>
462 typedef typename OrientationFunctor::Point
Point;
465 typedef typename Point::Coordinate Coordinate;
468 Coordinate
max = 1073741824;
474 clock_t timeBegin, timeEnd;
479 dx = (rand() % 3) - 1;
480 dy = (rand() % 3) - 1;
482 ASSERT(
R[0] >= -
max );
483 ASSERT(
R[0] <
max );
485 ASSERT(
R[0] >= -
max );
486 ASSERT(
R[0] <
max );
491 long double time, CPUTime;
492 time = ((double)timeEnd-(
double)timeBegin);
493 CPUTime = time/((double)CLOCKS_PER_SEC);
494 std::cout << CPUTime <<
" ";
508 long seed = time(NULL);
510 std::cout <<
"# incremental input " << std::endl;
511 std::cout <<
"# running times in s. for 1 million tries" << std::endl;
515 std::cout <<
"2x2-int32-int64 ";
519 std::cout << std::endl;
523 std::cout <<
"2x2-inc-int32-int64 ";
527 std::cout << std::endl;
531 std::cout <<
"2x2-avnaim++-int32-double ";
536 std::cout << std::endl;
538#ifdef WITH_BIGINTEGER
541 std::cout <<
"2x2-int32-BigInt ";
545 std::cout << std::endl;
549 std::cout <<
"2x2-inc-int32-BigInt ";
553 std::cout << std::endl;
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;
573 long seed = time(NULL);
577 std::cout <<
"3x3-int32-int64 ";
584 std::cout << std::endl;
586#ifdef WITH_BIGINTEGER
589 std::cout <<
"3x3-int32-BigInt ";
596 std::cout << std::endl;
601 std::cout <<
"2x2-int32-int64 ";
609 std::cout << std::endl;
611#ifdef WITH_BIGINTEGER
614 std::cout <<
"2x2-int32-BigInt ";
622 std::cout << std::endl;
627 std::cout <<
"2x2-inc-int32-int64 ";
635 std::cout << std::endl;
637#ifdef WITH_BIGINTEGER
640 std::cout <<
"2x2-inc-int32-BigInt ";
648 std::cout << std::endl;
653 std::cout <<
"2x2-avnaim-int32-int32 ";
661 std::cout << std::endl;
665 std::cout <<
"2x2-avnaim-int32-double ";
673 std::cout << std::endl;
677 std::cout <<
"2x2-avnaim++-int32-double ";
686 std::cout << std::endl;
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;
704 long seed = time(NULL);
706#ifdef WITH_BIGINTEGER
709 std::cout <<
"3x3-double-BigInt ";
717 std::cout << std::endl;
721 std::cout <<
"2x2-double-BigInt ";
730 std::cout << std::endl;
734 std::cout <<
"2x2-inc-double-BigInt ";
743 std::cout << std::endl;
748 std::cout <<
"2x2-avnaim-int64-int64 ";
757 std::cout << std::endl;
761 std::cout <<
"2x2-avnaim-double-int64 ";
770 std::cout << std::endl;
774 std::cout <<
"2x2-avnaim-int64-double ";
783 std::cout << std::endl;
787 std::cout <<
"2x2-avnaim-double-double ";
796 std::cout << std::endl;
800 std::cout <<
"2x2-avnaim++-int64-double ";
810 std::cout << std::endl;
814 std::cout <<
"2x2-avnaim++-double-double ";
824 std::cout << std::endl;
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;
842 long seed = time(NULL);
844#ifdef WITH_BIGINTEGER
847 std::cout <<
"3x3-BigInt-BigInt ";
855 std::cout << std::endl;
859 std::cout <<
"2x2-BigInt-BigInt ";
868 std::cout << std::endl;
872 std::cout <<
"2x2-inc-BigInt-BigInt ";
881 std::cout << std::endl;
886 std::cout <<
"2x2-avnaim-int64-int64 ";
895 std::cout << std::endl;
899 std::cout <<
"2x2-avnaim++-int64-longdouble ";
909 std::cout << std::endl;
918int main(
int argc,
char** argv )
922 for (
int i = 0; i < argc; ++i )
932 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
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: 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.
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...
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
boost::int64_t int64_t
signed 94-bit integer.
boost::int32_t int32_t
signed 32-bit integer.
mpz_class BigInteger
Multi-precision integer with GMP implementation.
Aim: This concept is a refinement of COrientationFunctor, useful for simple algebraic curves that can...
DGtal::int32_t randomInt15()
bool nullZeroVectorTest(OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
DGtal::BigInteger signedRandomBigInt62()
DGtal::int32_t randomInt30()
DGtal::int64_t signedRandomInt52()
DGtal::int32_t randomInt26()
DGtal::int64_t signedRandomInt62()
bool incTest(OrientationFunctor f, const DGtal::int32_t n=1000000)
DGtal::int64_t randomInt52()
DGtal::int32_t signedRandomInt30()
DGtal::int32_t signedRandomInt15()
bool randomTest(OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
double signedRandomDouble52()
bool quasiNullTest(OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
DGtal::int64_t randomInt62()
bool nullSameVectorsTest(OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
DGtal::int32_t signedRandomInt26()
bool nullTest(OrientationFunctor f, RandomFunctor gen, const DGtal::int32_t n=1000000)
DGtal::BigInteger randomBigInt62()