54 const RightColumns_ right_columns,
55 GetRightRow_ get_right_row,
56 Output_*
const output,
59 const auto left_NR = left.
nrow();
60 const auto common_dim = left.
ncol();
64 std::fill_n(output, sanisizer::product<std::size_t>(left_NR, right_columns), 0);
67 std::optional<std::vector<std::optional<std::vector<Output_> > > > tmp_results;
69 tmp_results.emplace(sanisizer::cast<I<
decltype(tmp_results->size())> >(options.
num_threads - 1));
72 const auto num_used =
tatami::parallelize([&](
int t, LeftIndex_ start, LeftIndex_ length) ->
void {
77 std::optional<std::vector<Output_> > tmp_output;
79 if (!do_parallel || t == 0) {
82 tmp_output.emplace(sanisizer::product<I<
decltype(tmp_output->size())> >(left_NR, right_columns));
83 outptr = tmp_output->data();
86 for (LeftIndex_ cd = 0; cd < length; ++cd) {
87 const auto lrange = left_ext->fetch(vbuffer.data(), ibuffer.data());
88 const auto rptr = get_right_row(start + cd);
89 for (LeftIndex_ x = 0; x < lrange.number; ++x) {
90 const Output_ mult = lrange.value[x];
91 const auto curout = outptr + sanisizer::product_unsafe<std::size_t>(lrange.index[x], right_columns);
92 for (RightColumns_ rc = 0; rc < right_columns; ++rc) {
93 curout[rc] += mult *
static_cast<Output_
>(rptr[rc]);
98 if (do_parallel && t > 0) {
99 (*tmp_results)[t - 1] = std::move(tmp_output);
104 for (
int u = 1; u < num_used; ++u) {
105 const auto& tmp = *((*tmp_results)[u - 1]);
106 const auto N = tmp.size();
107 for (I<
decltype(N)> x = 0; x < N; ++x) {
137 Output_*
const output,
140 const auto left_NR = left.
nrow();
141 const auto common_dim = left.
ncol();
142 const auto right_NC = right.
ncol();
145 std::optional<std::vector<std::optional<std::vector<Output_> > > > tmp_results;
147 tmp_results.emplace(sanisizer::cast<I<
decltype(tmp_results->size())> >(options.
num_threads - 1));
150 std::fill_n(output, sanisizer::product<std::size_t>(left_NR, right_NC), 0);
152 const auto num_used =
tatami::parallelize([&](
int t, LeftIndex_ start, LeftIndex_ length) ->
void {
160 std::optional<std::vector<Output_> > tmp_output;
162 if (!do_parallel || t == 0) {
165 tmp_output.emplace(sanisizer::product<I<
decltype(tmp_output->size())> >(left_NR, right_NC));
166 outptr = tmp_output->data();
169 for (LeftIndex_ cd = 0; cd < length; ++cd) {
170 const auto lrange = left_ext->fetch(vbuffer.data(), ibuffer.data());
171 const auto rptr = right_ext->fetch(rbuffer.data());
172 for (LeftIndex_ x = 0; x < lrange.number; ++x) {
173 const Output_ mult = lrange.value[x];
174 const auto curout = outptr + sanisizer::product_unsafe<std::size_t>(lrange.index[x], right_NC);
175 for (RightIndex_ rc = 0; rc < right_NC; ++rc) {
176 curout[rc] += mult *
static_cast<Output_
>(rptr[rc]);
181 if (do_parallel && t > 0) {
182 (*tmp_results)[t - 1] = std::move(tmp_output);
187 for (
int u = 1; u < num_used; ++u) {
188 const auto& tmp = *((*tmp_results)[u - 1]);
189 const auto N = tmp.size();
190 for (I<
decltype(N)> x = 0; x < N; ++x) {
void multiply_sparse_column_with_dense_row_matrix_to_row_output(const tatami::Matrix< LeftValue_, LeftIndex_ > &left, const RightColumns_ right_columns, GetRightRow_ get_right_row, Output_ *const output, const MultiplySparseColumnWithDenseRowMatrixToRowOutputOptions &options)
Definition row_to_row.hpp:52
auto consecutive_extractor(const Matrix< Value_, Index_ > &matrix, const bool row, const Index_ iter_start, const Index_ iter_length, Args_ &&... args)