+++ /dev/null
-/*------------------------------------------------------------------------
- Junction: Concurrent data structures in C++
- Copyright (c) 2016 Jeff Preshing
-
- Distributed under the Simplified BSD License.
- Original location: https://github.com/preshing/junction
-
- This software is distributed WITHOUT ANY WARRANTY; without even the
- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the LICENSE file for more information.
-------------------------------------------------------------------------*/
-
-#include <junction/Core.h>
-#include <junction/Averager.h>
-#include <math.h>
-
-namespace junction {
-
-double Averager::getStdDev() {
- finalize();
- double avg = getAverage();
- double dev = 0;
- for (ureg i = 0; i < m_values.size(); i++) {
- double diff = m_values[i] - avg;
- dev += diff * diff;
- }
- return sqrt(dev / m_values.size());
-}
-
-} // namespace junction
+++ /dev/null
-/*------------------------------------------------------------------------
- Junction: Concurrent data structures in C++
- Copyright (c) 2016 Jeff Preshing
-
- Distributed under the Simplified BSD License.
- Original location: https://github.com/preshing/junction
-
- This software is distributed WITHOUT ANY WARRANTY; without even the
- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the LICENSE file for more information.
-------------------------------------------------------------------------*/
-
-#ifndef JUNCTION_AVERAGER_H
-#define JUNCTION_AVERAGER_H
-
-#include <junction/Core.h>
-#include <vector>
-#include <algorithm>
-
-namespace junction {
-
-class Averager {
-private:
- std::vector<double> m_values;
- bool m_finalized;
-
-public:
- Averager() : m_finalized(false) {
- }
-
- void add(double value) {
- TURF_ASSERT(!m_finalized);
- m_values.push_back(value);
- }
-
- ureg getNumValues() const {
- return m_values.size();
- }
-
- void finalize(ureg bestValueCount = 0) {
- if (!m_finalized) {
- std::sort(m_values.begin(), m_values.end());
- if (bestValueCount)
- m_values.resize(bestValueCount);
- m_finalized = true;
- }
- }
-
- double getAverage() {
- finalize();
- double sum = 0;
- for (ureg i = 0; i < m_values.size(); i++) {
- sum += m_values[i];
- }
- return sum / m_values.size();
- }
-
- double getStdDev();
-};
-
-} // namespace junction
-
-#endif // JUNCTION_AVERAGER_H
#include <turf/Util.h>
#include <turf/extra/UniqueSequence.h>
#include <turf/extra/JobDispatcher.h>
-#include <junction/Averager.h>
#include <turf/extra/Options.h>
#include <junction/extra/MapAdapter.h>
+#include <algorithm>
+#include <vector>
using namespace turf::intTypes;
typedef junction::extra::MapAdapter MapAdapter;
#include <turf/Util.h>
#include <turf/extra/UniqueSequence.h>
#include <turf/extra/JobDispatcher.h>
-#include <junction/Averager.h>
#include <turf/extra/Options.h>
#include <junction/extra/MapAdapter.h>
+#include <algorithm>
+#include <vector>
using namespace turf::intTypes;
typedef junction::extra::MapAdapter MapAdapter;