GiNaC  1.8.0
tensor.h
Go to the documentation of this file.
1 
5 /*
6  * GiNaC Copyright (C) 1999-2020 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_TENSOR_H
24 #define GINAC_TENSOR_H
25 
26 #include "ex.h"
27 #include "archive.h"
28 
29 namespace GiNaC {
30 
34 class tensor : public basic
35 {
37 
38  // functions overriding virtual functions from base classes
39 protected:
40  unsigned return_type() const override { return return_types::noncommutative_composite; }
41 
42  // non-virtual functions in this class
43 public:
47  bool replace_contr_index(exvector::iterator self, exvector::iterator other) const;
48 };
49 
50 
53 class tensdelta : public tensor
54 {
56 
57  // functions overriding virtual functions from base classes
58 public:
59  bool info(unsigned inf) const override;
60  ex eval_indexed(const basic & i) const override;
61  bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override;
62 protected:
63  unsigned return_type() const override { return return_types::commutative; }
64 
65  // non-virtual functions in this class
66 protected:
67  void do_print(const print_context & c, unsigned level) const;
68  void do_print_latex(const print_latex & c, unsigned level) const;
69 };
70 GINAC_DECLARE_UNARCHIVER(tensdelta);
71 
72 
76 class tensmetric : public tensor
77 {
79 
80  // functions overriding virtual functions from base classes
81 public:
82  bool info(unsigned inf) const override;
83  ex eval_indexed(const basic & i) const override;
84  bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override;
85 protected:
86  unsigned return_type() const override { return return_types::commutative; }
87 
88  // non-virtual functions in this class
89 protected:
90  void do_print(const print_context & c, unsigned level) const;
91 };
92 GINAC_DECLARE_UNARCHIVER(tensmetric);
93 
94 
98 class minkmetric : public tensmetric
99 {
101 
102  // other constructors
103 public:
105  minkmetric(bool pos_sig);
106 
107  // functions overriding virtual functions from base classes
108 public:
109  bool info(unsigned inf) const override;
110  ex eval_indexed(const basic & i) const override;
111 
113  void archive(archive_node& n) const override;
115  void read_archive(const archive_node& n, lst& syms) override;
116 protected:
117  unsigned return_type() const override { return return_types::commutative; }
118 
119  // non-virtual functions in this class
120 protected:
121  void do_print(const print_context & c, unsigned level) const;
122  void do_print_latex(const print_latex & c, unsigned level) const;
123 
124  // member variables
125 private:
126  bool pos_sig;
127 };
129 
130 
135 class spinmetric : public tensmetric
136 {
138 
139  // functions overriding virtual functions from base classes
140 public:
141  bool info(unsigned inf) const override;
142  ex eval_indexed(const basic & i) const override;
143  bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override;
144 
145 protected:
146  void do_print(const print_context & c, unsigned level) const;
147  void do_print_latex(const print_latex & c, unsigned level) const;
148 };
150 
151 
155 class tensepsilon : public tensor
156 {
158 
159  // other constructors
160 public:
161  tensepsilon(bool minkowski, bool pos_sig);
162 
163  // functions overriding virtual functions from base classes
164 public:
165  bool info(unsigned inf) const override;
166  ex eval_indexed(const basic & i) const override;
167  bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override;
168 
170  void archive(archive_node& n) const override;
172  void read_archive(const archive_node& n, lst& syms) override;
173 protected:
174  unsigned return_type() const override { return return_types::commutative; }
175 
176  // non-virtual functions in this class
177 protected:
178  void do_print(const print_context & c, unsigned level) const;
179  void do_print_latex(const print_latex & c, unsigned level) const;
180 
181  // member variables
182 private:
183  bool minkowski;
184  bool pos_sig;
185 };
187 
188 
189 // utility functions
190 
198 ex delta_tensor(const ex & i1, const ex & i2);
199 
207 ex metric_tensor(const ex & i1, const ex & i2);
208 
218 ex lorentz_g(const ex & i1, const ex & i2, bool pos_sig = false);
219 
228 ex spinor_metric(const ex & i1, const ex & i2);
229 
236 ex epsilon_tensor(const ex & i1, const ex & i2);
237 
245 ex epsilon_tensor(const ex & i1, const ex & i2, const ex & i3);
246 
256 ex lorentz_eps(const ex & i1, const ex & i2, const ex & i3, const ex & i4, bool pos_sig = false);
257 
258 } // namespace GiNaC
259 
260 #endif // ndef GINAC_TENSOR_H
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition: tensor.cpp:112
unsigned return_type() const override
Definition: tensor.h:117
This class represents a Minkowski metric tensor.
Definition: tensor.h:98
ex metric_tensor(const ex &i1, const ex &i2)
Create a symmetric metric tensor with specified indices.
Definition: tensor.cpp:587
exset syms
Definition: factor.cpp:2434
This class represents a general metric tensor which can be used to raise/lower indices.
Definition: tensor.h:76
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition: tensor.cpp:99
Definition: add.cpp:38
unsigned return_type() const override
Definition: tensor.h:86
bool minkowski
If true, tensor is in Minkowski-type space.
Definition: tensor.h:183
Archiving of GiNaC expressions.
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Definition: basic.h:104
This class holds one of GiNaC's predefined special tensors such as the delta and the metric tensors...
Definition: tensor.h:34
minkmetric(bool pos_sig)
Construct Lorentz metric tensor with given signature.
Definition: tensor.cpp:75
void do_print_latex(const print_latex &c, unsigned level) const
ex lorentz_eps(const ex &i1, const ex &i2, const ex &i3, const ex &i4, bool pos_sig)
Create an epsilon tensor in a Minkowski space with four indices.
Definition: tensor.cpp:658
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed metric tensor.
Definition: tensor.cpp:311
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of an indexed metric tensor with something else.
Definition: tensor.cpp:444
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed epsilon tensor.
Definition: tensor.cpp:342
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed metric tensor.
Definition: tensor.cpp:253
Context for latex-parsable output.
Definition: print.h:122
bool info(unsigned inf) const override
Information about the object.
Definition: tensor.cpp:196
unsigned return_type() const override
Definition: tensor.h:174
This class represents an antisymmetric spinor metric tensor which can be used to raise/lower indices ...
Definition: tensor.h:135
ex epsilon_tensor(const ex &i1, const ex &i2)
Create an epsilon tensor in a Euclidean space with two indices.
Definition: tensor.cpp:620
bool pos_sig
If true, the metric is diag(-1,1,1...).
Definition: tensor.h:126
void do_print(const print_context &c, unsigned level) const
std::vector< ex > exvector
Definition: basic.h:46
tensepsilon(bool minkowski, bool pos_sig)
Definition: tensor.cpp:87
void do_print(const print_context &c, unsigned level) const
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed delta tensor.
Definition: tensor.cpp:211
void archive(archive_node &n) const override
Save (a.k.a.
Definition: tensor.cpp:120
ex spinor_metric(const ex &i1, const ex &i2)
Create a spinor metric tensor with specified indices.
Definition: tensor.cpp:608
void do_print(const print_context &c, unsigned level) const
bool pos_sig
If true, the metric is assumed to be diag(-1,1,1...).
Definition: tensor.h:184
size_t n
Definition: factor.cpp:1463
Interface to GiNaC&#39;s light-weight expression handles.
Base class for print_contexts.
Definition: print.h:102
void do_print(const print_context &c, unsigned level) const
unsigned return_type() const override
Definition: tensor.h:40
This class represents the totally antisymmetric epsilon tensor.
Definition: tensor.h:155
This class represents the delta tensor.
Definition: tensor.h:53
ex delta_tensor(const ex &i1, const ex &i2)
Create a delta tensor with specified indices.
Definition: tensor.cpp:577
void do_print(const print_context &c, unsigned level) const
void archive(archive_node &n) const override
Save (a.k.a.
Definition: tensor.cpp:106
bool info(unsigned inf) const override
Information about the object.
Definition: tensor.cpp:148
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition: archive.h:48
Lightweight wrapper for GiNaC&#39;s symbolic objects.
Definition: ex.h:72
void do_print_latex(const print_latex &c, unsigned level) const
void do_print_latex(const print_latex &c, unsigned level) const
ex lorentz_g(const ex &i1, const ex &i2, bool pos_sig)
Create a Minkowski metric tensor with specified indices.
Definition: tensor.cpp:597
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition: registrar.h:153
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of epsilon tensor with something else.
Definition: tensor.cpp:542
bool info(unsigned inf) const override
Information about the object.
Definition: tensor.cpp:188
GINAC_DECLARE_UNARCHIVER(add)
bool info(unsigned inf) const override
Information about the object.
Definition: tensor.cpp:140
size_t c
Definition: factor.cpp:770
bool info(unsigned inf) const override
Information about the object.
Definition: tensor.cpp:167
unsigned return_type() const override
Definition: tensor.h:63
void do_print_latex(const print_latex &c, unsigned level) const
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of an indexed spinor metric with something else.
Definition: tensor.cpp:462
bool replace_contr_index(exvector::iterator self, exvector::iterator other) const
Replace dummy index in contracted-with object by the contracting object&#39;s second index (used internal...
Definition: tensor.cpp:388
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed Lorentz metric tensor.
Definition: tensor.cpp:284
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of an indexed delta tensor with something else.
Definition: tensor.cpp:431

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