23 #ifndef INDEX_NEW_H_INCLUDED 24 #define INDEX_NEW_H_INCLUDED 44 :first(structure.begin()),
50 inline bool empty()
const {
54 inline size_t size()
const {
55 return (last - first);
58 inline const Index* begin()
const {
62 inline const Index* end()
const {
66 inline Index* begin() {
82 =
typename std::array<csl::Index, N>::iterator;
84 =
typename std::array<csl::Index, N>::const_iterator;
85 using reverse_iterator
86 =
typename std::array<csl::Index, N>::reverse_iterator;
87 using const_reverse_iterator
88 =
typename std::array<csl::Index, N>::const_reverse_iterator;
99 static_assert(N == 1);
104 :indices(other.begin(), other.end())
106 CSL_ASSERT_SPEC(other.size() == N,
107 CSLError::ValueError,
108 "Size mismatch for construction of IndexStructure, " 109 + toString(other.size()) +
" given, " + toString(N)
121 IndexStructure_new(std::array<csl::Index, N>&& t_indices)
122 :indices(std::move(t_indices))
127 constexpr
bool empty()
const {
131 constexpr
size_t size()
const {
135 inline iterator begin() {
136 return indices.begin();
139 inline iterator end() {
140 return indices.end();
143 inline const_iterator begin()
const {
144 return indices.begin();
147 inline const_iterator end()
const {
148 return indices.end();
151 inline reverse_iterator rbegin() {
152 return indices.rbegin();
155 inline reverse_iterator rend() {
156 return indices.rend();
159 inline const_reverse_iterator rbegin()
const {
160 return indices.rbegin();
163 inline const_reverse_iterator rend()
const {
164 return indices.rend();
179 auto iter = newStruct.begin();
180 for (
const auto& index : *
this)
182 for (
const auto& index : other)
186 std::vector<csl::Index> getVectorIndex()
const {
187 return std::vector<csl::Index>(indices.begin(), indices.end());
191 for (
auto& index : indices) {
192 index = index.rename();
209 for (
auto other = structure.begin(); other != structure.end();
211 if (not self->exactMatch(*other))
227 std::map<csl::Index,csl::Index> constraints;
228 return compareWithDummy(structure, constraints);
250 std::map<Index,Index>& constraints,
251 bool keepAllCosntraints =
false)
const {
253 for (
auto other = structure.begin(); other != structure.end();
257 if (not (*self).exactMatch((*other)))
265 if (not (*self).compareWithDummy((*other)))
267 if ((*
self) == (*other)) {
268 for (
const auto& cons : constraints)
269 if (cons.second == (*
self) and cons.first != cons.second)
272 if (constraints.find((*
self)) == constraints.end()) {
273 if (constraints.find((*other)) == constraints.end()) {
276 constraints[(*self)] = (*other);
279 if (constraints[(*other)] != (*self))
281 constraints[(*self)] = (*other);
285 if (constraints.find(*other) == constraints.end()) {
286 if (not (constraints[*
self] == *other))
289 else if (constraints[*
self] != *other
290 or constraints[*other] != *
self)
292 if (not keepAllCosntraints)
293 constraints.erase(*
self);
313 int t_nIndices = structure.size();
314 std::vector<int> indicesLeft(0);
315 for (
int i=0; i<t_nIndices; ++i)
317 if (structure[i].getFree())
318 indicesLeft.push_back(i);
320 for (
const auto& index : indices) {
322 if (index.getFree()) {
324 for (
size_t j=0; j!=indicesLeft.size(); ++j) {
326 if (index.exactMatch(structure[indicesLeft[j]])) {
328 indicesLeft.erase(indicesLeft.begin()+j);
337 if (not indicesLeft.empty())
351 return not (*
this == structure);
362 bool operator<(const IndexStructure_new<N>& structure)
const {
363 auto other = structure.begin();
364 for (
const auto& index : *
this) {
367 else if (*other < index)
384 return structure < *
this;
395 bool operator<=(const IndexStructure_new<N>& structure)
const {
396 return (*
this < structure or not (structure < *
this));
408 return structure <= *
this;
413 std::array<csl::Index, N> indices;
bool operator==(const IndexStructure_new< N > &structure) const
operator==, compares the IndexStructure_new<N> to structure in terms of free structure, independently of the dummy indices or the order of free indices.
Definition: index_new.h:312
Namespace for csl library.
Definition: abreviation.h:34
Definition: index_new.h:33
bool compareWithDummy(const IndexStructure_new< N > &structure) const
Compares *this with structure index by index (in order) using the function Index::compareWithDummy()...
Definition: index_new.h:226
Index object that is used for indicial objects.
Definition: index.h:75
Expr operator+(const Expr &a, const Expr &b)
Shortcut function that allows to use arithmetic operator + with Expr (== shared_ptr<Abstract>).
Definition: abstract.cpp:1298
bool operator>(const IndexStructure_new< N > &structure) const
operator>, simplicity comparator using comparators between indices, starting by comparing the first o...
Definition: index_new.h:383
bool operator!=(const IndexStructure_new< N > &structure) const
operator!=, returns the opposite of IndexStructure_new<N>::operator==().
Definition: index_new.h:350
File containing functions that are called by the program when something wrong happened: determines th...
bool compareWithDummy(const IndexStructure_new< N > &structure, std::map< Index, Index > &constraints, bool keepAllCosntraints=false) const
Compares *this with structure index by index (in order) using the function Index::compareWithDummy()...
Definition: index_new.h:249
Definition: index_new.h:35
bool exactMatch(const IndexStructure_new< N > &structure) const
Compares the IndexStructure_new<N> with structure. Each index must match exactly (see Index::exactMat...
Definition: index_new.h:207
bool operator>=(const IndexStructure_new< N > &structure) const
operator>=, simplicity comparator using comparators between indices, starting by comparing the first ...
Definition: index_new.h:407