1#ifndef XPED_IPEPS_ITERATOR_HPP_
2#define XPED_IPEPS_ITERATOR_HPP_
6#include <boost/iterator/iterator_facade.hpp>
13template <
typename Scalar,
typename Symmetry,
bool ENABLE_AD>
14class iPEPSIterator :
public boost::iterator_facade<iPEPSIterator<Scalar, Symmetry, ENABLE_AD>, Scalar*, boost::forward_traversal_tag, Scalar>
22 bool ITER_GRAD =
false,
23 std::size_t outer_num = 0,
24 std::size_t elem_num = 0)
26 , ITER_GRAD(ITER_GRAD)
27 , outer_num(outer_num)
30 if constexpr(not ENABLE_AD) { assert(ITER_GRAD ==
false); }
38 if(outer_num == data->size() - 1 and elem_num == data->at(outer_num).plainSize() - 1) {
39 outer_num = data->size();
43 if(elem_num < data->at(outer_num).plainSize() - 1)
51 bool equal(iPEPSIterator<Scalar, Symmetry, ENABLE_AD>
const& other)
const
53 return (this->outer_num == other.outer_num and this->elem_num == other.elem_num);
58 if constexpr(ENABLE_AD) {
59 auto beg = ITER_GRAD ? data->at(outer_num).cgradbegin() : data->at(outer_num).cbegin();
60 std::advance(beg, elem_num);
63 auto beg = data->at(outer_num).cbegin();
64 std::advance(beg, elem_num);
69 TMatrix<Tensor<Scalar, 2, 3, Symmetry, ENABLE_AD>>* data;
70 bool ITER_GRAD =
false;
71 std::size_t outer_num = 0;
72 std::size_t elem_num = 0;
Definition: Tensor.hpp:40
Definition: iPEPSIterator.hpp:15
iPEPSIterator()
Definition: iPEPSIterator.hpp:17
iPEPSIterator(TMatrix< Tensor< Scalar, 2, 3, Symmetry, ENABLE_AD > > *data_in, bool ITER_GRAD=false, std::size_t outer_num=0, std::size_t elem_num=0)
Definition: iPEPSIterator.hpp:21
friend class boost::iterator_core_access
Definition: iPEPSIterator.hpp:34
double Scalar
Definition: Heisenberg.cpp:5
Definition: TMatrix.hpp:13