Skip to content

File accumulatortype.h

File List > code_source > templat > include > TempLat > lattice > measuringtools > accumulatortype.h

Go to the documentation of this file

#ifndef TEMPLAT_LATTICE_MEASUREMENTS_ACCUMULATORTYPE_H
#define TEMPLAT_LATTICE_MEASUREMENTS_ACCUMULATORTYPE_H

/* This file is part of TempLat, available at https://cosmolattice.github.io/templat .
   Copyright 2021-2026 The TempLat authors, see AUTHORS.md.
   Released under the MIT license, see LICENSE.md. */

// File info: Main contributor(s): Franz R. Sattler, Year: 2026

#include <type_traits>

#include "TempLat/parallel/device.h"

namespace TempLat
{
  namespace Helpers
  {
    template <typename T> struct AccumulatorTypeHelper {
      using type = std::conditional_t<std::is_integral_v<T> || std::is_floating_point_v<T>, double, T>;
    };

    template <typename T> struct AccumulatorTypeHelper<complex<T>> {
      using type = complex<double>;
    };
  } // namespace Helpers

  template <typename T> using AccumulatorType = typename Helpers::AccumulatorTypeHelper<T>::type;
} // namespace TempLat

#endif