46 InputIndex_ NR = matrix.
nrow();
47 InputIndex_ NC = matrix.
ncol();
49 size_t primary = (pref_rows ? NR : NC);
50 size_t secondary = (pref_rows ? NC : NR);
52 if (row_major == pref_rows) {
53 constexpr bool same_type = std::is_same<InputValue_, StoredValue_>::value;
54 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
55 std::vector<InputValue_> temp(same_type ? 0 : secondary);
58 for (InputIndex_ x = 0; x < length; ++x) {
59 auto store_copy = store +
static_cast<size_t>(start + x) * secondary;
60 if constexpr(same_type) {
61 auto ptr = wrk->fetch(store_copy);
62 copy_n(ptr, secondary, store_copy);
64 auto ptr = wrk->fetch(temp.data());
65 std::copy_n(ptr, secondary, store_copy);
71 std::fill_n(store, primary * secondary, 0);
78 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
80 std::vector<InputValue_> vtemp(length);
81 std::vector<InputIndex_> itemp(length);
86 for (
size_t x = 0; x < primary; ++x) {
87 auto range = wrk->fetch(vtemp.data(), itemp.data());
88 for (InputIndex_ i = 0; i < range.number; ++i) {
89 store[
static_cast<size_t>(range.index[i]) * primary + x] = range.value[i];
98 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
100 const size_t length_as_size_t = length;
101 const size_t start_as_size_t = start;
107 constexpr size_t block_size = 16;
108 const size_t alloc = std::min(primary, block_size);
109 std::vector<InputValue_> bigbuffer(length_as_size_t * alloc);
110 std::vector<const InputValue_*> ptrs(alloc);
111 std::vector<InputValue_*> buf_ptrs;
112 buf_ptrs.reserve(alloc);
113 auto first = bigbuffer.data();
114 for (
size_t i = 0; i < alloc; ++i, first += length_as_size_t) {
115 buf_ptrs.push_back(first);
119 while (prim_i < primary) {
120 size_t prim_to_process = std::min(primary - prim_i, block_size);
121 for (
size_t c = 0; c < prim_to_process; ++c) {
122 ptrs[c] = wrk->fetch(buf_ptrs[c]);
126 while (sec_i < length_as_size_t) {
127 size_t sec_end = sec_i + std::min(block_size, length_as_size_t - sec_i);
128 for (
size_t c = 0; c < prim_to_process; ++c) {
129 auto input = ptrs[c];
130 size_t offset = start_as_size_t * primary + (c + prim_i);
131 for (
size_t r = sec_i; r < sec_end; ++r) {
132 store[r * primary + offset] = input[r];
138 prim_i += prim_to_process;
void convert_to_dense(const Matrix< InputValue_, InputIndex_ > &matrix, bool row_major, StoredValue_ *store, const ConvertToDenseOptions &options)
Definition convert_to_dense.hpp:45
auto consecutive_extractor(const Matrix< Value_, Index_ > &matrix, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35