Skip to content

Commit

Permalink
Replace boost:circular_buffer with amgcl::circular_buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ddemidov committed Jun 5, 2018
1 parent 1c07404 commit 0a76821
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
6 changes: 2 additions & 4 deletions amgcl/solver/lgmres.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ THE SOFTWARE.
#include <cmath>
#include <tuple>

#include <boost/circular_buffer.hpp>

#include <amgcl/backend/interface.hpp>
#include <amgcl/solver/detail/default_inner_product.hpp>
#include <amgcl/solver/detail/givens_rotations.hpp>
Expand Down Expand Up @@ -413,8 +411,8 @@ class lgmres {
std::shared_ptr<vector> r;
mutable std::vector< std::shared_ptr<vector> > vs, ws;
mutable std::vector< std::shared_ptr<vector> > outer_v_data, outer_Av_data;
mutable boost::circular_buffer< std::shared_ptr<vector> > outer_v;
mutable boost::circular_buffer< std::shared_ptr<vector> > outer_Av;
mutable circular_buffer< std::shared_ptr<vector> > outer_v;
mutable circular_buffer< std::shared_ptr<vector> > outer_Av;


InnerProduct inner_product;
Expand Down
38 changes: 38 additions & 0 deletions amgcl/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,44 @@ class multi_array {
}
};

template <class T>
class circular_buffer {
public:
circular_buffer(size_t n) : start(0) {
buf.reserve(n);
}

size_t size() const {
return buf.size();
}

void push_back(const T &v) {
if (buf.size() < buf.capacity()) {
buf.push_back(v);
} else {
buf[start] = v;
start = (start + 1) % buf.capacity();
}
}

const T& operator[](size_t i) const {
return buf[(start + i) % buf.capacity()];
}

T& operator[](size_t i) {
return buf[(start + i) % buf.capacity()];
}

void clear() {
buf.clear();
start = 0;
}

private:
size_t start;
std::vector<T> buf;
};

namespace detail {

inline const boost::property_tree::ptree& empty_ptree() {
Expand Down

0 comments on commit 0a76821

Please sign in to comment.