-
-
493 return by_column<Output_>(p,
Options());
-
+
+
485template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
+
+
487 return by_column<Output_>(p,
Options());
+
-
-
509template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
-
511 std::vector<Output_> mins(p->
nrow()), maxs(p->
nrow());
-
512 apply(
true, p, mins.data(), maxs.data(), ropt);
-
513 return std::make_pair(std::move(mins), std::move(maxs));
-
+
+
503template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
+
+
505 std::vector<Output_> mins(p->
nrow()), maxs(p->
nrow());
+
506 apply(
true, p, mins.data(), maxs.data(), ropt);
+
507 return std::make_pair(std::move(mins), std::move(maxs));
+
-
-
528template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
-
530 return by_row<Output_>(p,
Options());
-
+
+
522template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
+
+
524 return by_row<Output_>(p,
Options());
+
-
-
-
-
-
-
+
+
+
+
+
+
virtual Index_ ncol() const=0
virtual Index_ nrow() const=0
virtual bool prefer_rows() const=0
virtual std::unique_ptr< MyopicSparseExtractor< Value_, Index_ > > sparse(bool row, const Options &opt) const=0
Local output buffer for running calculations.
Definition utils.hpp:72
-
Running minima/maxima from dense data.
Definition ranges.hpp:174
-
void finish()
Definition ranges.hpp:223
-
RunningDense(Index_ num, Output_ *store, bool skip_nan)
Definition ranges.hpp:182
-
void add(const Value_ *ptr)
Definition ranges.hpp:188
-
Running minima/maxima from sparse data.
Definition ranges.hpp:249
-
void finish()
Definition ranges.hpp:304
-
RunningSparse(Index_ num, Output_ *store, bool skip_nan, Index_ subtract=0)
Definition ranges.hpp:260
-
void add(const Value_ *value, const Index_ *index, Index_ number)
Definition ranges.hpp:269
-
std::pair< std::vector< Output_ >, std::vector< Output_ > > by_row(const tatami::Matrix< Value_, Index_ > *p, const Options &ropt)
Definition ranges.hpp:510
-
Value_ direct(const Value_ *ptr, Index_ num, bool skip_nan)
Definition ranges.hpp:98
-
std::pair< std::vector< Output_ >, std::vector< Output_ > > by_column(const tatami::Matrix< Value_, Index_ > *p, const Options &ropt)
Definition ranges.hpp:473
-
void apply(bool row, const tatami::Matrix< Value_, Index_ > *p, Output_ *min_out, Output_ *max_out, const Options &ropt)
Definition ranges.hpp:348
+
Running minima/maxima from dense data.
Definition ranges.hpp:173
+
void finish()
Definition ranges.hpp:220
+
RunningDense(Index_ num, Output_ *store, bool skip_nan)
Definition ranges.hpp:181
+
void add(const Value_ *ptr)
Definition ranges.hpp:187
+
Running minima/maxima from sparse data.
Definition ranges.hpp:246
+
void finish()
Definition ranges.hpp:299
+
RunningSparse(Index_ num, Output_ *store, bool skip_nan, Index_ subtract=0)
Definition ranges.hpp:257
+
void add(const Value_ *value, const Index_ *index, Index_ number)
Definition ranges.hpp:266
+
std::pair< std::vector< Output_ >, std::vector< Output_ > > by_row(const tatami::Matrix< Value_, Index_ > *p, const Options &ropt)
Definition ranges.hpp:504
+
Value_ direct(const Value_ *ptr, Index_ num, bool skip_nan)
Definition ranges.hpp:97
+
std::pair< std::vector< Output_ >, std::vector< Output_ > > by_column(const tatami::Matrix< Value_, Index_ > *p, const Options &ropt)
Definition ranges.hpp:467
+
void apply(bool row, const tatami::Matrix< Value_, Index_ > *p, Output_ *min_out, Output_ *max_out, const Options &ropt)
Definition ranges.hpp:342
Functions to compute statistics from a tatami::Matrix.
Definition counts.hpp:18
void parallelize(Function_ fun, Index_ tasks, int threads)
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
bool sparse_extract_index
bool sparse_ordered_index
-
Range calculation options.
Definition ranges.hpp:29
-
bool skip_nan
Definition ranges.hpp:34
-
int num_threads
Definition ranges.hpp:40
+
Range calculation options.
Definition ranges.hpp:28
+
bool skip_nan
Definition ranges.hpp:33
+
int num_threads
Definition ranges.hpp:39
Utilities for computing matrix statistics.
diff --git a/docs/search/all_0.js b/docs/search/all_0.js
index ebf9e6e..d9b547a 100644
--- a/docs/search/all_0.js
+++ b/docs/search/all_0.js
@@ -1,10 +1,10 @@
var searchData=
[
['add_0',['add',['../classtatami__stats_1_1ranges_1_1RunningDense.html#af6aa418d2d28dec63a58109c5d879aa0',1,'tatami_stats::ranges::RunningDense::add()'],['../classtatami__stats_1_1ranges_1_1RunningSparse.html#aab1432179521651b5e238b04f70ba522',1,'tatami_stats::ranges::RunningSparse::add()'],['../classtatami__stats_1_1sums_1_1RunningDense.html#a1171923aa2b5441d00fb495e8faa6c1e',1,'tatami_stats::sums::RunningDense::add()'],['../classtatami__stats_1_1sums_1_1RunningSparse.html#a2fede3f8461b31bc9f5da83571bfac39',1,'tatami_stats::sums::RunningSparse::add()'],['../classtatami__stats_1_1variances_1_1RunningDense.html#a13d93ffc98acfd3f7eb53265ef694c07',1,'tatami_stats::variances::RunningDense::add()'],['../classtatami__stats_1_1variances_1_1RunningSparse.html#ad998372f22ce80165cc39a8bfcb74108',1,'tatami_stats::variances::RunningSparse::add()']]],
- ['apply_1',['apply',['../namespacetatami__stats_1_1ranges.html#ae6a6bab18f4f4f19e5f11850ea6691c7',1,'tatami_stats::ranges::apply()'],['../namespacetatami__stats_1_1medians.html#ad8b353fbe53c1168d241ac90d392ab67',1,'tatami_stats::medians::apply()'],['../namespacetatami__stats_1_1grouped__variances.html#afb7e174ad083e8f081e53e5454f02a0b',1,'tatami_stats::grouped_variances::apply()'],['../namespacetatami__stats_1_1grouped__sums.html#a0dbe7d8241e5f3ea3c2403d85619aa01',1,'tatami_stats::grouped_sums::apply()'],['../namespacetatami__stats_1_1grouped__medians.html#abbea18f8a5b281048e3eaa11104652d8',1,'tatami_stats::grouped_medians::apply()'],['../namespacetatami__stats_1_1counts_1_1zero.html#ab7cd26f29bd8108071cdab2c083f04e7',1,'tatami_stats::counts::zero::apply()'],['../namespacetatami__stats_1_1counts_1_1nan.html#a0f4804cd4dcf6c4017166da931c95c6c',1,'tatami_stats::counts::nan::apply()'],['../namespacetatami__stats_1_1counts.html#aca723eda7d77e04d8b38f215fb1b8f95',1,'tatami_stats::counts::apply()'],['../namespacetatami__stats_1_1sums.html#ae21d4cc4dfbc7002e3dd57b1eb6047a6',1,'tatami_stats::sums::apply()'],['../namespacetatami__stats_1_1variances.html#aa569b5ff798e7b55ca6d930711ae6773',1,'tatami_stats::variances::apply()']]],
+ ['apply_1',['apply',['../namespacetatami__stats_1_1medians.html#ad8b353fbe53c1168d241ac90d392ab67',1,'tatami_stats::medians::apply()'],['../namespacetatami__stats_1_1grouped__variances.html#afb7e174ad083e8f081e53e5454f02a0b',1,'tatami_stats::grouped_variances::apply()'],['../namespacetatami__stats_1_1grouped__sums.html#a0dbe7d8241e5f3ea3c2403d85619aa01',1,'tatami_stats::grouped_sums::apply()'],['../namespacetatami__stats_1_1grouped__medians.html#abbea18f8a5b281048e3eaa11104652d8',1,'tatami_stats::grouped_medians::apply()'],['../namespacetatami__stats_1_1counts_1_1zero.html#ab7cd26f29bd8108071cdab2c083f04e7',1,'tatami_stats::counts::zero::apply()'],['../namespacetatami__stats_1_1counts_1_1nan.html#a0f4804cd4dcf6c4017166da931c95c6c',1,'tatami_stats::counts::nan::apply()'],['../namespacetatami__stats_1_1counts.html#aca723eda7d77e04d8b38f215fb1b8f95',1,'tatami_stats::counts::apply()'],['../namespacetatami__stats_1_1ranges.html#ae6a6bab18f4f4f19e5f11850ea6691c7',1,'tatami_stats::ranges::apply()'],['../namespacetatami__stats_1_1sums.html#ae21d4cc4dfbc7002e3dd57b1eb6047a6',1,'tatami_stats::sums::apply()'],['../namespacetatami__stats_1_1variances.html#aa569b5ff798e7b55ca6d930711ae6773',1,'tatami_stats::variances::apply()']]],
['arithmetic_5fhelpers_2ehpp_2',['arithmetic_helpers.hpp',['https://tatami-inc.github.io/tatami/unary_2arithmetic__helpers_8hpp.html',1,'(Global Namespace)'],['https://tatami-inc.github.io/tatami/binary_2arithmetic__helpers_8hpp.html',1,'(Global Namespace)']]],
['arithmetic_5futils_2ehpp_3',['arithmetic_utils.hpp',['https://tatami-inc.github.io/tatami/arithmetic__utils_8hpp.html',1,'']]],
['arithmeticoperation_4',['ArithmeticOperation',['https://tatami-inc.github.io/tatami/namespacetatami.html#a9050a4b119e027638175c38cc9bbede8',1,'tatami']]],
- ['arrayview_5',['arrayview',['https://tatami-inc.github.io/tatami/classtatami_1_1ArrayView.html#a98f383e531be5aac446242d62febf4e9',1,'tatami::ArrayView::ArrayView()'],['https://tatami-inc.github.io/tatami/classtatami_1_1ArrayView.html',1,'tatami::ArrayView< typename T >']]],
+ ['arrayview_5',['arrayview',['https://tatami-inc.github.io/tatami/classtatami_1_1ArrayView.html#a6cbe9b7d0ee871c17d051d0496278757',1,'tatami::ArrayView::ArrayView()'],['https://tatami-inc.github.io/tatami/classtatami_1_1ArrayView.html#a98f383e531be5aac446242d62febf4e9',1,'tatami::ArrayView::ArrayView(const T *ptr, size_t number)'],['https://tatami-inc.github.io/tatami/classtatami_1_1ArrayView.html',1,'tatami::ArrayView< typename T >']]],
['arrayview_2ehpp_6',['ArrayView.hpp',['https://tatami-inc.github.io/tatami/ArrayView_8hpp.html',1,'']]]
];
diff --git a/docs/search/functions_0.js b/docs/search/functions_0.js
index f1a342f..2a38874 100644
--- a/docs/search/functions_0.js
+++ b/docs/search/functions_0.js
@@ -2,5 +2,5 @@ var searchData=
[
['add_0',['add',['../classtatami__stats_1_1ranges_1_1RunningSparse.html#aab1432179521651b5e238b04f70ba522',1,'tatami_stats::ranges::RunningSparse::add()'],['../classtatami__stats_1_1sums_1_1RunningDense.html#a1171923aa2b5441d00fb495e8faa6c1e',1,'tatami_stats::sums::RunningDense::add()'],['../classtatami__stats_1_1sums_1_1RunningSparse.html#a2fede3f8461b31bc9f5da83571bfac39',1,'tatami_stats::sums::RunningSparse::add()'],['../classtatami__stats_1_1variances_1_1RunningDense.html#a13d93ffc98acfd3f7eb53265ef694c07',1,'tatami_stats::variances::RunningDense::add()'],['../classtatami__stats_1_1variances_1_1RunningSparse.html#ad998372f22ce80165cc39a8bfcb74108',1,'tatami_stats::variances::RunningSparse::add()'],['../classtatami__stats_1_1ranges_1_1RunningDense.html#af6aa418d2d28dec63a58109c5d879aa0',1,'tatami_stats::ranges::RunningDense::add()']]],
['apply_1',['apply',['../namespacetatami__stats_1_1variances.html#aa569b5ff798e7b55ca6d930711ae6773',1,'tatami_stats::variances::apply()'],['../namespacetatami__stats_1_1sums.html#ae21d4cc4dfbc7002e3dd57b1eb6047a6',1,'tatami_stats::sums::apply()'],['../namespacetatami__stats_1_1ranges.html#ae6a6bab18f4f4f19e5f11850ea6691c7',1,'tatami_stats::ranges::apply()'],['../namespacetatami__stats_1_1medians.html#ad8b353fbe53c1168d241ac90d392ab67',1,'tatami_stats::medians::apply()'],['../namespacetatami__stats_1_1grouped__variances.html#afb7e174ad083e8f081e53e5454f02a0b',1,'tatami_stats::grouped_variances::apply()'],['../namespacetatami__stats_1_1grouped__sums.html#a0dbe7d8241e5f3ea3c2403d85619aa01',1,'tatami_stats::grouped_sums::apply()'],['../namespacetatami__stats_1_1grouped__medians.html#abbea18f8a5b281048e3eaa11104652d8',1,'tatami_stats::grouped_medians::apply()'],['../namespacetatami__stats_1_1counts_1_1zero.html#ab7cd26f29bd8108071cdab2c083f04e7',1,'tatami_stats::counts::zero::apply()'],['../namespacetatami__stats_1_1counts_1_1nan.html#a0f4804cd4dcf6c4017166da931c95c6c',1,'tatami_stats::counts::nan::apply()'],['../namespacetatami__stats_1_1counts.html#aca723eda7d77e04d8b38f215fb1b8f95',1,'tatami_stats::counts::apply()']]],
- ['arrayview_2',['ArrayView',['https://tatami-inc.github.io/tatami/classtatami_1_1ArrayView.html#a98f383e531be5aac446242d62febf4e9',1,'tatami::ArrayView']]]
+ ['arrayview_2',['arrayview',['https://tatami-inc.github.io/tatami/classtatami_1_1ArrayView.html#a6cbe9b7d0ee871c17d051d0496278757',1,'tatami::ArrayView::ArrayView()'],['https://tatami-inc.github.io/tatami/classtatami_1_1ArrayView.html#a98f383e531be5aac446242d62febf4e9',1,'tatami::ArrayView::ArrayView(const T *ptr, size_t number)']]]
];
diff --git a/docs/sums_8hpp_source.html b/docs/sums_8hpp_source.html
index b195b31..536a836 100644
--- a/docs/sums_8hpp_source.html
+++ b/docs/sums_8hpp_source.html
@@ -94,234 +94,229 @@
2#define TATAMI_STATS__SUMS_HPP
-
5#include "subpar/subpar.hpp"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
57template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
58Output_
direct(
const Value_* ptr, Index_ num,
bool skip_nan) {
-
59 return internal::nanable_ifelse_with_value<Value_>(
-
-
-
-
63 for (Index_ i = 0; i < num; ++i) {
-
-
65 if (!std::isnan(val)) {
-
-
-
-
-
-
-
72 return std::accumulate(ptr, ptr + num,
static_cast<Output_
>(0));
-
-
-
+
+
56template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
+
57Output_
direct(
const Value_* ptr, Index_ num,
bool skip_nan) {
+
58 return internal::nanable_ifelse_with_value<Value_>(
+
+
+
+
62 for (Index_ i = 0; i < num; ++i) {
+
+
64 if (!std::isnan(val)) {
+
+
+
+
+
+
+
71 return std::accumulate(ptr, ptr + num,
static_cast<Output_
>(0));
+
+
+
-
-
93template<
typename Output_,
typename Value_,
typename Index_>
-
-
-
-
102 RunningDense(Index_ num, Output_* sum,
bool skip_nan) : my_num(num), my_sum(sum), my_skip_nan(skip_nan) {}
-
-
-
108 void add(
const Value_* ptr) {
-
109 internal::nanable_ifelse<Value_>(
-
-
-
-
113 for (Index_ i = 0; i < my_num; ++i) {
-
-
115 if (!std::isnan(val)) {
-
-
-
-
-
-
-
122 for (Index_ i = 0; i < my_num; ++i) {
-
-
-
-
-
+
+
92template<
typename Output_,
typename Value_,
typename Index_>
+
+
+
+
101 RunningDense(Index_ num, Output_* sum,
bool skip_nan) : my_num(num), my_sum(sum), my_skip_nan(skip_nan) {}
+
+
+
107 void add(
const Value_* ptr) {
+
108 internal::nanable_ifelse<Value_>(
+
+
+
111 for (Index_ i = 0; i < my_num; ++i) {
+
+
113 if (!std::isnan(val)) {
+
+
+
+
+
+
119 for (Index_ i = 0; i < my_num; ++i) {
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
145template<
typename Output_,
typename Value_,
typename Index_>
-
-
-
-
-
-
157 my_sum(sum), my_skip_nan(skip_nan), my_subtract(subtract) {}
+
+
142template<
typename Output_,
typename Value_,
typename Index_>
+
+
+
+
+
+
154 my_sum(sum), my_skip_nan(skip_nan), my_subtract(subtract) {}
-
-
-
166 void add(
const Value_* value,
const Index_* index, Index_ number) {
-
167 internal::nanable_ifelse<Value_>(
-
-
-
-
171 for (Index_ i = 0; i < number; ++i) {
-
-
173 if (!std::isnan(val)) {
-
174 my_sum[index[i] - my_subtract] += val;
-
-
-
-
-
-
180 for (Index_ i = 0; i < number; ++i) {
-
181 my_sum[index[i] - my_subtract] += value[i];
-
-
-
-
+
+
+
163 void add(
const Value_* value,
const Index_* index, Index_ number) {
+
164 internal::nanable_ifelse<Value_>(
+
+
+
167 for (Index_ i = 0; i < number; ++i) {
+
+
169 if (!std::isnan(val)) {
+
170 my_sum[index[i] - my_subtract] += val;
+
+
+
+
+
175 for (Index_ i = 0; i < number; ++i) {
+
176 my_sum[index[i] - my_subtract] += value[i];
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
211template<
typename Value_,
typename Index_,
typename Output_>
-
-
-
213 auto dim = (row ? p->
nrow() : p->
ncol());
-
214 auto otherdim = (row ? p->
ncol() : p->
nrow());
-
+
+
206template<
typename Value_,
typename Index_,
typename Output_>
+
+
+
208 auto dim = (row ? p->
nrow() : p->
ncol());
+
209 auto otherdim = (row ? p->
ncol() : p->
nrow());
+
+
+
+
+
+
-
-
-
-
-
-
-
-
224 std::vector<Value_> vbuffer(otherdim);
-
225 for (Index_ x = 0; x < l; ++x) {
-
226 auto out = ext->fetch(vbuffer.data(), NULL);
-
-
-
-
-
-
-
+
+
+
219 std::vector<Value_> vbuffer(otherdim);
+
220 for (Index_ x = 0; x < l; ++x) {
+
221 auto out = ext->fetch(vbuffer.data(), NULL);
+
+
+
+
+
+
+
+
+
+
+
232 std::vector<Value_> vbuffer(l);
+
233 std::vector<Index_> ibuffer(l);
-
-
-
237 std::vector<Value_> vbuffer(l);
-
238 std::vector<Index_> ibuffer(l);
-
-
-
+
+
+
+
238 for (Index_ x = 0; x < otherdim; ++x) {
+
239 auto out = ext->fetch(vbuffer.data(), ibuffer.data());
+
240 runner.
add(out.value, out.index, out.number);
+
-
243 for (Index_ x = 0; x < otherdim; ++x) {
-
244 auto out = ext->fetch(vbuffer.data(), ibuffer.data());
-
245 runner.
add(out.value, out.index, out.number);
-
-
-
-
-
-
-
-
-
-
-
256 std::vector<Value_> buffer(otherdim);
-
257 for (Index_ x = 0; x < l; ++x) {
-
258 auto out = ext->fetch(buffer.data());
-
-
-
+
+
+
+
+
+
+
+
+
251 std::vector<Value_> buffer(otherdim);
+
252 for (Index_ x = 0; x < l; ++x) {
+
253 auto out = ext->fetch(buffer.data());
+
+
+
+
+
+
+
+
261 std::vector<Value_> buffer(l);
-
-
-
-
266 std::vector<Value_> buffer(l);
-
-
-
+
+
+
+
266 for (Index_ x = 0; x < otherdim; ++x) {
+
267 auto out = ext->fetch(buffer.data());
+
+
-
271 for (Index_ x = 0; x < otherdim; ++x) {
-
272 auto out = ext->fetch(buffer.data());
-
-
+
+
+
+
-
-
-
-
-
-
-
+
+
-
-
295template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
-
297 std::vector<Output_> output(p->
ncol());
-
298 apply(
false, p, output.data(), sopt);
-
-
+
+
290template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
+
+
292 std::vector<Output_> output(p->
ncol());
+
293 apply(
false, p, output.data(), sopt);
+
+
-
-
312template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
-
-
+
+
307template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
-
-
328template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
-
330 std::vector<Output_> output(p->
nrow());
-
331 apply(
true, p, output.data(), sopt);
-
-
+
+
323template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
+
+
325 std::vector<Output_> output(p->
nrow());
+
326 apply(
true, p, output.data(), sopt);
+
+
-
-
345template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
-
-
+
+
340template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
-
-
-
-
-
-
+
+
+
+
+
+
virtual Index_ ncol() const=0
virtual Index_ nrow() const=0
@@ -330,25 +325,25 @@
Local output buffer for running calculations.
Definition utils.hpp:72
void transfer()
Definition utils.hpp:126
Output_ * data()
Definition utils.hpp:111
-
Running sums from dense data.
Definition sums.hpp:94
-
void add(const Value_ *ptr)
Definition sums.hpp:108
-
RunningDense(Index_ num, Output_ *sum, bool skip_nan)
Definition sums.hpp:102
-
Running sums from sparse data.
Definition sums.hpp:146
-
void add(const Value_ *value, const Index_ *index, Index_ number)
Definition sums.hpp:166
-
RunningSparse(Output_ *sum, bool skip_nan, Index_ subtract=0)
Definition sums.hpp:156
-
std::vector< Output_ > by_column(const tatami::Matrix< Value_, Index_ > *p, const Options &sopt)
Definition sums.hpp:296
-
void apply(bool row, const tatami::Matrix< Value_, Index_ > *p, Output_ *output, const Options &sopt)
Definition sums.hpp:212
-
std::vector< Output_ > by_row(const tatami::Matrix< Value_, Index_ > *p, const Options &sopt)
Definition sums.hpp:329
-
Output_ direct(const Value_ *ptr, Index_ num, bool skip_nan)
Definition sums.hpp:58
+
Running sums from dense data.
Definition sums.hpp:93
+
void add(const Value_ *ptr)
Definition sums.hpp:107
+
RunningDense(Index_ num, Output_ *sum, bool skip_nan)
Definition sums.hpp:101
+
Running sums from sparse data.
Definition sums.hpp:143
+
void add(const Value_ *value, const Index_ *index, Index_ number)
Definition sums.hpp:163
+
RunningSparse(Output_ *sum, bool skip_nan, Index_ subtract=0)
Definition sums.hpp:153
+
std::vector< Output_ > by_column(const tatami::Matrix< Value_, Index_ > *p, const Options &sopt)
Definition sums.hpp:291
+
void apply(bool row, const tatami::Matrix< Value_, Index_ > *p, Output_ *output, const Options &sopt)
Definition sums.hpp:207
+
std::vector< Output_ > by_row(const tatami::Matrix< Value_, Index_ > *p, const Options &sopt)
Definition sums.hpp:324
+
Output_ direct(const Value_ *ptr, Index_ num, bool skip_nan)
Definition sums.hpp:57
Functions to compute statistics from a tatami::Matrix.
Definition counts.hpp:18
void parallelize(Function_ fun, Index_ tasks, int threads)
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
bool sparse_extract_index
bool sparse_ordered_index
-
Summation options.
Definition sums.hpp:29
-
int num_threads
Definition sums.hpp:40
-
bool skip_nan
Definition sums.hpp:34
+
Summation options.
Definition sums.hpp:28
+
int num_threads
Definition sums.hpp:39
+
bool skip_nan
Definition sums.hpp:33
Utilities for computing matrix statistics.
diff --git a/docs/variances_8hpp_source.html b/docs/variances_8hpp_source.html
index 55832a4..46da228 100644
--- a/docs/variances_8hpp_source.html
+++ b/docs/variances_8hpp_source.html
@@ -94,403 +94,394 @@
2#define TATAMI_STATS_VARS_HPP
-
5#include "subpar/subpar.hpp"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
50template<
typename Output_ =
double,
typename Value_,
typename Index_ >
-
51void add_welford(Output_& mean, Output_& sumsq, Value_ value, Index_ count) {
-
52 Output_ delta = value - mean;
-
53 mean += delta / count;
-
54 sumsq += delta * (value - mean);
-
-
-
57template<
typename Output_ =
double,
typename Index_ >
-
58void add_welford_zeros(Output_& mean, Output_& sumsq, Index_ num_nonzero, Index_ num_all) {
-
59 auto ratio =
static_cast<Output_
>(num_nonzero) /
static_cast<Output_
>(num_all);
-
60 sumsq += mean * mean * ratio * (num_all - num_nonzero);
-
-
-
-
-
65template<
typename Index_>
-
-
-
68 Index_& operator[](
size_t) {
return out; }
-
-
-
-
-
95template<
typename Output_ =
double,
typename Value_,
typename Index_ >
-
-
96std::pair<Output_, Output_>
direct(
const Value_* value, Index_ num_nonzero, Index_ num_all,
bool skip_nan) {
-
-
-
-
100 ::tatami_stats::internal::nanable_ifelse<Value_>(
-
-
-
-
104 for (Index_ i = 0; i < num_nonzero; ++i, ++copy) {
-
-
106 if (std::isnan(val)) {
-
-
-
-
-
-
-
-
-
115 for (Index_ i = 0; i < num_nonzero; ++i, ++copy) {
-
-
-
-
-
-
121 auto count = num_all - lost;
-
-
-
-
125 ::tatami_stats::internal::nanable_ifelse<Value_>(
-
-
-
128 for (Index_ i = 0; i < num_nonzero; ++i) {
-
-
130 if (!std::isnan(val)) {
-
131 auto delta =
static_cast<Output_
>(val) - mean;
-
132 var += delta * delta;
-
-
-
-
-
137 for (Index_ i = 0; i < num_nonzero; ++i) {
-
138 auto delta =
static_cast<Output_
>(value[i]) - mean;
-
139 var += delta * delta;
-
-
-
-
-
144 if (num_nonzero < num_all) {
-
145 var +=
static_cast<Output_
>(num_all - num_nonzero) * mean * mean;
-
-
-
-
149 return std::make_pair(std::numeric_limits<Output_>::quiet_NaN(), std::numeric_limits<Output_>::quiet_NaN());
-
150 }
else if (count == 1) {
-
151 return std::make_pair(mean, std::numeric_limits<Output_>::quiet_NaN());
-
-
153 return std::make_pair(mean, var / (count - 1));
-
-
+
+
+
+
49template<
typename Output_ =
double,
typename Value_,
typename Index_ >
+
50void add_welford(Output_& mean, Output_& sumsq, Value_ value, Index_ count) {
+
51 Output_ delta = value - mean;
+
52 mean += delta / count;
+
53 sumsq += delta * (value - mean);
+
+
+
56template<
typename Output_ =
double,
typename Index_ >
+
57void add_welford_zeros(Output_& mean, Output_& sumsq, Index_ num_nonzero, Index_ num_all) {
+
58 auto ratio =
static_cast<Output_
>(num_nonzero) /
static_cast<Output_
>(num_all);
+
59 sumsq += mean * mean * ratio * (num_all - num_nonzero);
+
+
+
+
+
64template<
typename Index_>
+
+
+
67 Index_& operator[](
size_t) {
return out; }
+
+
+
+
+
94template<
typename Output_ =
double,
typename Value_,
typename Index_ >
+
+
95std::pair<Output_, Output_>
direct(
const Value_* value, Index_ num_nonzero, Index_ num_all,
bool skip_nan) {
+
+
+
+
99 ::tatami_stats::internal::nanable_ifelse<Value_>(
+
+
+
+
103 for (Index_ i = 0; i < num_nonzero; ++i, ++copy) {
+
+
105 if (std::isnan(val)) {
+
+
+
+
+
+
+
+
+
114 for (Index_ i = 0; i < num_nonzero; ++i, ++copy) {
+
+
+
+
+
+
120 auto count = num_all - lost;
+
+
+
+
124 ::tatami_stats::internal::nanable_ifelse<Value_>(
+
+
+
127 for (Index_ i = 0; i < num_nonzero; ++i) {
+
+
129 if (!std::isnan(val)) {
+
130 auto delta =
static_cast<Output_
>(val) - mean;
+
131 var += delta * delta;
+
+
+
+
+
136 for (Index_ i = 0; i < num_nonzero; ++i) {
+
137 auto delta =
static_cast<Output_
>(value[i]) - mean;
+
138 var += delta * delta;
+
+
+
+
+
143 if (num_nonzero < num_all) {
+
144 var +=
static_cast<Output_
>(num_all - num_nonzero) * mean * mean;
+
+
+
+
148 return std::make_pair(std::numeric_limits<Output_>::quiet_NaN(), std::numeric_limits<Output_>::quiet_NaN());
+
149 }
else if (count == 1) {
+
150 return std::make_pair(mean, std::numeric_limits<Output_>::quiet_NaN());
+
+
152 return std::make_pair(mean, var / (count - 1));
+
+
-
-
173template<
typename Output_ =
double,
typename Value_,
typename Index_ >
-
-
174std::pair<Output_, Output_>
direct(
const Value_* ptr, Index_ num,
bool skip_nan) {
-
175 return direct<Output_>(ptr, num, num, skip_nan);
-
+
+
172template<
typename Output_ =
double,
typename Value_,
typename Index_ >
+
+
173std::pair<Output_, Output_>
direct(
const Value_* ptr, Index_ num,
bool skip_nan) {
+
174 return direct<Output_>(ptr, num, num, skip_nan);
+
-
-
192template<
typename Output_,
typename Value_,
typename Index_>
-
-
-
-
-
203 RunningDense(Index_ num, Output_* mean, Output_* variance,
bool skip_nan) :
-
204 my_num(num), my_mean(mean), my_variance(variance), my_skip_nan(skip_nan), my_ok_count(skip_nan ? num : 0) {}
+
+
191template<
typename Output_,
typename Value_,
typename Index_>
+
+
+
+
+
202 RunningDense(Index_ num, Output_* mean, Output_* variance,
bool skip_nan) :
+
203 my_num(num), my_mean(mean), my_variance(variance), my_skip_nan(skip_nan), my_ok_count(skip_nan ? num : 0) {}
-
-
-
210 void add(
const Value_* ptr) {
-
211 ::tatami_stats::internal::nanable_ifelse<Value_>(
-
-
-
-
215 for (Index_ i = 0; i < my_num; ++i, ++ptr) {
-
-
217 if (!std::isnan(val)) {
-
218 internal::add_welford(my_mean[i], my_variance[i], val, ++(my_ok_count[i]));
-
-
-
-
-
-
-
225 for (Index_ i = 0; i < my_num; ++i, ++ptr) {
-
226 internal::add_welford(my_mean[i], my_variance[i], *ptr, my_count);
-
-
-
-
+
+
+
209 void add(
const Value_* ptr) {
+
210 ::tatami_stats::internal::nanable_ifelse<Value_>(
+
+
+
213 for (Index_ i = 0; i < my_num; ++i, ++ptr) {
+
+
215 if (!std::isnan(val)) {
+
216 internal::add_welford(my_mean[i], my_variance[i], val, ++(my_ok_count[i]));
+
+
+
+
+
+
222 for (Index_ i = 0; i < my_num; ++i, ++ptr) {
+
223 internal::add_welford(my_mean[i], my_variance[i], *ptr, my_count);
+
+
+
+
-
-
-
-
236 ::tatami_stats::internal::nanable_ifelse<Value_>(
-
-
-
-
240 for (Index_ i = 0; i < my_num; ++i) {
-
241 auto ct = my_ok_count[i];
-
-
243 my_variance[i] = std::numeric_limits<Output_>::quiet_NaN();
-
-
245 my_mean[i] = std::numeric_limits<Output_>::quiet_NaN();
-
-
-
248 my_variance[i] /= ct - 1;
-
-
-
-
-
-
254 std::fill_n(my_variance, my_num, std::numeric_limits<Output_>::quiet_NaN());
-
-
256 std::fill_n(my_mean, my_num, std::numeric_limits<Output_>::quiet_NaN());
+
+
+
+
233 ::tatami_stats::internal::nanable_ifelse<Value_>(
+
+
+
236 for (Index_ i = 0; i < my_num; ++i) {
+
237 auto ct = my_ok_count[i];
+
+
239 my_variance[i] = std::numeric_limits<Output_>::quiet_NaN();
+
+
241 my_mean[i] = std::numeric_limits<Output_>::quiet_NaN();
+
+
+
244 my_variance[i] /= ct - 1;
+
+
+
+
+
+
250 std::fill_n(my_variance, my_num, std::numeric_limits<Output_>::quiet_NaN());
+
+
252 std::fill_n(my_mean, my_num, std::numeric_limits<Output_>::quiet_NaN());
+
+
+
255 for (Index_ i = 0; i < my_num; ++i) {
+
256 my_variance[i] /= my_count - 1;
-
-
-
260 for (Index_ i = 0; i < my_num; ++i) {
-
261 my_variance[i] /= my_count - 1;
-
-
-
-
-
+
+
+
+
-
-
-
-
-
271 Output_* my_variance;
-
-
-
274 typename std::conditional<std::numeric_limits<Value_>::has_quiet_NaN, std::vector<Index_>, internal::MockVector<Index_> >::type my_ok_count;
-
+
+
+
+
+
266 Output_* my_variance;
+
+
+
269 typename std::conditional<std::numeric_limits<Value_>::has_quiet_NaN, std::vector<Index_>, internal::MockVector<Index_> >::type my_ok_count;
+
-
-
287template<
typename Output_,
typename Value_,
typename Index_>
-
-
-
-
-
301 RunningSparse(Index_ num, Output_* mean, Output_* variance,
bool skip_nan, Index_ subtract = 0) :
-
302 my_num(num), my_mean(mean), my_variance(variance), my_nonzero(num), my_skip_nan(skip_nan), my_subtract(subtract), my_nan(skip_nan ? num : 0) {}
+
+
282template<
typename Output_,
typename Value_,
typename Index_>
+
+
+
+
+
296 RunningSparse(Index_ num, Output_* mean, Output_* variance,
bool skip_nan, Index_ subtract = 0) :
+
297 my_num(num), my_mean(mean), my_variance(variance), my_nonzero(num), my_skip_nan(skip_nan), my_subtract(subtract), my_nan(skip_nan ? num : 0) {}
-
-
-
310 void add(
const Value_* value,
const Index_* index, Index_ number) {
-
-
-
313 ::tatami_stats::internal::nanable_ifelse<Value_>(
-
-
-
-
317 for (Index_ i = 0; i < number; ++i) {
-
-
319 auto ri = index[i] - my_subtract;
-
320 if (std::isnan(val)) {
-
-
-
323 internal::add_welford(my_mean[ri], my_variance[ri], val, ++(my_nonzero[ri]));
-
+
+
+
305 void add(
const Value_* value,
const Index_* index, Index_ number) {
+
+
+
308 ::tatami_stats::internal::nanable_ifelse<Value_>(
+
+
+
311 for (Index_ i = 0; i < number; ++i) {
+
+
313 auto ri = index[i] - my_subtract;
+
314 if (std::isnan(val)) {
+
+
+
317 internal::add_welford(my_mean[ri], my_variance[ri], val, ++(my_nonzero[ri]));
+
+
+
+
+
322 for (Index_ i = 0; i < number; ++i) {
+
323 auto ri = index[i] - my_subtract;
+
324 internal::add_welford(my_mean[ri], my_variance[ri], value[i], ++(my_nonzero[ri]));
-
-
-
-
329 for (Index_ i = 0; i < number; ++i) {
-
330 auto ri = index[i] - my_subtract;
-
331 internal::add_welford(my_mean[ri], my_variance[ri], value[i], ++(my_nonzero[ri]));
-
-
-
-
+
+
+
-
-
-
-
341 ::tatami_stats::internal::nanable_ifelse<Value_>(
-
-
-
-
345 for (Index_ i = 0; i < my_num; ++i) {
-
346 auto& curM = my_mean[i];
-
347 auto& curV = my_variance[i];
-
348 Index_ ct = my_count - my_nan[i];
-
-
-
351 curV = std::numeric_limits<Output_>::quiet_NaN();
-
-
353 curM = std::numeric_limits<Output_>::quiet_NaN();
-
-
-
356 internal::add_welford_zeros(curM, curV, my_nonzero[i], ct);
-
+
+
+
+
334 ::tatami_stats::internal::nanable_ifelse<Value_>(
+
+
+
337 for (Index_ i = 0; i < my_num; ++i) {
+
338 auto& curM = my_mean[i];
+
339 auto& curV = my_variance[i];
+
340 Index_ ct = my_count - my_nan[i];
+
+
+
343 curV = std::numeric_limits<Output_>::quiet_NaN();
+
+
345 curM = std::numeric_limits<Output_>::quiet_NaN();
+
+
+
348 internal::add_welford_zeros(curM, curV, my_nonzero[i], ct);
+
+
+
+
+
+
+
355 std::fill_n(my_variance, my_num, std::numeric_limits<Output_>::quiet_NaN());
+
+
357 std::fill_n(my_mean, my_num, std::numeric_limits<Output_>::quiet_NaN());
-
-
-
-
-
363 std::fill_n(my_variance, my_num, std::numeric_limits<Output_>::quiet_NaN());
-
-
365 std::fill_n(my_mean, my_num, std::numeric_limits<Output_>::quiet_NaN());
-
-
-
-
369 for (Index_ i = 0; i < my_num; ++i) {
-
370 auto& var = my_variance[i];
-
371 internal::add_welford_zeros(my_mean[i], var, my_nonzero[i], my_count);
-
-
-
-
-
-
+
+
360 for (Index_ i = 0; i < my_num; ++i) {
+
361 auto& var = my_variance[i];
+
362 internal::add_welford_zeros(my_mean[i], var, my_nonzero[i], my_count);
+
+
+
+
+
+
-
-
-
-
-
382 Output_* my_variance;
-
383 std::vector<Index_> my_nonzero;
-
-
-
-
387 typename std::conditional<std::numeric_limits<Value_>::has_quiet_NaN, std::vector<Index_>, internal::MockVector<Index_> >::type my_nan;
-
+
+
+
+
+
373 Output_* my_variance;
+
374 std::vector<Index_> my_nonzero;
+
+
+
+
378 typename std::conditional<std::numeric_limits<Value_>::has_quiet_NaN, std::vector<Index_>, internal::MockVector<Index_> >::type my_nan;
+
-
-
406template<
typename Value_,
typename Index_,
typename Output_>
-
-
-
408 auto dim = (row ? p->
nrow() : p->
ncol());
-
409 auto otherdim = (row ? p->
ncol() : p->
nrow());
-
-
-
-
-
-
-
-
-
418 std::vector<Value_> vbuffer(otherdim);
-
419 for (Index_ x = 0; x < l; ++x) {
-
420 auto out = ext->fetch(vbuffer.data(), NULL);
-
421 output[x + s] = variances::direct<Output_>(out.value, out.number, otherdim, vopt.
skip_nan).second;
-
-
-
-
-
-
-
428 std::vector<Value_> vbuffer(l);
-
429 std::vector<Index_> ibuffer(l);
-
-
431 std::vector<Output_> running_means(l);
-
-
-
-
435 for (Index_ x = 0; x < otherdim; ++x) {
-
436 auto out = ext->fetch(vbuffer.data(), ibuffer.data());
-
437 runner.
add(out.value, out.index, out.number);
-
-
-
-
-
-
-
-
-
-
-
-
449 std::vector<Value_> buffer(otherdim);
-
450 for (Index_ x = 0; x < l; ++x) {
-
451 auto out = ext->fetch(buffer.data());
-
452 output[x + s] = variances::direct<Output_>(out, otherdim, vopt.
skip_nan).second;
-
-
+
+
397template<
typename Value_,
typename Index_,
typename Output_>
+
+
+
399 auto dim = (row ? p->
nrow() : p->
ncol());
+
400 auto otherdim = (row ? p->
ncol() : p->
nrow());
+
+
+
+
+
+
+
+
+
409 std::vector<Value_> vbuffer(otherdim);
+
410 for (Index_ x = 0; x < l; ++x) {
+
411 auto out = ext->fetch(vbuffer.data(), NULL);
+
412 output[x + s] = variances::direct<Output_>(out.value, out.number, otherdim, vopt.
skip_nan).second;
+
+
+
+
+
+
+
419 std::vector<Value_> vbuffer(l);
+
420 std::vector<Index_> ibuffer(l);
+
+
422 std::vector<Output_> running_means(l);
+
+
+
+
426 for (Index_ x = 0; x < otherdim; ++x) {
+
427 auto out = ext->fetch(vbuffer.data(), ibuffer.data());
+
428 runner.
add(out.value, out.index, out.number);
+
+
+
+
+
+
+
+
+
+
+
+
440 std::vector<Value_> buffer(otherdim);
+
441 for (Index_ x = 0; x < l; ++x) {
+
442 auto out = ext->fetch(buffer.data());
+
443 output[x + s] = variances::direct<Output_>(out, otherdim, vopt.
skip_nan).second;
+
+
+
+
+
+
+
450 std::vector<Value_> buffer(l);
+
+
452 std::vector<Output_> running_means(l);
+
+
-
-
-
-
459 std::vector<Value_> buffer(l);
+
456 for (Index_ x = 0; x < otherdim; ++x) {
+
457 runner.
add(ext->fetch(buffer.data()));
+
+
-
461 std::vector<Output_> running_means(l);
-
-
-
-
465 for (Index_ x = 0; x < otherdim; ++x) {
-
466 runner.
add(ext->fetch(buffer.data()));
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
488template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
-
490 std::vector<Output_> output(p->
ncol());
-
491 apply(
false, p, output.data(), vopt);
-
-
+
+
479template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
+
+
481 std::vector<Output_> output(p->
ncol());
+
482 apply(
false, p, output.data(), vopt);
+
+
-
-
506template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
-
-
-
+
+
497template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
-
-
524template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
-
526 std::vector<Output_> output(p->
nrow());
-
527 apply(
true, p, output.data(), vopt);
-
-
+
+
515template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
+
+
517 std::vector<Output_> output(p->
nrow());
+
518 apply(
true, p, output.data(), vopt);
+
+
-
-
542template<
typename Output_ =
double,
typename Value_,
typename Index_>
-
-
-
-
-
+
+
533template<
typename Output_ =
double,
typename Value_,
typename Index_>
+
-
-
-
-
-
-
+
+
+
+
+
+
virtual Index_ ncol() const=0
virtual Index_ nrow() const=0
@@ -499,26 +490,26 @@
Local output buffer for running calculations.
Definition utils.hpp:72
void transfer()
Definition utils.hpp:126
Output_ * data()
Definition utils.hpp:111
-
Running variances from dense data.
Definition variances.hpp:193
-
void add(const Value_ *ptr)
Definition variances.hpp:210
-
void finish()
Definition variances.hpp:235
-
RunningDense(Index_ num, Output_ *mean, Output_ *variance, bool skip_nan)
Definition variances.hpp:203
-
Running variances from sparse data.
Definition variances.hpp:288
-
void finish()
Definition variances.hpp:340
-
RunningSparse(Index_ num, Output_ *mean, Output_ *variance, bool skip_nan, Index_ subtract=0)
Definition variances.hpp:301
-
void add(const Value_ *value, const Index_ *index, Index_ number)
Definition variances.hpp:310
-
std::vector< Output_ > by_row(const tatami::Matrix< Value_, Index_ > *p, const Options &vopt)
Definition variances.hpp:525
-
std::pair< Output_, Output_ > direct(const Value_ *value, Index_ num_nonzero, Index_ num_all, bool skip_nan)
Definition variances.hpp:96
-
void apply(bool row, const tatami::Matrix< Value_, Index_ > *p, Output_ *output, const Options &vopt)
Definition variances.hpp:407
-
std::vector< Output_ > by_column(const tatami::Matrix< Value_, Index_ > *p, const Options &vopt)
Definition variances.hpp:489
+
Running variances from dense data.
Definition variances.hpp:192
+
void add(const Value_ *ptr)
Definition variances.hpp:209
+
void finish()
Definition variances.hpp:232
+
RunningDense(Index_ num, Output_ *mean, Output_ *variance, bool skip_nan)
Definition variances.hpp:202
+
Running variances from sparse data.
Definition variances.hpp:283
+
void finish()
Definition variances.hpp:333
+
RunningSparse(Index_ num, Output_ *mean, Output_ *variance, bool skip_nan, Index_ subtract=0)
Definition variances.hpp:296
+
void add(const Value_ *value, const Index_ *index, Index_ number)
Definition variances.hpp:305
+
std::vector< Output_ > by_row(const tatami::Matrix< Value_, Index_ > *p, const Options &vopt)
Definition variances.hpp:516
+
std::pair< Output_, Output_ > direct(const Value_ *value, Index_ num_nonzero, Index_ num_all, bool skip_nan)
Definition variances.hpp:95
+
void apply(bool row, const tatami::Matrix< Value_, Index_ > *p, Output_ *output, const Options &vopt)
Definition variances.hpp:398
+
std::vector< Output_ > by_column(const tatami::Matrix< Value_, Index_ > *p, const Options &vopt)
Definition variances.hpp:480
Functions to compute statistics from a tatami::Matrix.
Definition counts.hpp:18
void parallelize(Function_ fun, Index_ tasks, int threads)
auto consecutive_extractor(const Matrix< Value_, Index_ > *mat, bool row, Index_ iter_start, Index_ iter_length, Args_ &&... args)
bool sparse_extract_index
-
Variance calculation options.
Definition variances.hpp:31
-
int num_threads
Definition variances.hpp:42
-
bool skip_nan
Definition variances.hpp:36
+
Variance calculation options.
Definition variances.hpp:30
+
int num_threads
Definition variances.hpp:41
+
bool skip_nan
Definition variances.hpp:35
Utilities for computing matrix statistics.