46 const Index_ dim = (row ? mat.
nrow() : mat.
ncol());
47 const Index_ otherdim = (row ? mat.
ncol() : mat.
nrow());
48 std::fill(output, output + dim, 0);
54 bool count_zero = condition(0);
61 for (Index_ x = 0; x < len; ++x) {
62 auto range = ext->fetch(xbuffer.data(), ibuffer.data());
64 for (Index_ j = 0; j < range.number; ++j) {
65 target += condition(range.value[j]);
68 target += otherdim - range.number;
70 output[x + start] = target;
79 for (Index_ x = 0; x < len; ++x) {
80 auto ptr = ext->fetch(xbuffer.data());
82 for (Index_ j = 0; j < otherdim; ++j) {
83 target += condition(ptr[j]);
85 output[x + start] = target;
91 auto threaded_output = sanisizer::create<std::vector<std::vector<Output_> > >(num_threads > 0 ? num_threads - 1 : 0);
96 bool count_zero = condition(0);
103 auto curoutput = output;
105 auto& outvec = threaded_output[thread - 1];
107 curoutput = outvec.data();
111 for (Index_ x = 0; x < len; ++x) {
112 auto range = ext->fetch(xbuffer.data(), ibuffer.data());
113 for (Index_ j = 0; j < range.number; ++j) {
114 auto idx = range.index[j];
115 curoutput[idx] += condition(range.value[j]);
121 for (Index_ d = 0; d < dim; ++d) {
122 curoutput[d] += len - nonzeros[d];
125 }, otherdim, num_threads);
132 auto curoutput = output;
134 auto& outvec = threaded_output[thread - 1];
136 curoutput = outvec.data();
139 for (Index_ x = 0; x < len; ++x) {
140 auto ptr = ext->fetch(xbuffer.data());
141 for (Index_ j = 0; j < dim; ++j) {
142 curoutput[j] += condition(ptr[j]);
145 }, otherdim, num_threads);
148 for (
const auto& curout : threaded_output) {
149 if (!curout.empty()) {
150 for (Index_ d = 0; d < dim; ++d) {
151 output[d] += curout[d];
164 apply(row, *p, output, num_threads, std::move(condition));