18 struct findstack : std::stack<real_t *, std::vector<real_t *>> {
21 auto begin() {
return this->
c.begin(); }
22 auto begin()
const {
return this->
c.begin(); }
23 auto end() {
return this->
c.end(); }
24 auto end()
const {
return this->
c.end(); }
26 auto cbegin()
const {
return this->
c.cbegin(); }
27 auto cend()
const {
return this->
c.cend(); }
29 auto rbegin() {
return this->
c.rbegin(); }
30 auto rbegin()
const {
return this->
c.rbegin(); }
31 auto rend() {
return this->
c.rend(); }
32 auto rend()
const {
return this->
c.rend(); }
34 auto crbegin()
const {
return this->
c.crbegin(); }
35 auto crend()
const {
return this->
c.crend(); }
52 using mvec = Eigen::Map<vec>;
66 :
v{std::exchange(o.
v, {
nullptr, 0})},
67 alloc{std::exchange(o.alloc,
nullptr)} {}
70 this->
v = std::exchange(o.v, {nullptr, 0});
71 this->
alloc = std::exchange(o.alloc,
nullptr);
85 throw std::bad_alloc();
86 auto dptr = stack.top();
88 highwatermark = std::max(used_space(), highwatermark);
89 return Eigen::Map<vec>(dptr,
n);
96 assert(dptr >= &*storage.begin());
97 assert(dptr <= &*storage.end() -
n);
98 assert(std::find(stack.begin(), stack.end(), dptr) == stack.end() &&
103 template <
class... Vecs>
109 size_t size()
const {
return stack.size(); }
alloc_raii_wrapper alloc_raii()
Eigen::Index vector_size() const
alpaqa::vec_allocator::findstack stack
vec_allocator(const vec_allocator &)=delete
vec_allocator(size_t num_vec, Eigen::Index n)
vec_allocator & operator=(vec_allocator &&)=delete
void free(rvec first, Vecs &&...vecs)
vec_allocator(vec_allocator &&)=delete
vec_allocator & operator=(const vec_allocator &)=delete
std::vector< real_t > storage
size_t used_space() const
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
constexpr real_t NaN
Not a number.
double real_t
Default floating point type.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
alloc_raii_wrapper(alloc_raii_wrapper &&o)
alloc_raii_wrapper & operator=(crvec v)
alloc_raii_wrapper(real_t *dptr, Eigen::Index n, vec_allocator *alloc)
alloc_raii_wrapper(mvec &&v, vec_allocator *alloc)
alloc_raii_wrapper & operator=(const alloc_raii_wrapper &)=delete
alloc_raii_wrapper & operator=(alloc_raii_wrapper &&o)
alloc_raii_wrapper(const alloc_raii_wrapper &)=delete