From 1edc9c867116d9e4700ccb5360eda13b61151253 Mon Sep 17 00:00:00 2001 From: Daniel Seemaier Date: Mon, 11 Sep 2023 15:49:17 +0200 Subject: [PATCH] Update include guards in tools, remove unused files --- kagen/tools/benchmark.h | 62 -------------------------------- kagen/tools/converter.h | 2 ++ kagen/tools/mersenne.h | 9 ++--- kagen/tools/newton.h | 2 ++ kagen/tools/random_permutation.h | 2 -- kagen/tools/sorted_mersenne.h | 7 ++-- 6 files changed, 9 insertions(+), 75 deletions(-) delete mode 100644 kagen/tools/benchmark.h diff --git a/kagen/tools/benchmark.h b/kagen/tools/benchmark.h deleted file mode 100644 index 5c667a7..0000000 --- a/kagen/tools/benchmark.h +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * include/tools/benchmark.h - * - * Copyright (C) 2016-2017 Sebastian Lamm - * - * All rights reserved. Published under the BSD-2 license in the LICENSE file. - ******************************************************************************/ - -#ifndef _BENCHMARK_H_ -#define _BENCHMARK_H_ - -#include -#include - -namespace kagen { - -// template-based loop unrolling -template -struct FauxUnroll { - template - static void call(F&& f) { - FauxUnroll::call(f); - f(N - 1); - } -}; - -template <> -struct FauxUnroll<0> { - template - static void call(F&&) {} -}; - -struct Statistics { - // Single-pass standard deviation calculation as described in Donald Knuth: - // The Art of Computer Programming, Volume 2, Chapter 4.2.2, Equations 15&16 - double mean_; - double nvar_; // approx n * variance; stddev = sqrt(nvar_ / (count_-1)) - size_t count_; - - Statistics() : mean_(0.0), nvar_(0.0), count_(0) {} - - void Push(double t) { - ++count_; - if (count_ == 1) { - mean_ = t; - } else { - double oldmean = mean_; - mean_ += (t - oldmean) / count_; - nvar_ += (t - oldmean) * (t - mean_); - } - } - - double Avg() const { - return mean_; - } - double Stddev() const { - return count_ > 1 ? sqrt(nvar_ / (count_ - 1)) : 0; - } -}; - -} // namespace kagen -#endif diff --git a/kagen/tools/converter.h b/kagen/tools/converter.h index e36e3e5..f50284e 100644 --- a/kagen/tools/converter.h +++ b/kagen/tools/converter.h @@ -1,3 +1,5 @@ +#pragma once + #include "kagen/definitions.h" #include diff --git a/kagen/tools/mersenne.h b/kagen/tools/mersenne.h index c30a720..3ee7bd3 100644 --- a/kagen/tools/mersenne.h +++ b/kagen/tools/mersenne.h @@ -5,18 +5,17 @@ * * All rights reserved. Published under the BSD-2 license in the LICENSE file. ******************************************************************************/ +#pragma once -#ifndef _MERSENNE_H_ -#define _MERSENNE_H_ +#include "kagen/definitions.h" #include namespace kagen { - class Mersenne { public: Mersenne() : Mersenne(0) {} - Mersenne(SInt seed) : gen_(seed), dis_(0.0, 1.0) {} + Mersenne(const SInt seed) : gen_(seed), dis_(0.0, 1.0) {} void RandomInit(SInt seed) { gen_.seed(seed); @@ -48,6 +47,4 @@ class Mersenne { std::mt19937_64 gen_; std::uniform_real_distribution dis_; }; - } // namespace kagen -#endif diff --git a/kagen/tools/newton.h b/kagen/tools/newton.h index 00ab9b1..e1c5663 100644 --- a/kagen/tools/newton.h +++ b/kagen/tools/newton.h @@ -1,3 +1,5 @@ +#pragma once + #include namespace kagen { diff --git a/kagen/tools/random_permutation.h b/kagen/tools/random_permutation.h index 7ae9115..ac21c0e 100644 --- a/kagen/tools/random_permutation.h +++ b/kagen/tools/random_permutation.h @@ -5,7 +5,6 @@ * * All rights reserved. Published under the BSD-2 license in the LICENSE file. ******************************************************************************/ - #pragma once #include @@ -17,7 +16,6 @@ #include "xxhash.h" namespace kagen::random_permutation { - // Some bit twiddling helper functions. template constexpr uint8_t num_bits() { diff --git a/kagen/tools/sorted_mersenne.h b/kagen/tools/sorted_mersenne.h index bfa8632..4f69010 100644 --- a/kagen/tools/sorted_mersenne.h +++ b/kagen/tools/sorted_mersenne.h @@ -5,14 +5,13 @@ * * All rights reserved. Published under the BSD-2 license in the LICENSE file. ******************************************************************************/ +#pragma once -#ifndef _SORTED_MERSENNE_H_ -#define _SORTED_MERSENNE_H_ +#include "kagen/definitions.h" #include namespace kagen { - class SortedMersenne { public: SortedMersenne() : SortedMersenne(0) {} @@ -56,6 +55,4 @@ class SortedMersenne { SInt num_samples_; double ln_cur_max_; }; - } // namespace kagen -#endif