--- a/examples/consistency/rips-consistency-zigzag.cpp Thu Jul 30 10:35:49 2009 -0700
+++ b/examples/consistency/rips-consistency-zigzag.cpp Tue Jul 28 13:27:13 2009 -0700
@@ -68,7 +68,7 @@
{ out << "(d=" << bi.dimension << ") " << bi.index; if (bi.un) out << " U " << (bi.index + 1); return out; }
// Forward declarations of auxilliary functions
-void report_death(std::ostream& out, const BirthInfo& birth, const BirthInfo& death);
+void report_death(std::ostream& out, const BirthInfo& birth, const BirthInfo& death, unsigned skeleton_dimension);
void make_boundary(const Smplx& s, Complex& c, const Zigzag& zz, Boundary& b);
void process_command_line_options(int argc,
char* argv[],
@@ -78,9 +78,9 @@
std::string& subsample_filename,
std::string& outfilename);
void add_simplex(const Smplx& s, const BirthInfo& birth, const BirthInfo& death,
- Complex& complex, Zigzag& zz, std::ostream& out, Timer& add);
+ Complex& complex, Zigzag& zz, std::ostream& out, Timer& add, unsigned skeleton_dimension);
void remove_simplex(const Smplx& s, const BirthInfo& birth, const BirthInfo& death,
- Complex& complex, Zigzag& zz, std::ostream& out, Timer& remove);
+ Complex& complex, Zigzag& zz, std::ostream& out, Timer& remove, unsigned skeleton_dimension);
int main(int argc, char* argv[])
{
@@ -179,7 +179,7 @@
for (SimplexVector::const_iterator cur = subcomplex.begin(); cur != subcomplex.end(); ++cur)
{
add_simplex(*cur, BirthInfo(cur->dimension(), i, true), BirthInfo(cur->dimension() - 1, i),
- complex, zz, out, add);
+ complex, zz, out, add, skeleton_dimension);
// Record cofaces with all other vertices outside of the subcomplex
coface.start();
@@ -193,7 +193,7 @@
// Add simplices that cut across VR(K_i) and VR(K_{i+1})
for (SimplexVector::const_iterator cur = across.begin(); cur != across.end(); ++cur)
add_simplex(*cur, BirthInfo(cur->dimension(), i, true), BirthInfo(cur->dimension() - 1, i),
- complex, zz, out, add);
+ complex, zz, out, add, skeleton_dimension);
rInfo(" Cross simplices added");
@@ -213,12 +213,12 @@
for (SimplexVector::const_reverse_iterator cur = across.rbegin(); cur != across.rend(); ++cur)
remove_simplex(*cur, BirthInfo(cur->dimension() - 1, i+1), BirthInfo(cur->dimension(), i, true),
- complex, zz, out, remove);
+ complex, zz, out, remove, skeleton_dimension);
rInfo(" Cross simplices removed");
for (SimplexVector::const_reverse_iterator cur = subcomplex.rbegin(); cur != subcomplex.rend(); ++cur)
remove_simplex(*cur, BirthInfo(cur->dimension() - 1, i+1), BirthInfo(cur->dimension(), i, true),
- complex, zz, out, remove);
+ complex, zz, out, remove, skeleton_dimension);
rInfo(" Subcomplex simplices removed");
Dimension betti_1 = 0;
@@ -249,14 +249,14 @@
}
}
-void report_death(std::ostream& out, const BirthInfo& birth, const BirthInfo& death)
+void report_death(std::ostream& out, const BirthInfo& birth, const BirthInfo& death, unsigned skeleton_dimension)
{
- if (death > birth)
+ if (birth.dimension < skeleton_dimension && death > birth)
out << birth << " --- " << death << std::endl;
}
void add_simplex(const Smplx& s, const BirthInfo& birth, const BirthInfo& death,
- Complex& complex, Zigzag& zz, std::ostream& out, Timer& add)
+ Complex& complex, Zigzag& zz, std::ostream& out, Timer& add, unsigned skeleton_dimension)
{
rDebug("Adding simplex: %s", tostring(s).c_str());
@@ -264,13 +264,13 @@
make_boundary(s, complex, zz, b);
add.start();
boost::tie(idx, d) = zz.add(b, birth);
- if (d) report_death(out, *d, death);
+ if (d) report_death(out, *d, death, skeleton_dimension);
add.stop();
complex.insert(std::make_pair(s, idx));
}
void remove_simplex(const Smplx& s, const BirthInfo& birth, const BirthInfo& death,
- Complex& complex, Zigzag& zz, std::ostream& out, Timer& remove)
+ Complex& complex, Zigzag& zz, std::ostream& out, Timer& remove, unsigned skeleton_dimension)
{
rDebug("Removing simplex: %s", tostring(s).c_str());
@@ -278,7 +278,7 @@
remove.start();
Death d = zz.remove(si->second, birth);
remove.stop();
- if (d) report_death(out, *d, death);
+ if (d) report_death(out, *d, death, skeleton_dimension);
complex.erase(si);
}