45 auto dim = (row ? p->
nrow() : p->
ncol());
46 auto otherdim = (row ? p->
ncol() : p->
nrow());
47 std::fill(output, output + dim, 0);
53 bool count_zero = condition(0);
56 std::vector<Value_> xbuffer(otherdim);
57 std::vector<Index_> ibuffer(otherdim);
60 for (Index_ x = 0; x < len; ++x) {
61 auto range = ext->fetch(xbuffer.data(), ibuffer.data());
63 for (Index_ j = 0; j < range.number; ++j) {
64 target += condition(range.value[j]);
67 target += otherdim - range.number;
69 output[x + start] = target;
75 std::vector<Value_> xbuffer(otherdim);
78 for (Index_ x = 0; x < len; ++x) {
79 auto ptr = ext->fetch(xbuffer.data());
81 for (Index_ j = 0; j < otherdim; ++j) {
82 target += condition(ptr[j]);
84 output[x + start] = target;
90 num_threads = subpar::sanitize_num_workers(num_threads, otherdim);
91 std::vector<Output_*> threaded_output_ptrs(num_threads, output);
92 std::vector<std::vector<Output_> > threaded_output;
93 if (num_threads > 1) {
94 threaded_output.resize(num_threads - 1);
95 for (
int t = 1; t < num_threads; ++t) {
96 auto& curout = threaded_output[t - 1];
98 threaded_output_ptrs[t] = curout.data();
105 bool count_zero = condition(0);
108 std::vector<Value_> xbuffer(dim);
109 std::vector<Index_> ibuffer(dim);
112 auto curoutput = threaded_output_ptrs[thread];
113 std::vector<Index_> nonzeros(dim);
115 for (Index_ x = 0; x < len; ++x) {
116 auto range = ext->fetch(xbuffer.data(), ibuffer.data());
117 for (Index_ j = 0; j < range.number; ++j) {
118 auto idx = range.index[j];
119 curoutput[idx] += condition(range.value[j]);
125 for (
int d = 0; d < dim; ++d) {
126 curoutput[d] += len - nonzeros[d];
129 }, otherdim, num_threads);
133 std::vector<Value_> xbuffer(dim);
135 auto curoutput = threaded_output_ptrs[thread];
137 for (Index_ x = 0; x < len; ++x) {
138 auto ptr = ext->fetch(xbuffer.data());
139 for (Index_ j = 0; j < dim; ++j) {
140 curoutput[j] += condition(ptr[j]);
143 }, otherdim, num_threads);
146 for (
int t = 1; t < num_threads; ++t) {
147 auto curoutput = threaded_output_ptrs[t];
148 for (Index_ d = 0; d < dim; ++d) {
149 output[d] += curoutput[d];