Cleaned up AssertMsg in debug.h, and adjusted assertions in filtration.hpp
authorDmitriy Morozov <morozov@cs.duke.edu>
Sun, 03 Dec 2006 22:38:34 -0500
changeset 2 b75a0599c75b
parent 1 b227c7a027cd
child 3 76a2c73ecbbf
Cleaned up AssertMsg in debug.h, and adjusted assertions in filtration.hpp
include/debug.h
include/filtration.hpp
--- a/include/debug.h	Mon Oct 30 14:40:34 2006 -0500
+++ b/include/debug.h	Sun Dec 03 22:38:34 2006 -0500
@@ -75,9 +75,9 @@
 
 #define AssertMsg(TEST,MSG)                                           \
 				 ( (TEST) ? (void)0                                   \
-						  : (std::cerr << __FILE__ "(" << __LINE__    \
+						  : (std::cerr << __FILE__ " (" << __LINE__    \
 								  << "): Assertion failed " #TEST     \
-								  << MSG << std::endl,abort()))
+								  << " - " << MSG << std::endl,abort()))
 /*
 #define AssertMsg(TEST,STRM,MSG)                                      \
 				 ( (TEST) ? (void)0                                   \
--- a/include/filtration.hpp	Mon Oct 30 14:40:34 2006 -0500
+++ b/include/filtration.hpp	Sun Dec 03 22:38:34 2006 -0500
@@ -54,6 +54,8 @@
 		{
 			Index i = bdry.top(cycles_cmp);
 			Dout(dc::filtration, *i << ": " << *(i->pair()));
+			AssertMsg(!cycles_cmp(i, j), "Simplices in the cycle must precede current simplex: " << 
+										 "(" << *i << " in cycle of " << *j << ")");
 			AssertMsg(i->value() <= j->value(), "Values in the cycle must be less than the value of the simplex");
 
 			// i is not paired, so we pair j with i
@@ -169,12 +171,14 @@
 /* Filtration Private */
 template<class S, class FS>
 void
-Filtration<S, FS>::init_cycle_trail(Index j)
+Filtration<S, FS>::
+init_cycle_trail(Index j)
 {
 	typename Simplex::Cycle bdry = j->boundary();
 
 	for (typename Simplex::Cycle::const_iterator cur = bdry.begin(); cur != bdry.end(); ++cur)
 	{
+		AssertMsg(get_index(*cur) != end(), "Non-existent simplex in the cycle");
 		Dout(dc::filtration, "Appending in init_cycle_trail(): " << *cur);
 		j->cycle().append(get_index(*cur));
 	}