Skip to content

File su2doubletdagger.h

File List > algebra > su2algebra > su2doubletdagger.h

Go to the documentation of this file

#ifndef TEMPLAT_LATTICE_ALGEBRA_SU2ALGEBRA_SU2DOUBLETDAGGER_H
#define TEMPLAT_LATTICE_ALGEBRA_SU2ALGEBRA_SU2DOUBLETDAGGER_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, Franz R. Sattler, Year: 2025

#include "TempLat/lattice/algebra/su2algebra/helpers/hassu2doubletget.h"
#include "TempLat/util/rangeiteration/tagliteral.h"
#include "TempLat/lattice/algebra/su2algebra/su2doubletunaryoperator.h"
#include "TempLat/lattice/algebra/su2algebra/helpers/su2doubletgetgetreturntype.h"
#include "TempLat/lattice/algebra/helpers/doeval.h"

#include "TempLat/parallel/device.h"

namespace TempLat
{
  template <typename R> class SU2DoubletDagger : public SU2DoubletUnaryOperator<R>
  {
  public:
    using SV = SU2DoubletGetGetReturnType<R>::type;
    using SU2DoubletUnaryOperator<R>::mR;

    /* Put public methods here. These should change very little over time. */
    SU2DoubletDagger(const R &pR) : SU2DoubletUnaryOperator<R>(pR) {}

    template <int M> auto SU2DoubletGet(Tag<M> t) const
    {
      static_assert(M >= 0 && M <= 3, "SU2DoubletGet: M must be between 0 and 3 for SU2DoubletDagger");
      if constexpr (M % 2 == 0)
        return mR.SU2DoubletGet(t);
      else
        return -mR.SU2DoubletGet(t);
    }

    template <int N> const auto &operator()(Tag<N> t) const { return SU2DoubletGet(t); }

    template <typename... IDX>
      requires requires(std::decay_t<R> r, IDX... idx) {
        requires IsVariadicIndex<IDX...>;
        DoEval::eval(r, idx...);
      }
    DEVICE_INLINE_FUNCTION auto eval(const IDX &...idx) const
    {
      auto child = DoEval::eval(mR, idx...);
      // child[0] = child[0];
      child[1] = -child[1];
      // child[2] = child[2];
      child[3] = -child[3];
      return child;
    }

    virtual std::string toString() const override { return GetString::get(mR) + "^\u2020"; }
  };

  template <class R>
    requires HasSU2DoubletGet<R>
  auto dagger(const R &r)
  {
    return SU2DoubletDagger<R>(r);
  };
} // namespace TempLat

#endif