bindings/python/static-persistence.h
author Dmitriy Morozov <dmitriy@mrzv.org>
Tue, 27 Jun 2017 09:38:20 -0700
changeset 286 0496c5f88b2a
parent 232 edbbf84fde9e
permissions -rw-r--r--
Remove 'hg up tip' from doc/get-build-install.rst

#ifndef __PYTHON_STATIC_PERSISTENCE_H__
#define __PYTHON_STATIC_PERSISTENCE_H__

#include <topology/static-persistence.h>

#include "filtration.h"

namespace dionysus {
namespace python   {

typedef         StaticPersistence<>             SPersistence;
typedef         SPersistence::OrderElement      SPersistenceNode;
typedef         SPersistence::OrderIndex        SPersistenceIndex;
typedef         SPersistence::SimplexMap<PythonFiltration>        
                                                SPersistenceSimplexMap;


/* Persistence */
template<class Persistence>
boost::shared_ptr<Persistence>          init_from_filtration(bp::object f)
{
    PythonFiltration& sf = bp::extract<PythonFiltration&>(f);
    boost::shared_ptr<Persistence> p(new Persistence(sf));
    return p;
}

template<class Persistence, class PersistenceIndex>
unsigned                                distance(Persistence& p, 
                                                 const PersistenceIndex& i)             { return p.iterator_to(i) - p.begin(); }

/* SPNode */
template<class PNode>
const PNode&                            pair(const PNode& n)                            { return *n.pair; }


/* PersistenceSimplexMap */
template<class PersistenceSimplexMap, class PersistenceIndex>
const SimplexVD&                        psmap_getitem(const PersistenceSimplexMap& psmap, 
                                                      const PersistenceIndex& i)        { return psmap[i]; }


} } // namespace dionysus::python

#endif