67 InputIndex_ NR = matrix->
nrow();
68 InputIndex_ NC = matrix->
ncol();
69 InputIndex_ primary = (row ? NR : NC);
70 InputIndex_ secondary = (row ? NC : NR);
73 auto& store_v = output.
value;
74 auto& store_i = output.
index;
78 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
79 std::vector<InputValue_> buffer_v(secondary);
80 std::vector<InputIndex_> buffer_i(secondary);
83 for (InputIndex_ p = start, pe = start + length; p < pe; ++p) {
84 auto range = wrk->fetch(buffer_v.data(), buffer_i.data());
85 auto& sv = store_v[p];
86 auto& si = store_i[p];
87 sv.reserve(range.number);
88 si.reserve(range.number);
90 for (InputIndex_ i = 0; i < range.number; ++i, ++range.value, ++range.index) {
92 sv.push_back(*range.value);
93 si.push_back(*range.index);
100 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
101 std::vector<InputValue_> buffer_v(secondary);
106 for (InputIndex_ p = start, pe = start + length; p < pe; ++p) {
107 auto ptr = wrk->fetch(buffer_v.data());
108 auto& sv = store_v[p];
109 auto& si = store_i[p];
111 for (InputIndex_ s = 0; s < secondary; ++s, ++ptr) {
118 }, primary, threads);
128 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
129 std::vector<InputValue_> buffer_v(primary);
130 std::vector<InputIndex_> buffer_i(primary);
133 for (InputIndex_ x = 0; x < secondary; ++x) {
134 auto range = wrk->fetch(buffer_v.data(), buffer_i.data());
135 for (InputIndex_ i = 0; i < range.number; ++i, ++range.value, ++range.index) {
137 store_v[*range.index].push_back(*range.value);
138 store_i[*range.index].push_back(x);
142 }, primary, threads);
145 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
147 std::vector<InputValue_> buffer_v(length);
149 for (InputIndex_ x = 0; x < secondary; ++x) {
150 auto ptr = wrk->fetch(buffer_v.data());
151 for (InputIndex_ p = start, pe = start + length; p < pe; ++p, ++ptr) {
153 store_v[p].push_back(*ptr);
154 store_i[p].push_back(x);
158 }, primary, threads);
std::shared_ptr< Matrix< Value_, Index_ > > convert_to_fragmented_sparse(const Matrix< InputValue_, InputIndex_ > *matrix, bool row, int threads=1)
Definition convert_to_fragmented_sparse.hpp:181
FragmentedSparseContents< StoredValue_, StoredIndex_ > retrieve_fragmented_sparse_contents(const Matrix< InputValue_, InputIndex_ > *matrix, bool row, int threads=1)
Definition convert_to_fragmented_sparse.hpp:66
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35
Fragmented sparse contents.
Definition convert_to_fragmented_sparse.hpp:30
std::vector< std::vector< Value_ > > value
Definition convert_to_fragmented_sparse.hpp:43
std::vector< std::vector< Index_ > > index
Definition convert_to_fragmented_sparse.hpp:50