Krita Source Code Documentation
Loading...
Searching...
No Matches
KisRollingMeanAccumulatorWrapper.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <boost/accumulators/accumulators.hpp>
10#include <boost/accumulators/statistics/stats.hpp>
11#include <boost/accumulators/statistics/rolling_mean.hpp>
12
13using namespace boost::accumulators;
14
16 Private(int windowSize)
17 : accumulator(tag::rolling_window::window_size = windowSize)
18 {
19 }
20
21 accumulator_set<qreal, stats<tag::lazy_rolling_mean> > accumulator;
22};
23
24
26 : m_d(new Private(windowSize))
27{
28}
29
33
35{
36 m_d->accumulator(value);
37}
38
40{
41 return boost::accumulators::rolling_mean(m_d->accumulator);
42}
43
45{
46 return boost::accumulators::rolling_count(m_d->accumulator) > 0 ?
47 boost::accumulators::rolling_mean(m_d->accumulator) : 0;
48}
49
51{
52 return boost::accumulators::rolling_count(m_d->accumulator);
53}
54
56{
57 m_d->accumulator =
58 accumulator_set<qreal, stats<tag::lazy_rolling_mean>>(
59 tag::rolling_window::window_size = windowSize);
60}
float value(const T *src, size_t ch)
accumulator_set< qreal, stats< tag::lazy_rolling_mean > > accumulator