include/topology/lowerstarfiltration.h
author Dmitriy Morozov <dmitriy@mrzv.org>
Thu, 09 Jul 2009 02:42:47 -0700
branchdev
changeset 138 96030f8d2f2c
parent 100 884f70adc576
child 179 d15c6d144645
permissions -rw-r--r--
Rips pairwise cohomology produces output necessary for 1-cocycle parametrization

/*
 * Author: Dmitriy Morozov
 * Department of Computer Science, Duke University, 2005 -- 2008
 */

#ifndef __LOWERSTARFILTRATION_H__
#define __LOWERSTARFILTRATION_H__

#include <boost/serialization/access.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/nvp.hpp>

/**
 * Struct: MaxVertexComparison
 *
 * Functor that determines which simplex has a higher vertex with respect to VertexComparison_
 */
template<class Simplex_, class VertexComparison_>
struct MaxVertexComparison
{
    typedef                     VertexComparison_                                   VertexComparison;
    typedef                     Simplex_                                            Simplex;

                                MaxVertexComparison(const VertexComparison& vcmp):
                                    vcmp_(vcmp)                                     {}

    bool                        operator()(const Simplex& s1, const Simplex& s2) const
    {
        return std::max_element(s1.vertices().begin(), s1.vertices().end(), vcmp) <
               std::max_element(s2.vertices().begin(), s2.vertices().end(), vcmp);
    }

    VertexComparison            vcmp_;
};


/**
 * Map from i-th vertex to its index in the filtration.
 */
template<class Index_>
class VertexSimplexMap
{
    public:
        typedef                 Index_                                              Index;
        typedef                 std::vector<FiltrationIndex>                        VertexVector;
                                
                                VertexSimplexMap(Index begin, Index end, const Map& m)
        {
            for (FiltrationIndex cur = begin; cur != end; ++cur)
                if (m[cur].dimension() == 0)
                    vertices_.push_back(cur);
        }

    private:
        VertexVector            vertices_;
};

// TODO: transpose_vertices(Index, Filtration, Persistence, Visitor);

#endif // __LOWERSTARFILTRATION_H__