Do not use _DEBUG, prefix some macros by CGAL_KD_.

This commit is contained in:
Sylvain Pion 2007-05-23 13:33:11 +00:00
parent 50bdf94b7f
commit 51b8b2e28a
12 changed files with 68 additions and 69 deletions

View File

@ -75,8 +75,8 @@ Let |j = C.index_of_vertex_in_opposite_facet(f,i)|. Then
#include <list> #include <list>
#include <vector> #include <vector>
#undef _DEBUG #undef CGAL_KD_DEBUG
#define _DEBUG 93 #define CGAL_KD_DEBUG 93
#include <CGAL/Kernel_d/debug.h> #include <CGAL/Kernel_d/debug.h>
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE

View File

@ -35,8 +35,8 @@
#include <list> #include <list>
#include <cstddef> #include <cstddef>
#undef _DEBUG #undef CGAL_KD_DEBUG
#define _DEBUG 93 #define CGAL_KD_DEBUG 93
#include <CGAL/Kernel_d/debug.h> #include <CGAL/Kernel_d/debug.h>
#ifdef CGAL_USE_LEDA #ifdef CGAL_USE_LEDA

View File

@ -23,7 +23,7 @@ typedef double RT;
int main() int main()
{ {
SETDTHREAD(11); CGAL_KD_SETDTHREAD(11);
CGAL::set_pretty_mode ( std::cerr ); CGAL::set_pretty_mode ( std::cerr );
CGAL_TEST_START; CGAL_TEST_START;
{ {

View File

@ -27,7 +27,7 @@ typedef double FT;
int main() int main()
{ {
CGAL::set_pretty_mode ( std::cerr ); CGAL::set_pretty_mode ( std::cerr );
SETDTHREAD(193); CGAL_KD_SETDTHREAD(193);
CGAL_TEST_START; CGAL_TEST_START;
{ {
typedef CGAL::Cartesian_d<FT> Kernel; typedef CGAL::Cartesian_d<FT> Kernel;

View File

@ -73,30 +73,30 @@ Gaussian_elimination(const Matrix &M,
for (i=0; i<cdim; ++i) column_permutation.push_back(i); for (i=0; i<cdim; ++i) column_permutation.push_back(i);
// Main loop : invariant is that L * M[q] = U // Main loop : invariant is that L * M[q] = U
// M[q] stands for M with row i permuted with row q[i] // M[q] stands for M with row i permuted with row q[i]
TRACEN("START GAUSS ELIMINATION"); CGAL_KD_TRACEN("START GAUSS ELIMINATION");
det = 1; det = 1;
for (k=0; k<dim; ++k) { for (k=0; k<dim; ++k) {
// Total pivoting, without looking for the maximum entry // Total pivoting, without looking for the maximum entry
for (i=k,j=k; for (i=k,j=k;
j<cdim && U[i][j] == FT(0); j<cdim && U[i][j] == FT(0);
(++i==dim)? ++j,i=k : 0 ) ; (++i==dim)? ++j,i=k : 0 ) ;
TRACEN("before swap [k="<<k<<"] :"); CGAL_KD_TRACEN("before swap [k="<<k<<"] :");
TRACEN(" found i="<<i<<" and j="<<j); CGAL_KD_TRACEN(" found i="<<i<<" and j="<<j);
TRACEV(U); CGAL_KD_TRACEV(U);
if (j==cdim) break; if (j==cdim) break;
if (i!=k) { if (i!=k) {
TRACEN("swap row i="<<i<<" and k="<<k); CGAL_KD_TRACEN("swap row i="<<i<<" and k="<<k);
U.swap_rows(i,k); L.swap_rows(i,k); U.swap_rows(i,k); L.swap_rows(i,k);
std::swap(row_permutation[k], row_permutation[i]); std::swap(row_permutation[k], row_permutation[i]);
sign = -sign; sign = -sign;
} }
if (j!=k) { if (j!=k) {
TRACEN("swap column j="<<j<<" and k="<<k); CGAL_KD_TRACEN("swap column j="<<j<<" and k="<<k);
U.swap_columns(j,k); U.swap_columns(j,k);
std::swap(column_permutation[j],column_permutation[k]); std::swap(column_permutation[j],column_permutation[k]);
sign = -sign; sign = -sign;
} }
TRACEN("after swap: "<<U); CGAL_KD_TRACEN("after swap: "<<U);
FT pivot = U[k][k]; FT pivot = U[k][k];
CGAL_assertion(pivot != FT(0)); CGAL_assertion(pivot != FT(0));
det *= pivot; det *= pivot;
@ -110,7 +110,7 @@ Gaussian_elimination(const Matrix &M,
} }
} }
TRACEN("END GAUSS ELIMINATION"); TRACEV(L);TRACEV(U); CGAL_KD_TRACEN("END GAUSS ELIMINATION"); CGAL_KD_TRACEV(L);CGAL_KD_TRACEV(U);
// By invariant, L * M[q] = U and det(M) = det // By invariant, L * M[q] = U and det(M) = det
rank = k; rank = k;
if (rank == dim) { if (rank == dim) {
@ -132,7 +132,7 @@ Triangular_system_solver(const Matrix &U, const Matrix& L, const Vector &b,
// back substitution of x[rdim], x[rdim-1], etc. // back substitution of x[rdim], x[rdim-1], etc.
// depends on "free" variables x[rdim+1], etc. x[cdim] // depends on "free" variables x[rdim+1], etc. x[cdim]
CGAL_kernel_assertion( U.row_dimension() == b.dimension()); CGAL_kernel_assertion( U.row_dimension() == b.dimension());
TRACEN("Triangular_system_solver");TRACEV(U);TRACEV(b); CGAL_KD_TRACEN("Triangular_system_solver");CGAL_KD_TRACEV(U);CGAL_KD_TRACEV(b);
D = FT(1); int i; D = FT(1); int i;
for (i = rank; i < U.row_dimension(); ++i) for (i = rank; i < U.row_dimension(); ++i)
if ( b[i] != FT(0) ) { x = L.row(i); return false; } if ( b[i] != FT(0) ) { x = L.row(i); return false; }
@ -155,7 +155,7 @@ Triangular_left_inverse(const Matrix &U, Matrix &Uinv)
{ {
int i, j, k; int i, j, k;
CGAL_kernel_precondition(U.dimension() == transpose(Uinv.dimension())); CGAL_kernel_precondition(U.dimension() == transpose(Uinv.dimension()));
TRACEN("system : " << U); CGAL_KD_TRACEN("system : " << U);
for (i=U.row_dimension()-1; i>=0; --i) { for (i=U.row_dimension()-1; i>=0; --i) {
Uinv[i][i] = FT(1)/U[i][i]; Uinv[i][i] = FT(1)/U[i][i];
for (j=i+1; j<U.column_dimension(); ++j) { for (j=i+1; j<U.column_dimension(); ++j) {
@ -164,7 +164,7 @@ Triangular_left_inverse(const Matrix &U, Matrix &Uinv)
Uinv[i][j] /= U[j][j]; Uinv[i][j] /= U[j][j];
} }
} }
TRACEN("finally : " << Uinv); CGAL_KD_TRACEN("finally : " << Uinv);
} }
template < class FT, class AL > template < class FT, class AL >
@ -184,7 +184,7 @@ inverse(const Matrix &M, Matrix &I, FT &D, Vector &c)
Uinv = Uinv * L; Uinv = Uinv * L;
// Don't forget to permute the rows of M back // Don't forget to permute the rows of M back
TRACEN("inverse before permutation : "<<I); CGAL_KD_TRACEN("inverse before permutation : "<<I);
I = Matrix(M.column_dimension(),M.row_dimension()); I = Matrix(M.column_dimension(),M.row_dimension());
typename Matrix::row_iterator rit, wit; typename Matrix::row_iterator rit, wit;
for (rank=0; rank<I.column_dimension(); ++rank) for (rank=0; rank<I.column_dimension(); ++rank)
@ -264,7 +264,7 @@ linear_solver(const Matrix &M, const Vector &b,
Matrix L,U; Matrix L,U;
int rank; int rank;
std::vector<int> dummy, var; std::vector<int> dummy, var;
TRACEN("linear_solver");TRACEV(M); TRACEV(b); CGAL_KD_TRACEN("linear_solver");CGAL_KD_TRACEV(M); CGAL_KD_TRACEV(b);
Gaussian_elimination(M, L, U, dummy, var, D, rank, c); Gaussian_elimination(M, L, U, dummy, var, D, rank, c);
// Compute a solution by solving triangular system // Compute a solution by solving triangular system
// Since LM=U, and x is a solution of Mx=b, then Ux=Lb // Since LM=U, and x is a solution of Mx=b, then Ux=Lb
@ -294,7 +294,7 @@ linear_solver(const Matrix &M, const Vector &b,
Matrix L,U; Matrix L,U;
int rank; int rank;
std::vector<int> dummy, var; std::vector<int> dummy, var;
TRACEN("linear_solver");TRACEV(M); TRACEV(b); CGAL_KD_TRACEN("linear_solver");CGAL_KD_TRACEV(M); CGAL_KD_TRACEV(b);
Gaussian_elimination(M, L, U, dummy, var, D, rank, c); Gaussian_elimination(M, L, U, dummy, var, D, rank, c);
// Compute a solution by solving triangular system // Compute a solution by solving triangular system
// Since LM=U, and x is a solution of Mx=b, then Ux=Lb // Since LM=U, and x is a solution of Mx=b, then Ux=Lb
@ -320,7 +320,7 @@ linear_solver(const Matrix &M, const Vector &b,
h -= U(i,j)*spanning_vectors(var[j],l); h -= U(i,j)*spanning_vectors(var[j],l);
spanning_vectors(var[i],l)= h / U(i,i); spanning_vectors(var[i],l)= h / U(i,i);
} }
TRACEV(spanning_vectors.column(l)); CGAL_KD_TRACEV(spanning_vectors.column(l));
#ifdef CGAL_LA_SELFTEST #ifdef CGAL_LA_SELFTEST
CGAL_assertion( (M*spanning_vectors.column(l)).is_zero() ); CGAL_assertion( (M*spanning_vectors.column(l)).is_zero() );
@ -362,7 +362,7 @@ homogeneous_linear_solver(const Matrix &M, Matrix &spanning_vectors)
#ifdef CGAL_LA_SELFTEST #ifdef CGAL_LA_SELFTEST
Vector x; Vector x;
Triangular_system_solver(U, L, b, rank, c, D); Triangular_system_solver(U, L, b, rank, c, D);
TRACEV(M);TRACEV(U);TRACEV(b);TRACEV(rank);TRACEV(c);TRACEV(D); CGAL_KD_TRACEV(M);CGAL_KD_TRACEV(U);CGAL_KD_TRACEV(b);CGAL_KD_TRACEV(rank);CGAL_KD_TRACEV(c);CGAL_KD_TRACEV(D);
x = Vector(M.column_dimension()); x = Vector(M.column_dimension());
for (i=0; i<U.row_dimension(); ++i) for (i=0; i<U.row_dimension(); ++i)
x[ var[i] ] = c[i]; x[ var[i] ] = c[i];
@ -386,7 +386,7 @@ homogeneous_linear_solver(const Matrix &M, Matrix &spanning_vectors)
h -= U(i,j)*spanning_vectors(var[j],l); h -= U(i,j)*spanning_vectors(var[j],l);
spanning_vectors(var[i],l)= h / U(i,i); spanning_vectors(var[i],l)= h / U(i,i);
} }
TRACEV(spanning_vectors.column(l)); CGAL_KD_TRACEV(spanning_vectors.column(l));
#ifdef CGAL_LA_SELFTEST #ifdef CGAL_LA_SELFTEST
/* we check whether the $l$ - th spanning vector is a solution /* we check whether the $l$ - th spanning vector is a solution

View File

@ -27,8 +27,8 @@
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <CGAL/memory.h> #include <CGAL/memory.h>
#undef _DEBUG #undef CGAL_KD_DEBUG
#define _DEBUG 51 #define CGAL_KD_DEBUG 51
#include <CGAL/Kernel_d/debug.h> #include <CGAL/Kernel_d/debug.h>
#include <cmath> #include <cmath>

View File

@ -20,19 +20,20 @@
// //
// //
// Author(s) : Michael Seel <seel@mpi-sb.mpg.de> // Author(s) : Michael Seel <seel@mpi-sb.mpg.de>
#ifndef CGAL_DEBUG_H //
#define CGAL_DEBUG_H #ifndef CGAL_KERNEL_D_DEBUG_H
#define CGAL_KERNEL_D_DEBUG_H
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <sstream> #include <sstream>
#undef TRACE #undef CGAL_KD_TRACE
#undef TRACEN #undef CGAL_KD_TRACEN
#undef TRACEV #undef CGAL_KD_TRACEV
#undef CTRACE #undef CGAL_KD_CTRACE
#undef CTRACEN #undef CGAL_KD_CTRACEN
#undef ASSERT #undef CGAL_KD_ASSERT
static int debugthread=3141592; static int debugthread=3141592;
namespace { namespace {
@ -40,49 +41,49 @@ namespace {
int Avoid_warning_for_unused_debugthread::x = debugthread; int Avoid_warning_for_unused_debugthread::x = debugthread;
} }
#if _DEBUG>0 #if CGAL_KD_DEBUG>0
#define SETDTHREAD(l) debugthread=l #define CGAL_KD_SETDTHREAD(l) debugthread=l
#else #else
#define SETDTHREAD(l) #define CGAL_KD_SETDTHREAD(l)
#endif #endif
#if _DEBUG>0 #if CGAL_KD_DEBUG>0
#define TRACE(t) if((debugthread%_DEBUG)==0)\ #define CGAL_KD_TRACE(t) if((debugthread%CGAL_KD_DEBUG)==0)\
std::cerr<<" "<<t;std::cerr.flush() std::cerr<<" "<<t;std::cerr.flush()
#else #else
#define TRACE(t) #define CGAL_KD_TRACE(t)
#endif #endif
#if _DEBUG>0 #if CGAL_KD_DEBUG>0
#define TRACEV(t) if((debugthread%_DEBUG)==0)\ #define CGAL_KD_TRACEV(t) if((debugthread%CGAL_KD_DEBUG)==0)\
std::cerr<<" "<<#t<<" = "<<(t)<<std::endl;std::cerr.flush() std::cerr<<" "<<#t<<" = "<<(t)<<std::endl;std::cerr.flush()
#else #else
#define TRACEV(t) #define CGAL_KD_TRACEV(t)
#endif #endif
#if _DEBUG>0 #if CGAL_KD_DEBUG>0
#define TRACEN(t) if((debugthread%_DEBUG)==0)\ #define CGAL_KD_TRACEN(t) if((debugthread%CGAL_KD_DEBUG)==0)\
std::cerr<<" "<<t<<std::endl;std::cerr.flush() std::cerr<<" "<<t<<std::endl;std::cerr.flush()
#else #else
#define TRACEN(t) #define CGAL_KD_TRACEN(t)
#endif #endif
#if _DEBUG>0 #if CGAL_KD_DEBUG>0
#define CTRACE(b,t) if(b) std::cerr << " " << t; else std::cerr << " 0" #define CGAL_KD_CTRACE(b,t) if(b) std::cerr << " " << t; else std::cerr << " 0"
#else #else
#define CTRACE(b,t) #define CGAL_KD_CTRACE(b,t)
#endif #endif
#if _DEBUG>0 #if CGAL_KD_DEBUG>0
#define CTRACEN(b,t) if(b) std::cerr<< " " <<t<<"\n"; else std::cerr<<" 0\n" #define CGAL_KD_CTRACEN(b,t) if(b) std::cerr<< " " <<t<<"\n"; else std::cerr<<" 0\n"
#else #else
#define CTRACEN(b,t) #define CGAL_KD_CTRACEN(b,t)
#endif #endif
#ifndef _ASSERT #ifndef CGAL_KD__ASSERT
#define ASSERT(cond,fstr) #define CGAL_KD_ASSERT(cond,fstr)
#else #else
#define ASSERT(cond,fstr) \ #define CGAL_KD_ASSERT(cond,fstr) \
if (!(cond)) { \ if (!(cond)) { \
std::cerr << " ASSERT: " << #fstr << endl; \ std::cerr << " ASSERT: " << #fstr << endl; \
std::cerr << " COND: " << #cond << endl; \ std::cerr << " COND: " << #cond << endl; \
@ -118,6 +119,4 @@ std::string make_std_string(const T& t)
} // MSDEBUG } // MSDEBUG
#endif //CGAL_DEBUG_H #endif //CGAL_KERNEL_D_DEBUG_H

View File

@ -29,12 +29,12 @@
#include <CGAL/enum.h> #include <CGAL/enum.h>
#endif #endif
#undef TRACE #undef CGAL_KD_TRACE
#undef TRACEN #undef CGAL_KD_TRACEN
#undef TRACEV #undef CGAL_KD_TRACEV
#define TRACE(t) std::cerr << t #define CGAL_KD_TRACE(t) std::cerr << t
#define TRACEN(t) std::cerr << t << std::endl #define CGAL_KD_TRACEN(t) std::cerr << t << std::endl
#define TRACEV(t) std::cerr << #t << " = " << (t) << std::endl #define CGAL_KD_TRACEV(t) std::cerr << #t << " = " << (t) << std::endl
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE

View File

@ -25,8 +25,8 @@
#include <CGAL/basic.h> #include <CGAL/basic.h>
#undef _DEBUG #undef CGAL_KD_DEBUG
#define _DEBUG 11 #define CGAL_KD_DEBUG 11
#include <CGAL/Kernel_d/debug.h> #include <CGAL/Kernel_d/debug.h>

View File

@ -29,8 +29,8 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#undef _DEBUG #undef CGAL_KD_DEBUG
#define _DEBUG 13 #define CGAL_KD_DEBUG 13
#include <CGAL/Kernel_d/debug.h> #include <CGAL/Kernel_d/debug.h>

View File

@ -36,7 +36,7 @@ typedef double FT;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
SETDTHREAD(151); CGAL_KD_SETDTHREAD(151);
CGAL::set_pretty_mode ( std::cerr ); CGAL::set_pretty_mode ( std::cerr );
CGAL_TEST_START; CGAL_TEST_START;
{ {

View File

@ -30,7 +30,7 @@ typedef double FT_;
#endif #endif
int main() int main()
{ SETDTHREAD(2); { CGAL_KD_SETDTHREAD(2);
CGAL::set_pretty_mode ( std::cerr ); CGAL::set_pretty_mode ( std::cerr );
CGAL_TEST_START; CGAL_TEST_START;
{ // Homogeneous Kernel { // Homogeneous Kernel