summaryrefslogtreecommitdiff
path: root/matching/include/persistence_module.h
blob: ea9cfd02b8ab2c1eeed7290bad4845394672141d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef MATCHING_DISTANCE_PERSISTENCE_MODULE_H
#define MATCHING_DISTANCE_PERSISTENCE_MODULE_H

#include <cassert>
#include <vector>
#include <utility>
#include <string>

#include "common_util.h"
#include "dual_point.h"
#include "box.h"

namespace md {


    class ModulePresentation {
    public:

        struct Relation {

            Point position_;
            IntPoint bigrade_;

            Relation() {}
            Relation(const Point& _pos) : position_(_pos) { }

            Real get_x() const { return position_.x; }
            Real get_y() const { return position_.y; }

            IndexVec components_;

        };

        ModulePresentation() { }

        ModulePresentation(const std::string& fname); // read from file

        Diagram weighted_slice_diagram(const DualPoint& line) const;

        // translate all points by vector (a,a)
        void translate(Real a);

        // return minimal value of x- and y-coordinates
        Real minimal_coordinate() const { return std::min(min_x(), min_x()); }

        // return box that contains all positions of all simplices
        Box bounding_box() const;

        friend std::ostream& operator<<(std::ostream& os, const ModulePresentation& mp);

        Real max_x() const { return max_x_; }

        Real max_y() const { return max_y_; }

        Real min_x() const { return min_x_; }

        Real min_y() const { return min_y_; }

        PointVec positions() const;

    private:

        Real max_x_ { std::numeric_limits<Real>::max() };
        Real max_y_ { std::numeric_limits<Real>::max() };
        Real min_x_ { -std::numeric_limits<Real>::max() };
        Real min_y_ { -std::numeric_limits<Real>::max() };
        Box bounding_box_;

        PointVec generators_;
        std::vector<Relation> relations_;

        PointVec positions_;

        void init_boundaries();
        void project_generators(const DualPoint& slice, IndexVec& sorted_indices, RealVec& projections) const;
        void project_relations(const DualPoint& slice, IndexVec& sorted_indices, RealVec& projections) const;
    };

//    template<typename R = double>
//    R matching_distance(const PersistenceModule&, const PersistenceModule&, R)
//    {
//        return 0.0;
//    };

} // namespace md



#endif //MATCHING_DISTANCE_PERSISTENCE_MODULE_H