@@ -26,6 +26,7 @@ public:
2626
2727 // Flip method: need to be able to flip metric
2828 virtual bool flip_ccw (int _h, bool Ptolemy = true );
29+ void undo_flips ();
2930
3031 // Metric change methods: need to be able to clone metric and change metric coordinates
3132 virtual std::unique_ptr<DifferentiableConeMetric> clone_cone_metric () const = 0;
@@ -88,7 +89,40 @@ public:
8889
8990 bool flip_ccw (int _h, bool Ptolemy = true ) override ;
9091
91- private:
92+ MatrixX get_flip_jacobian () const
93+ {
94+ typedef Eigen::Triplet<Scalar> T;
95+ std::vector<T> tripletList;
96+ int num_edges = e2he.size ();
97+ tripletList.reserve (5 * num_edges);
98+ for (int i = 0 ; i < num_edges; ++i) {
99+ for (auto it : m_transition_jacobian_lol[i]) {
100+ tripletList.push_back (T (i, it.first , it.second ));
101+ }
102+ }
103+
104+ // Create the matrix from the triplets
105+ MatrixX transition_jacobian;
106+ transition_jacobian.resize (num_edges, num_edges);
107+ transition_jacobian.reserve (tripletList.size ());
108+ transition_jacobian.setFromTriplets (tripletList.begin (), tripletList.end ());
109+
110+ return transition_jacobian;
111+ }
112+
113+ // Reset Jacobian
114+ void reset ()
115+ {
116+ // Initialize jacobian to the identity
117+ int num_edges = e2he.size ();
118+ m_transition_jacobian_lol =
119+ std::vector<std::map<int , Scalar>>(num_edges, std::map<int , Scalar>());
120+ for (int e = 0 ; e < num_edges; ++e) {
121+ m_transition_jacobian_lol[e][e] = 1.0 ;
122+ }
123+ }
124+
125+ protected:
92126 std::vector<int > m_embed;
93127 std::vector<int > m_proj;
94128 MatrixX m_projection;
@@ -122,7 +156,7 @@ public:
122156
123157 bool flip_ccw (int _h, bool Ptolemy = true ) override ;
124158
125- private :
159+ protected :
126160 std::vector<int > m_embed;
127161 std::vector<int > m_proj;
128162 MatrixX m_projection;
0 commit comments