1#ifndef TATAMI_CONVERT_TO_DENSE_H
2#define TATAMI_CONVERT_TO_DENSE_H
7#include "../utils/consecutive_extractor.hpp"
8#include "../utils/parallelize.hpp"
9#include "../utils/copy.hpp"
34template <
typename StoredValue_,
typename InputValue_,
typename InputIndex_>
36 InputIndex_ NR = matrix->
nrow();
37 InputIndex_ NC = matrix->
ncol();
39 size_t primary = (pref_rows ? NR : NC);
40 size_t secondary = (pref_rows ? NC : NR);
42 if (row_major == pref_rows) {
43 constexpr bool same_type = std::is_same<InputValue_, StoredValue_>::value;
44 parallelize([&](
int, InputIndex_ start, InputIndex_ length) ->
void {
45 std::vector<InputValue_> temp(same_type ? 0 : secondary);
60 }
else if (
matrix->is_sparse()) {
61 std::fill_n(
store, primary * secondary, 0);
76 for (
size_t x = 0;
x < primary; ++
x) {
100 std::vector<const InputValue_*>
ptrs(
alloc);
109 while (
prim_i < primary) {
160 std::vector<StoredValue_>
buffer(
static_cast<size_t>(
NR) *
static_cast<size_t>(
NC));
169template<
bool row_,
typename StoredValue_,
typename InputValue_,
typename InputIndex_>
174template<
bool row_,
typename Value_,
typename Index_,
typename StoredValue_ = Value_,
typename InputValue_,
typename InputIndex_>
Dense matrix representation.
Virtual class for a matrix.
Definition Matrix.hpp:59
virtual Index_ ncol() const =0
virtual Index_ nrow() const =0
virtual bool prefer_rows() const =0
Flexible representations for matrix data.
Definition Extractor.hpp:15
void parallelize(Function_ fun, Index_ tasks, int threads)
Definition parallelize.hpp:42
void convert_to_dense(const Matrix< InputValue_, InputIndex_ > *matrix, bool row_major, StoredValue_ *store, int threads=1)
Definition convert_to_dense.hpp:35
Value_ * copy_n(const Value_ *input, Size_ n, Value_ *output)
Definition copy.hpp:25
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
Definition consecutive_extractor.hpp:35