65 Index_ dim = (row ? p->
nrow() : p->
ncol());
66 Index_ otherdim = (row ? p->
ncol() : p->
nrow());
72 std::vector<Value_> xbuffer(otherdim);
73 std::vector<Index_> ibuffer(otherdim);
74 std::vector<Output_> tmp(num_groups);
76 for (Index_ i = 0; i < len; ++i) {
77 auto range = ext->fetch(xbuffer.data(), ibuffer.data());
78 std::fill(tmp.begin(), tmp.end(),
static_cast<Output_
>(0));
80 internal::nanable_ifelse<Value_>(
83 for (int j = 0; j < range.number; ++j) {
84 auto val = range.value[j];
85 if (!std::isnan(val)) {
86 tmp[group[range.index[j]]] += val;
91 for (
int j = 0; j < range.number; ++j) {
92 tmp[group[range.index[j]]] += range.value[j];
97 for (
size_t g = 0; g < num_groups; ++g) {
98 output[g][i + start] = tmp[g];
111 std::vector<sums::RunningSparse<Output_, Value_, Index_> > runners;
112 runners.reserve(num_groups);
113 std::vector<LocalOutputBuffer<Output_> > local_output;
114 local_output.reserve(num_groups);
116 for (
size_t g = 0; g < num_groups; ++g) {
117 local_output.emplace_back(thread, start, len, output[g]);
118 runners.emplace_back(local_output.back().data(), sopt.
skip_nan, start);
122 std::vector<Value_> xbuffer(len);
123 std::vector<Index_> ibuffer(len);
125 for (
int i = 0; i < otherdim; ++i) {
126 auto range = ext->fetch(xbuffer.data(), ibuffer.data());
127 runners[group[i]].add(range.value, range.index, range.number);
130 for (
size_t g = 0; g < num_groups; ++g) {
131 local_output[g].transfer();
137 if (p->prefer_rows() == row) {
140 std::vector<Value_> xbuffer(otherdim);
141 std::vector<Output_> tmp(num_groups);
143 for (Index_ i = 0; i < len; ++i) {
144 auto ptr = ext->fetch(xbuffer.data());
145 std::fill(tmp.begin(), tmp.end(),
static_cast<Output_
>(0));
147 internal::nanable_ifelse<Value_>(
150 for (Index_ j = 0; j < otherdim; ++j) {
152 if (!std::isnan(val)) {
153 tmp[group[j]] += val;
158 for (Index_ j = 0; j < otherdim; ++j) {
159 tmp[group[j]] += ptr[j];
164 for (
size_t g = 0; g < num_groups; ++g) {
165 output[g][i + start] = tmp[g];
168 }, dim, sopt.num_threads);
172 std::vector<sums::RunningDense<Output_, Value_, Index_> > runners;
173 runners.reserve(num_groups);
174 std::vector<LocalOutputBuffer<Output_> > local_output;
175 local_output.reserve(num_groups);
177 for (
size_t g = 0; g < num_groups; ++g) {
178 local_output.emplace_back(thread, start, len, output[g]);
179 runners.emplace_back(len, local_output.back().data(), sopt.skip_nan);
182 std::vector<Value_> xbuffer(len);
185 for (
int i = 0; i < otherdim; ++i) {
186 auto ptr = ext->fetch(xbuffer.data());
187 runners[group[i]].add(ptr);
190 for (
size_t g = 0; g < num_groups; ++g) {
191 local_output[g].transfer();
193 }, dim, sopt.num_threads);