19 #include "libmesh/coupling_matrix.h"
24 CouplingMatrix & CouplingMatrix::operator&= (
const CouplingMatrix & other)
26 const std::size_t max_size = std::numeric_limits<std::size_t>::max();
28 rc_type::iterator start_range = this->_ranges.begin();
30 rc_type::const_iterator other_range = other._ranges.begin();
31 const rc_type::const_iterator other_end = other._ranges.end();
33 for (; other_range != other_end; ++other_range)
35 std::size_t other_range_start = other_range->first;
36 std::size_t other_range_end = other_range->second;
44 rc_type::iterator lb =
45 std::upper_bound (start_range, this->_ranges.end(),
46 std::make_pair(other_range_start, max_size));
50 lb=this->_ranges.end();
57 if (lb == this->_ranges.end())
62 const std::size_t lastloc = lb->second;
63 libmesh_assert_less_equal(lb->first, lastloc);
64 libmesh_assert_less_equal(lb->first, other_range_start);
68 CouplingMatrix::rc_type::const_iterator next = lb;
70 if (next != this->_ranges.end())
73 libmesh_assert_greater(next->first, lastloc+1);
78 CouplingMatrix::rc_type::iterator next = lb;
83 if (other_range_start <= lastloc)
84 lb->second = other_range_end;
89 start_range = lb = this->_ranges.emplace
90 (next, other_range_start, other_range_end);
98 for (
const std::size_t nextloc =
99 (next == this->_ranges.end()) ?
100 std::numeric_limits<std::size_t>::max() : next->first;
101 nextloc <= lb->second; ++next)
105 libmesh_assert_greater(nextloc, lastloc+1);
107 lb->second = std::max(lb->second, next->second);
110 CouplingMatrix::rc_type::iterator oldnext = lb;
114 this->_ranges.erase(oldnext, next);
119 for (; other_range != other_end; ++other_range)
120 this->_ranges.push_back(*other_range);