tatami_mult
Multiply tatami matrices
Loading...
Searching...
No Matches
sparse_row.hpp
Go to the documentation of this file.
1#ifndef TATAMI_MULT_SINGLE_VECTOR_SPARSE_ROW_HPP
2#define TATAMI_MULT_SINGLE_VECTOR_SPARSE_ROW_HPP
3
4#include <cstddef>
5#include <vector>
6
7#include "tatami/tatami.hpp"
8
9#include "../sparse_dot_product.hpp"
10
16namespace tatami_mult {
17
18/* See https://github.com/tatami-inc/test-multiplication/tree/master/sparse_row/single_vector
19 * for an explanation of the choice of algorithm.
20 */
21
32
49template<std::size_t accumulators_ = 4, typename LeftValue_, typename LeftIndex_, typename RightValue_, typename Output_>
52 const RightValue_* const right,
53 Output_* const output,
55) {
56 const auto NR = left.nrow();
57 const auto NC = left.ncol();
58 tatami::parallelize([&](int, LeftIndex_ start, LeftIndex_ length) -> void {
59 auto ext = tatami::consecutive_extractor<true>(left, true, start, length);
62 for (LeftIndex_ r = start, end = start + length; r < end; ++r) {
63 auto range = ext->fetch(vbuffer.data(), ibuffer.data());
64 output[r] = sparse_dot_product<accumulators_>(
65 range.number, // tatami guarantees that range.number will fit in a std::size_t, so no need to protect the function call.
66 range.value,
67 range.index,
68 right,
69 static_cast<Output_>(0)
70 );
71 }
72 }, NR, options.num_threads);
73}
74
75}
76
77#endif
virtual Index_ ncol() const=0
virtual Index_ nrow() const=0
Multiplication of tatami matrices.
Definition column_to_column.hpp:19
void multiply_sparse_row_with_single_vector(const tatami::Matrix< LeftValue_, LeftIndex_ > &left, const RightValue_ *const right, Output_ *const output, const MultiplySparseRowWithSingleVectorOptions &options)
Definition sparse_row.hpp:50
int parallelize(Function_ fun, const Index_ tasks, const int workers)
Container_ create_container_of_Index_size(const Index_ x, Args_ &&... args)
auto consecutive_extractor(const Matrix< Value_, Index_ > &matrix, const bool row, const Index_ iter_start, const Index_ iter_length, Args_ &&... args)
Options for multiply_sparse_row_with_single_vector().
Definition sparse_row.hpp:25