Skip to content

File imag.h

File List > algebra > complexalgebra > imag.h

Go to the documentation of this file

#ifndef COSMOINTERFACE_COMPLEXFIELDALGEBRA_HELPERS_IMAG_H
#define COSMOINTERFACE_COMPLEXFIELDALGEBRA_HELPERS_IMAG_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): Adrien Florio, Year: 2019

#include "TempLat/lattice/algebra/complexalgebra/helpers/hascomplexfieldget.h"
#include "TempLat/lattice/algebra/complexalgebra/ascomplexfield.h"
#include "TempLat/lattice/algebra/helpers/iscomplextype.h"

namespace TempLat
{
  template <class T>
    requires HasComplexFieldGet<T>
  auto Imag(T &&t)
  {
    return t.ComplexFieldGet(Tag<1>());
  }

  template <class T>
    requires IsComplexType<T>
  auto Imag(T &&t)
  {
    return t.imag();
  }

  template <class T>
    requires HasComplexEval<std::decay_t<T>>
  auto Imag(T &&t)
  {
    return asComplexField(std::forward<T>(t)).ComplexFieldGet(1_c);
  }
} // namespace TempLat

#endif