7#include <dr/detail/matrix_entry.hpp>
16template <
typename T,
typename I,
typename Allocator = std::allocator<T>>
19 using value_type = std::pair<T, I>;
20 using scalar_type = T;
22 using size_type = std::size_t;
23 using difference_type = std::ptrdiff_t;
25 using allocator_type = Allocator;
30 using backend_allocator_type =
typename std::allocator_traits<
31 allocator_type>::template rebind_alloc<value_type>;
32 using aggregator_allocator_type =
typename std::allocator_traits<
33 allocator_type>::template rebind_alloc<std::vector<value_type>>;
34 using row_type = std::vector<value_type, backend_allocator_type>;
35 using backend_type = std::vector<row_type, aggregator_allocator_type>;
37 using iterator =
typename backend_type::iterator;
38 using const_iterator =
typename backend_type::const_iterator;
41 auto average_size = nnz / shape.first / 2;
42 for (std::size_t i = 0; i < shape.first; i++) {
43 tuples_.push_back(row_type());
44 tuples_.back().reserve(average_size);
50 size_type size()
const noexcept {
return size_; }
52 iterator begin()
noexcept {
return tuples_.begin(); }
54 const_iterator begin()
const noexcept {
return tuples_.begin(); }
56 iterator end()
noexcept {
return tuples_.end(); }
58 const_iterator end()
const noexcept {
return tuples_.end(); }
60 template <
typename InputIt>
void push_back(InputIt first, InputIt last) {
61 for (
auto iter = first; iter != last; ++iter) {
66 void push_back(index_type row,
const value_type &value) {
67 tuples_[row].push_back(value);
72 auto comparator = [](
auto &one,
auto &two) {
73 return one.second < two.second;
75 for (
auto &elem : tuples_) {
76 std::sort(elem.begin(), elem.end(), comparator);
88 std::size_t size_ = 0;
Definition: csr_matrix_base.hpp:17