GiNaC 1.8.10
tensor.h
Go to the documentation of this file.
1
5/*
6 * GiNaC Copyright (C) 1999-2026 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef GINAC_TENSOR_H
23#define GINAC_TENSOR_H
24
25#include "ex.h"
26#include "archive.h"
27
28namespace GiNaC {
29
33class tensor : public basic
34{
36
37 // functions overriding virtual functions from base classes
38protected:
39 unsigned return_type() const override { return return_types::noncommutative_composite; }
40
41 // non-virtual functions in this class
42public:
46 bool replace_contr_index(exvector::iterator self, exvector::iterator other) const;
47};
48
49
52class tensdelta : public tensor
53{
55
56 // functions overriding virtual functions from base classes
57public:
58 bool info(unsigned inf) const override;
59 ex eval_indexed(const basic & i) const override;
60 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override;
61protected:
62 unsigned return_type() const override { return return_types::commutative; }
63
64 // non-virtual functions in this class
65protected:
66 void do_print(const print_context & c, unsigned level) const;
67 void do_print_latex(const print_latex & c, unsigned level) const;
68};
70
71
75class tensmetric : public tensor
76{
78
79 // functions overriding virtual functions from base classes
80public:
81 bool info(unsigned inf) const override;
82 ex eval_indexed(const basic & i) const override;
83 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override;
84protected:
85 unsigned return_type() const override { return return_types::commutative; }
86
87 // non-virtual functions in this class
88protected:
89 void do_print(const print_context & c, unsigned level) const;
90};
92
93
97class minkmetric : public tensmetric
98{
100
101 // other constructors
102public:
104 minkmetric(bool pos_sig);
105
106 // functions overriding virtual functions from base classes
107public:
108 bool info(unsigned inf) const override;
109 ex eval_indexed(const basic & i) const override;
110
112 void archive(archive_node& n) const override;
114 void read_archive(const archive_node& n, lst& syms) override;
115protected:
116 unsigned return_type() const override { return return_types::commutative; }
117
118 // non-virtual functions in this class
119protected:
120 void do_print(const print_context & c, unsigned level) const;
121 void do_print_latex(const print_latex & c, unsigned level) const;
122
123 // member variables
124private:
125 bool pos_sig;
126};
128
129
134class spinmetric : public tensmetric
135{
137
138 // functions overriding virtual functions from base classes
139public:
140 bool info(unsigned inf) const override;
141 ex eval_indexed(const basic & i) const override;
142 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override;
143
144protected:
145 void do_print(const print_context & c, unsigned level) const;
146 void do_print_latex(const print_latex & c, unsigned level) const;
147};
149
150
154class tensepsilon : public tensor
155{
157
158 // other constructors
159public:
160 tensepsilon(bool minkowski, bool pos_sig);
161
162 // functions overriding virtual functions from base classes
163public:
164 bool info(unsigned inf) const override;
165 ex eval_indexed(const basic & i) const override;
166 bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override;
167
169 void archive(archive_node& n) const override;
171 void read_archive(const archive_node& n, lst& syms) override;
172protected:
173 unsigned return_type() const override { return return_types::commutative; }
174
175 // non-virtual functions in this class
176protected:
177 void do_print(const print_context & c, unsigned level) const;
178 void do_print_latex(const print_latex & c, unsigned level) const;
179
180 // member variables
181private:
183 bool pos_sig;
184};
186
187
188// utility functions
189
197ex delta_tensor(const ex & i1, const ex & i2);
198
206ex metric_tensor(const ex & i1, const ex & i2);
207
217ex lorentz_g(const ex & i1, const ex & i2, bool pos_sig = false);
218
227ex spinor_metric(const ex & i1, const ex & i2);
228
235ex epsilon_tensor(const ex & i1, const ex & i2);
236
244ex epsilon_tensor(const ex & i1, const ex & i2, const ex & i3);
245
255ex lorentz_eps(const ex & i1, const ex & i2, const ex & i3, const ex & i4, bool pos_sig = false);
256
257} // namespace GiNaC
258
259#endif // ndef GINAC_TENSOR_H
Archiving of GiNaC expressions.
#define GINAC_DECLARE_UNARCHIVER(classname)
Helper macros to register a class with (un)archiving (a.k.a.
Definition archive.h:218
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition archive.h:48
This class holds archived versions of GiNaC expressions (class ex).
Definition archive.h:254
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Definition basic.h:104
Wrapper template for making GiNaC classes out of STL containers.
Definition container.h:72
Lightweight wrapper for GiNaC's symbolic objects.
Definition ex.h:72
This class represents a Minkowski metric tensor.
Definition tensor.h:98
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed Lorentz metric tensor.
Definition tensor.cpp:282
void do_print(const print_context &c, unsigned level) const
bool pos_sig
If true, the metric is diag(-1,1,1...).
Definition tensor.h:125
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition tensor.cpp:97
bool info(unsigned inf) const override
Information about the object.
Definition tensor.cpp:165
void do_print_latex(const print_latex &c, unsigned level) const
unsigned return_type() const override
Definition tensor.h:116
Base class for print_contexts.
Definition print.h:101
Context for latex-parsable output.
Definition print.h:121
This class represents an antisymmetric spinor metric tensor which can be used to raise/lower indices ...
Definition tensor.h:135
bool info(unsigned inf) const override
Information about the object.
Definition tensor.cpp:194
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed metric tensor.
Definition tensor.cpp:309
void do_print_latex(const print_latex &c, unsigned level) const
void do_print(const print_context &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:460
This class represents the delta tensor.
Definition tensor.h:53
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:429
unsigned return_type() const override
Definition tensor.h:62
void do_print_latex(const print_latex &c, unsigned level) const
void do_print(const print_context &c, unsigned level) const
bool info(unsigned inf) const override
Information about the object.
Definition tensor.cpp:138
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed delta tensor.
Definition tensor.cpp:209
This class represents the totally antisymmetric epsilon tensor.
Definition tensor.h:155
void do_print_latex(const print_latex &c, unsigned level) const
bool minkowski
If true, tensor is in Minkowski-type space.
Definition tensor.h:182
bool pos_sig
If true, the metric is assumed to be diag(-1,1,1...).
Definition tensor.h:183
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition tensor.cpp:110
unsigned return_type() const override
Definition tensor.h:173
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of epsilon tensor with something else.
Definition tensor.cpp:540
bool info(unsigned inf) const override
Information about the object.
Definition tensor.cpp:186
void do_print(const print_context &c, unsigned level) const
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed epsilon tensor.
Definition tensor.cpp:340
This class represents a general metric tensor which can be used to raise/lower indices.
Definition tensor.h:76
bool info(unsigned inf) const override
Information about the object.
Definition tensor.cpp:146
unsigned return_type() const override
Definition tensor.h:85
void do_print(const print_context &c, unsigned level) const
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed metric tensor.
Definition tensor.cpp:251
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:442
This class holds one of GiNaC's predefined special tensors such as the delta and the metric tensors.
Definition tensor.h:34
unsigned return_type() const override
Definition tensor.h:39
bool replace_contr_index(exvector::iterator self, exvector::iterator other) const
Replace dummy index in contracted-with object by the contracting object's second index (used internal...
Definition tensor.cpp:386
Interface to GiNaC's light-weight expression handles.
size_t n
Definition factor.cpp:1431
size_t c
Definition factor.cpp:756
exset syms
Definition factor.cpp:2427
Definition add.cpp:35
ex spinor_metric(const ex &i1, const ex &i2)
Create a spinor metric tensor with specified indices.
Definition tensor.cpp:606
ex metric_tensor(const ex &i1, const ex &i2)
Create a symmetric metric tensor with specified indices.
Definition tensor.cpp:585
ex delta_tensor(const ex &i1, const ex &i2)
Create a delta tensor with specified indices.
Definition tensor.cpp:575
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:656
ex lorentz_g(const ex &i1, const ex &i2, bool pos_sig)
Create a Minkowski metric tensor with specified indices.
Definition tensor.cpp:595
std::vector< ex > exvector
Definition basic.h:47
ex epsilon_tensor(const ex &i1, const ex &i2)
Create an epsilon tensor in a Euclidean space with two indices.
Definition tensor.cpp:618
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition registrar.h:151

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