48 InputIndex_ NR = matrix.
nrow();
49 InputIndex_ NC = matrix.
ncol();
51 auto primary = (pref_rows ? NR : NC);
52 auto secondary = (pref_rows ? NC : NR);
57 if (row_major == pref_rows) {
58 constexpr bool same_type = std::is_same<InputValue_, StoredValue_>::value;
59 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
62 if constexpr(same_type) {
69 for (
decltype(length) x = 0; x < length; ++x) {
70 auto store_copy = store + sanisizer::product_unsafe<std::size_t>(secondary, start + x);
71 if constexpr(same_type) {
72 auto ptr = wrk->fetch(store_copy);
73 copy_n(ptr, secondary, store_copy);
75 auto ptr = wrk->fetch(temp.data());
76 std::copy_n(ptr, secondary, store_copy);
82 std::fill_n(store, sanisizer::product_unsafe<std::size_t>(primary, secondary), 0);
89 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
97 for (
decltype(primary) x = 0; x < primary; ++x) {
98 auto range = wrk->fetch(vtemp.data(), itemp.data());
99 for (InputIndex_ i = 0; i < range.number; ++i) {
100 store[sanisizer::nd_offset<std::size_t>(x, primary, range.index[i])] = range.value[i];
109 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
116 constexpr InputIndex_ block_size = 16;
117 InputIndex_ alloc = std::min(primary, block_size);
118 std::vector<InputValue_> bigbuffer(sanisizer::product_unsafe<
typename std::vector<InputValue_>::size_type>(length, alloc));
119 std::vector<const InputValue_*> ptrs(alloc);
120 std::vector<InputValue_*> buf_ptrs(alloc);
121 for (
decltype(alloc) i = 0; i < alloc; ++i) {
122 buf_ptrs[i] = bigbuffer.data() + sanisizer::product_unsafe<std::size_t>(length, i);
125 InputIndex_ prim_i = 0;
126 while (prim_i < primary) {
127 InputIndex_ prim_to_process = std::min(
static_cast<InputIndex_
>(primary - prim_i), block_size);
128 for (
decltype(prim_to_process) c = 0; c < prim_to_process; ++c) {
129 ptrs[c] = wrk->fetch(buf_ptrs[c]);
132 InputIndex_ sec_i = 0;
133 while (sec_i < length) {
134 InputIndex_ sec_end = sec_i + std::min(
static_cast<InputIndex_
>(length - sec_i), block_size);
135 for (
decltype(prim_to_process) c = 0; c < prim_to_process; ++c) {
136 auto input = ptrs[c];
137 for (InputIndex_ r = sec_i; r < sec_end; ++r) {
138 store[sanisizer::nd_offset<std::size_t>(c + prim_i, primary, r + start)] = input[r];
144 prim_i += prim_to_process;
174 auto NR = matrix.
nrow();
175 auto NC = matrix.
ncol();
176 auto buffer_size = sanisizer::product<std::size_t>(NR, NC);
177 auto buffer = sanisizer::create<std::vector<StoredValue_> >(buffer_size);
void convert_to_dense(const Matrix< InputValue_, InputIndex_ > &matrix, bool row_major, StoredValue_ *store, const ConvertToDenseOptions &options)
Definition convert_to_dense.hpp:47
auto consecutive_extractor(const Matrix< Value_, Index_ > &matrix, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35