File su2sum.h
File List > algebra > su2algebra > su2sum.h
Go to the documentation of this file
#ifndef COSMOINTERFACE_SU2ALGEBRA_SU2SUM_H
#define COSMOINTERFACE_SU2ALGEBRA_SU2SUM_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/hassu2get.h"
#include "TempLat/lattice/algebra/su2algebra/su2binaryoperator.h"
#include "TempLat/lattice/algebra/su2algebra/helpers/su2getgetreturntype.h"
#include "TempLat/util/rangeiteration/tagliteral.h"
#include "TempLat/lattice/algebra/helpers/doeval.h"
namespace TempLat
{
template <typename R, typename T> class SU2Addition : public SU2BinaryOperator<R, T>
{
public:
// Put public methods here. These should change very little over time.
using SU2BinaryOperator<R, T>::mR;
using SU2BinaryOperator<R, T>::mT;
using SV = typename SU2GetGetReturnType<R>::type;
SU2Addition(const R &pR, const T &pT) : SU2BinaryOperator<R, T>(pR, pT) {}
template <int N> auto SU2Get(Tag<N> t) const
{
static_assert(N >= 0 && N <= 3, "SU2Get: N must be between 0 and 3 for SU2Addition");
return mT.SU2Get(t) + mR.SU2Get(t);
}
template <int N> auto operator()(Tag<N> t) const { return SU2Get(t); }
template <typename... IDX>
requires requires(std::decay_t<R> r, std::decay_t<T> t, IDX... idx) {
requires IsVariadicIndex<IDX...>;
DoEval::eval(r, idx...);
DoEval::eval(t, idx...);
}
DEVICE_INLINE_FUNCTION auto eval(const IDX &...idx) const
{
auto cL = DoEval::eval(mR, idx...);
const auto cR = DoEval::eval(mT, idx...);
cL[0] += cR[0];
cL[1] += cR[1];
cL[2] += cR[2];
cL[3] += cR[3];
return cL;
}
virtual std::string operatorString() const override { return "+"; }
};
template <typename R, typename T>
requires(HasSU2Get<R> && HasSU2Get<T>)
auto operator+(const R &r, const T &t)
{
return SU2Addition{r, t};
}
} // namespace TempLat
#endif