Skip to content

File listdivide.h

File List > algebra > listoperators > listdivide.h

Go to the documentation of this file

#ifndef TEMPLAT_LATTICE_ALGEBRA_OPERATORS_LISTOPERATORS_LISTDIVIDE_H
#define TEMPLAT_LATTICE_ALGEBRA_OPERATORS_LISTOPERATORS_LISTDIVIDE_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/helpers/getcomponent.h"
#include "TempLat/util/static_max.h"
#include "TempLat/util/tuple_size.h"
#include "listbinaryoperator.h"
#include "TempLat/lattice/algebra/conditional/conditionallistbinarygetter.h"
#include "TempLat/lattice/algebra/operators/divide.h"

namespace TempLat
{

  template <typename R, typename T> class ListDivision : public ListBinaryOperator<R, T>
  {
  public:
    using ListBinaryOperator<R, T>::mR;
    using ListBinaryOperator<R, T>::mT;
    ListDivision(const R &pR, const T &pT) : ListBinaryOperator<R, T>(pR, pT) {}

    template <int N> auto getComp(Tag<N> t) { return GetComponent::get(mR, t) / GetComponent::get(mT, t); }

    virtual std::string operatorString() const override { return "/"; }

    template <int N> void doWeNeedGhosts(Tag<N> i)
    {
      GhostsHunter::apply(mR, i);
      GhostsHunter::apply(mT, i);
    }
    static const size_t size = static_max<tuple_size<R>::value, tuple_size<T>::value>::value;
  };

  template <typename R, typename T>
    requires ConditionalListBinaryGetter<R, T>
  auto operator/(const R &r, const T &t)
  {
    return ListDivision<R, T>(r, t);
  }
} // namespace TempLat

#endif