GiNaC 1.8.7
indexed.h
Go to the documentation of this file.
1
5/*
6 * GiNaC Copyright (C) 1999-2023 Johannes Gutenberg University Mainz, Germany
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef GINAC_INDEXED_H
24#define GINAC_INDEXED_H
25
26#include "exprseq.h"
27#include "wildcard.h"
28
29#include <map>
30
31namespace GiNaC {
32
33class scalar_products;
34class symmetry;
35
39class indexed : public exprseq
40{
42
43 friend ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indices, const scalar_products & sp);
44 friend ex simplify_indexed_product(const ex & e, exvector & free_indices, exvector & dummy_indices, const scalar_products & sp);
45 friend bool reposition_dummy_indices(ex & e, exvector & variant_dummy_indices, exvector & moved_indices);
46
47 // other constructors
48public:
52 indexed(const ex & b);
53
58 indexed(const ex & b, const ex & i1);
59
65 indexed(const ex & b, const ex & i1, const ex & i2);
66
73 indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3);
74
82 indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3, const ex & i4);
83
91 indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2);
92
101 indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3);
102
112 indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3, const ex & i4);
113
119 indexed(const ex & b, const exvector & iv);
120
127 indexed(const ex & b, const symmetry & symm, const exvector & iv);
128
129 // internal constructors
130 indexed(const symmetry & symm, const exprseq & es);
131 indexed(const symmetry & symm, const exvector & v);
132 indexed(const symmetry & symm, exvector && v);
133
134 // functions overriding virtual functions from base classes
135public:
136 unsigned precedence() const override {return 55;}
137 bool info(unsigned inf) const override;
138 ex eval() const override;
139 ex real_part() const override;
140 ex imag_part() const override;
141 exvector get_free_indices() const override;
142
144 void archive(archive_node& n) const override;
146 void read_archive(const archive_node& n, lst& syms) override;
147protected:
148 ex derivative(const symbol & s) const override;
149 ex thiscontainer(const exvector & v) const override;
150 ex thiscontainer(exvector && v) const override;
151 unsigned return_type() const override;
152 return_type_t return_type_tinfo() const override { return op(0).return_type_tinfo(); }
153 ex expand(unsigned options = 0) const override;
154
155 // new virtual functions which can be overridden by derived classes
156 // none
157
158 // non-virtual functions in this class
159public:
162 bool all_index_values_are(unsigned inf) const;
163
165 exvector get_indices() const;
166
169
173 exvector get_dummy_indices(const indexed & other) const;
174
177 bool has_dummy_index_for(const ex & i) const;
178
180 ex get_symmetry() const {return symtree;}
181
182protected:
183 void printindices(const print_context & c, unsigned level) const;
184 void print_indexed(const print_context & c, const char *openbrace, const char *closebrace, unsigned level) const;
185 void do_print(const print_context & c, unsigned level) const;
186 void do_print_latex(const print_latex & c, unsigned level) const;
187 void do_print_tree(const print_tree & c, unsigned level) const;
188 void validate() const;
189
190 // member variables
191protected:
193};
195
196
197class spmapkey {
198public:
199 spmapkey() : dim(wild()) {}
200 spmapkey(const ex & v1, const ex & v2, const ex & dim = wild());
201
202 bool operator==(const spmapkey &other) const;
203 bool operator<(const spmapkey &other) const;
204
205 void debugprint() const;
206
207protected:
209};
210
211typedef std::map<spmapkey, ex> spmap;
212
218public:
220 void add(const ex & v1, const ex & v2, const ex & sp);
221
223 void add(const ex & v1, const ex & v2, const ex & dim, const ex & sp);
224
228 void add_vectors(const lst & l, const ex & dim = wild());
229
231 void clear();
232
233 bool is_defined(const ex & v1, const ex & v2, const ex & dim) const;
234 ex evaluate(const ex & v1, const ex & v2, const ex & dim) const;
235 void debugprint() const;
236
237protected:
238 spmap spm; /*< Map from defined scalar product pairs to their values */
239};
240
241
242// utility functions
243
246
250
253ex rename_dummy_indices_uniquely(exvector & va, const ex & b, bool modify_va = false);
254
256ex rename_dummy_indices_uniquely(const ex & a, const ex & b);
257
259ex rename_dummy_indices_uniquely(const exvector & va, const exvector & vb, const ex & b);
260
263lst rename_dummy_indices_uniquely(const exvector & va, const exvector & vb);
264
274ex expand_dummy_sum(const ex & e, bool subs_idx = false);
275
276} // namespace GiNaC
277
278#endif // ndef GINAC_INDEXED_H
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition: archive.h:49
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
ex op(size_t i) const override
Return operand/member at position i.
Definition: container.h:295
Lightweight wrapper for GiNaC's symbolic objects.
Definition: ex.h:72
return_type_t return_type_tinfo() const
Definition: ex.h:231
This class holds an indexed expression.
Definition: indexed.h:40
bool all_index_values_are(unsigned inf) const
Check whether all index values have a certain property.
Definition: indexed.cpp:246
ex thiscontainer(const exvector &v) const override
Definition: indexed.cpp:313
friend ex simplify_indexed(const ex &e, exvector &free_indices, exvector &dummy_indices, const scalar_products &sp)
Simplify indexed expression, return list of free indices.
Definition: indexed.cpp:1044
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
Definition: indexed.h:136
void printindices(const print_context &c, unsigned level) const
Definition: indexed.cpp:165
exvector get_free_indices() const override
Return a vector containing the free indices of an expression.
Definition: indexed.cpp:457
ex get_symmetry() const
Return symmetry properties.
Definition: indexed.h:180
void archive(archive_node &n) const override
Save (a.k.a.
Definition: indexed.cpp:155
void do_print(const print_context &c, unsigned level) const
Definition: indexed.cpp:219
ex expand(unsigned options=0) const override
Expand expression, i.e.
Definition: indexed.cpp:331
void do_print_latex(const print_latex &c, unsigned level) const
Definition: indexed.cpp:224
friend bool reposition_dummy_indices(ex &e, exvector &variant_dummy_indices, exvector &moved_indices)
Raise/lower dummy indices in a single indexed objects to canonicalize their variance.
Definition: indexed.cpp:618
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition: indexed.cpp:132
void do_print_tree(const print_tree &c, unsigned level) const
Definition: indexed.cpp:229
ex derivative(const symbol &s) const override
Implementation of ex::diff() for an indexed object always returns 0.
Definition: indexed.cpp:388
bool info(unsigned inf) const override
Information about the object.
Definition: indexed.cpp:239
ex eval() const override
Perform automatic non-interruptive term rewriting rules.
Definition: indexed.cpp:263
indexed(const ex &b)
Construct indexed object with no index.
Definition: indexed.cpp:64
ex real_part() const override
Definition: indexed.cpp:299
void validate() const
Check whether all indices are of class idx and validate the symmetry tree.
Definition: indexed.cpp:368
ex symtree
Index symmetry (tree of symmetry objects)
Definition: indexed.h:192
exvector get_indices() const
Return a vector containing the object's indices.
Definition: indexed.cpp:423
return_type_t return_type_tinfo() const override
Definition: indexed.h:152
exvector get_dummy_indices() const
Return a vector containing the dummy indices of the object, if any.
Definition: indexed.cpp:429
void print_indexed(const print_context &c, const char *openbrace, const char *closebrace, unsigned level) const
Definition: indexed.cpp:207
friend ex simplify_indexed_product(const ex &e, exvector &free_indices, exvector &dummy_indices, const scalar_products &sp)
Simplify product of indexed expressions (commutative, noncommutative and simple squares),...
Definition: indexed.cpp:779
bool has_dummy_index_for(const ex &i) const
Check whether the object has an index that forms a dummy index pair with a given index.
Definition: indexed.cpp:446
unsigned return_type() const override
Definition: indexed.cpp:323
ex imag_part() const override
Definition: indexed.cpp:306
Base class for print_contexts.
Definition: print.h:103
Context for latex-parsable output.
Definition: print.h:123
Context for tree-like output for debugging.
Definition: print.h:147
Helper class for storing information about known scalar products which are to be automatically replac...
Definition: indexed.h:217
bool is_defined(const ex &v1, const ex &v2, const ex &dim) const
Check whether scalar product pair is defined.
Definition: indexed.cpp:1372
void debugprint() const
Definition: indexed.cpp:1383
ex evaluate(const ex &v1, const ex &v2, const ex &dim) const
Return value of defined scalar product pair.
Definition: indexed.cpp:1378
void add(const ex &v1, const ex &v2, const ex &sp)
Register scalar product pair and its value.
Definition: indexed.cpp:1348
void clear()
Clear all registered scalar products.
Definition: indexed.cpp:1366
void add_vectors(const lst &l, const ex &dim=wild())
Register list of vectors.
Definition: indexed.cpp:1358
void debugprint() const
Definition: indexed.cpp:1343
bool operator<(const spmapkey &other) const
Definition: indexed.cpp:1327
bool operator==(const spmapkey &other) const
Definition: indexed.cpp:1315
Basic CAS symbol.
Definition: symbol.h:39
This class describes the symmetry of a group of indices.
Definition: symmetry.h:39
Definition of GiNaC's exprseq.
unsigned options
Definition: factor.cpp:2475
size_t n
Definition: factor.cpp:1432
size_t c
Definition: factor.cpp:757
exset syms
Definition: factor.cpp:2429
Definition: add.cpp:38
std::map< spmapkey, ex > spmap
Definition: indexed.h:211
GINAC_DECLARE_UNARCHIVER(add)
static ex symm(const ex &e, exvector::const_iterator first, exvector::const_iterator last, bool asymmetric)
Definition: symmetry.cpp:485
lst rename_dummy_indices_uniquely(const exvector &va, const exvector &vb)
Similar to above, where va and vb are the same and the return value is a list of two lists for substi...
Definition: indexed.cpp:1460
ex expand_dummy_sum(const ex &e, bool subs_idx)
This function returns the given expression with expanded sums for all dummy index summations,...
Definition: indexed.cpp:1541
std::vector< ex > exvector
Definition: basic.h:48
exvector get_all_dummy_indices(const ex &e)
Returns all dummy indices from the exvector.
Definition: indexed.cpp:1435
ex wild(unsigned label=0)
Create a wildcard object with the specified label.
Definition: wildcard.h:72
exvector get_all_dummy_indices_safely(const ex &e)
More reliable version of the form.
Definition: indexed.cpp:1394
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition: registrar.h:153
To distinguish between different kinds of non-commutative objects.
Definition: registrar.h:44
Interface to GiNaC's wildcard objects.

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.