examples/rips/rips.cpp
author Dmitriy Morozov <dmitriy@mrzv.org>
Tue, 20 Jan 2009 10:53:35 -0800
branchdev
changeset 110 430d9e71e921
parent 109 75eb7a4628f2
child 113 3e8bebb5d857
permissions -rw-r--r--
Implemented ImageZigzagPersistence * Changed ZigzagPersistence to support a visitor, and implemented ImageZigzagPersistence * examples/rips/rips-zigzag now computes using ImageZigzagPersistence * PersistenceDiagram no longer records zero persistence pairs * Added utilities/memory.h with report_memory() function

#include <topology/rips.h>

// Trivial example of size() points on a line with integer coordinates
struct Distances
{
    typedef         int             IndexType;
    typedef         double          DistanceType;

    DistanceType    operator()(IndexType a, IndexType b) const      { return std::abs(a - b); }

    size_t          size() const                                    { return 2000; }
    IndexType       begin() const                                   { return 0; }
    IndexType       end() const                                     { return size(); }
};

int main(int argc, char* argv[])
{
#ifdef LOGGING
	rlog::RLogInit(argc, argv);

	stdoutLog.subscribeTo( RLOG_CHANNEL("error") );
	stdoutLog.subscribeTo( RLOG_CHANNEL("rips/info") );
#endif

    Distances distances;
    
#if 0
    // Storing ExplicitDistances speeds up the computation (at the price of memory)
    typedef         RipsGenerator<ExplicitDistances<Distances> >    RipsGenerator;
    ExplicitDistances<Distances> explicit_distances(distances);
    RipsGenerator rips(explicit_distances);
#else
    //typedef         RipsGeneratorMemory<Distances>                        RipsGenerator;
    typedef         RipsGenerator<Distances>                        RipsGenerator;
    RipsGenerator   rips(distances);
#endif

    RipsGenerator::SimplexVector complex;
    //rips.generate(complex, 3, distances.size());
    rips.generate(complex, 3, 50);
    
    std::cout << "Size: " << complex.size() << std::endl;
//    for (RipsGenerator::SimplexVector::const_iterator cur = complex.begin(); cur != complex.end(); ++cur)
//        std::cout << *cur << std::endl;
}