X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=include%2Flibstick-0.1%2Fsimplicialcomplex.h;h=849bb2284e1185e338405bc60b64a3c85969f998;hb=b8116d93868855d5a2ce01c14632d571ed4ec8e5;hp=973d632e548d581fc3b893df6582644f5ce6e021;hpb=799cd8e53b06b4f9ec7d4dde13ab600717982099;p=libstick.git diff --git a/include/libstick-0.1/simplicialcomplex.h b/include/libstick-0.1/simplicialcomplex.h index 973d632..849bb22 100644 --- a/include/libstick-0.1/simplicialcomplex.h +++ b/include/libstick-0.1/simplicialcomplex.h @@ -10,7 +10,7 @@ #include -#include +#include "booleanmatrix.h" namespace libstick { @@ -121,6 +121,10 @@ class simplicial_complex { return c.simplices[order.at(i)]; } + const simplcompltype& get_complex() const { + return c; + } + /** Returns true iff the faces of simplex i are before i in this order. */ bool is_filtration() const { assert(size() == c.size()); @@ -145,13 +149,22 @@ class simplicial_complex { return is_filtration(); } + /** Randomize order. It has hardly any impact on runtime, but + * it makes cycles "nicer" when the simplice's function values + * are constant. + * */ + void randomize_order() { + std::random_shuffle(order.begin(), order.end()); + restore_revorder_from_order(); + } + /** Sort simplices such that is_monotone() gives true. This * requires that the complex's is_monotone() gave true * beforehand.*/ void make_monotone_filtration() { assert(c.is_monotone()); - sort(order.begin(), order.end(), cmp_monotone_filtration(c)); + std::sort(order.begin(), order.end(), cmp_monotone_filtration(c)); restore_revorder_from_order(); assert(c.is_monotone()); @@ -198,6 +211,11 @@ class simplicial_complex { add_simplex(simplex::create_minusonedim_simplex()); } + /** Remove all simplices except the dummy simplex */ + void clear() { + simplices.resize(1); + } + /** Return number of simplices. */ size_t size() const { return simplices.size();