File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -440,8 +440,7 @@ DomOrdPWMap DomOrdPWMap::inverse() const
440440 DomOrdPWMap result;
441441
442442 for (const MapEntry& entry : _pieces) {
443- Map m = entry.map ();
444- result.emplace (Map{m.image (), m.law ().inverse ()});
443+ result.emplace (entry.map ().inverse ());
445444 }
446445
447446 return result;
Original file line number Diff line number Diff line change @@ -128,6 +128,15 @@ Set Map::preImage(const Set& subcodom) const
128128 .intersection (_domain);
129129}
130130
131+ Map Map::inverse () const
132+ {
133+ if (_domain.cardinal () == 1 ) {
134+ return Map{image (), _domain.minElem ()};
135+ }
136+
137+ return Map{image (), _law.inverse ()};
138+ }
139+
131140Map Map::composition (const Map& other) const
132141{
133142 Set result_domain = _domain.intersection (other.image ());
Original file line number Diff line number Diff line change @@ -113,7 +113,13 @@ class Map {
113113 * @param subcodom Set of elements in the image of the map for which the
114114 * pre image will be calculated.
115115 */
116- Set preImage (const Set& subcodom) const ; // opt
116+ Set preImage (const Set& subcodom) const ;
117+
118+ /* *
119+ * @brief Calculates the inverse of a map.
120+ * Precondition: map should be bijective.
121+ */
122+ Map inverse () const ;
117123
118124 /* *
119125 * @brief Calculate the composition of \p this with \p other, i.e.
Original file line number Diff line number Diff line change @@ -416,8 +416,7 @@ OrdPWMap OrdPWMap::inverse() const
416416 OrdPWMap result;
417417
418418 for (const MapEntry& entry : _pieces) {
419- Map m = entry.map ();
420- result.emplace (Map{m.image (), m.law ().inverse ()});
419+ result.emplace (entry.map ().inverse ());
421420 }
422421
423422 return result;
Original file line number Diff line number Diff line change @@ -248,7 +248,7 @@ UnordPWMap UnordPWMap::inverse() const
248248 UnordPWMap result;
249249
250250 for (const Map& m : _pieces) {
251- result.emplaceBack (m. image (), m. law () .inverse ());
251+ result.pushBack (m .inverse ());
252252 }
253253
254254 return result;
You can’t perform that action at this time.
0 commit comments