79 spinmetric::spinmetric()
101 inherited::read_archive(
n, sym_lst);
108 inherited::archive(
n);
114 inherited::read_archive(
n, sym_lst);
122 inherited::archive(
n);
164 return inherited::compare_same_type(other);
185 return inherited::compare_same_type(other);
217 const idx & i1 = ex_to<idx>(i.op(1));
218 const idx & i2 = ex_to<idx>(i.op(2));
226 m[i2] = i2.replace_dim(min_dim);
234 }
catch (std::exception &e) {
261 const varidx & i1 = ex_to<varidx>(i.
op(1));
262 const varidx & i2 = ex_to<varidx>(i.
op(2));
270 m[i2] = i2.replace_dim(min_dim);
292 const varidx & i1 = ex_to<varidx>(i.
op(1));
293 const varidx & i2 = ex_to<varidx>(i.
op(2));
307 return inherited::eval_indexed(i);
319 const spinidx & i1 = ex_to<spinidx>(i.
op(1));
320 const spinidx & i2 = ex_to<spinidx>(i.
op(2));
323 if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
349 if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
358 v.reserve(i.
nops() - 1);
359 for (
size_t j=1; j<i.
nops(); j++)
360 v.push_back(ex_to<numeric>(ex_to<idx>(i.
op(j)).get_value()).
to_int());
365 for (
size_t j=1; j<i.
nops(); j++) {
366 const ex &
x = i.
op(j);
367 if (!is_a<varidx>(
x)) {
368 throw(std::runtime_error(
"indices of epsilon tensor in Minkowski space must be of type varidx"));
370 if (ex_to<varidx>(
x).is_covariant()) {
371 if (ex_to<idx>(
x).get_value().
is_zero()) {
372 sign = (
pos_sig ? -sign : sign);
375 sign = (
pos_sig ? sign : -sign);
391 const idx *self_idx = &ex_to<idx>(
self->op(1));
392 const idx *free_idx = &ex_to<idx>(
self->op(2));
393 bool first_index_tried =
false;
397 for (
size_t i=1; i<other->nops(); i++) {
398 if (! is_a<idx>(other->op(i)))
400 const idx &other_idx = ex_to<idx>(other->op(i));
411 }
catch (std::exception &e) {
418 if (!first_index_tried) {
421 self_idx = &ex_to<idx>(
self->op(2));
422 free_idx = &ex_to<idx>(
self->op(1));
423 first_index_tried =
true;
453 if (is_a<tensdelta>(other->op(0)))
470 if (is_a<spinmetric>(other->op(0))) {
471 const idx &self_i1 = ex_to<idx>(
self->op(1));
472 const idx &self_i2 = ex_to<idx>(
self->op(2));
473 const idx &other_i1 = ex_to<idx>(other->op(1));
474 const idx &other_i2 = ex_to<idx>(other->op(2));
503 if (is_a<tensdelta>(other->op(0)))
507 const idx *self_idx = &ex_to<idx>(
self->op(1));
508 const idx *free_idx = &ex_to<idx>(
self->op(2));
509 bool first_index_tried =
false;
514 for (
size_t i=1; i<other->nops(); i++) {
515 const idx &other_idx = ex_to<idx>(other->op(i));
521 *other = other->
subs(other_idx == *free_idx);
522 *
self = (
static_cast<const spinidx *
>(self_idx)->is_covariant() ? sign : -sign);
528 if (!first_index_tried) {
531 self_idx = &ex_to<idx>(
self->op(2));
532 free_idx = &ex_to<idx>(
self->op(1));
533 first_index_tried =
true;
547 size_t num =
self->nops() - 1;
549 if (is_exactly_a<tensepsilon>(other->op(0)) && num+1 == other->nops()) {
552 bool variance = is_a<varidx>(
self->op(1));
554 for (
size_t i=0; i<num; i++) {
555 for (
size_t j=0; j<num; j++) {
565 *
self = sign * M.determinant().simplify_indexed();
579 static ex delta = dynallocate<tensdelta>();
581 if (!is_a<idx>(i1) || !is_a<idx>(i2))
582 throw(std::invalid_argument(
"indices of delta tensor must be of type idx"));
589 static ex metric = dynallocate<tensmetric>();
591 if (!is_a<varidx>(i1) || !is_a<varidx>(i2))
592 throw(std::invalid_argument(
"indices of metric tensor must be of type varidx"));
599 static ex metric_neg = dynallocate<minkmetric>(
false);
600 static ex metric_pos = dynallocate<minkmetric>(
true);
602 if (!is_a<varidx>(i1) || !is_a<varidx>(i2))
603 throw(std::invalid_argument(
"indices of metric tensor must be of type varidx"));
610 static ex metric = dynallocate<spinmetric>();
612 if (!is_a<spinidx>(i1) || !is_a<spinidx>(i2))
613 throw(std::invalid_argument(
"indices of spinor metric must be of type spinidx"));
614 if (!ex_to<idx>(i1).get_dim().is_equal(2) || !ex_to<idx>(i2).get_dim().is_equal(2))
615 throw(std::runtime_error(
"index dimension for spinor metric must be 2"));
622 static ex epsilon = dynallocate<tensepsilon>();
624 if (!is_a<idx>(i1) || !is_a<idx>(i2))
625 throw(std::invalid_argument(
"indices of epsilon tensor must be of type idx"));
627 ex dim = ex_to<idx>(i1).get_dim();
628 if (!dim.
is_equal(ex_to<idx>(i2).get_dim()))
629 throw(std::invalid_argument(
"all indices of epsilon tensor must have the same dimension"));
630 if (!ex_to<idx>(i1).get_dim().is_equal(
_ex2))
631 throw(std::runtime_error(
"index dimension of epsilon tensor must match number of indices"));
633 if(is_a<wildcard>(i1.
op(0))||is_a<wildcard>(i2.
op(0)))
641 static ex epsilon = dynallocate<tensepsilon>();
643 if (!is_a<idx>(i1) || !is_a<idx>(i2) || !is_a<idx>(i3))
644 throw(std::invalid_argument(
"indices of epsilon tensor must be of type idx"));
646 ex dim = ex_to<idx>(i1).get_dim();
647 if (!dim.
is_equal(ex_to<idx>(i2).get_dim()) || !dim.
is_equal(ex_to<idx>(i3).get_dim()))
648 throw(std::invalid_argument(
"all indices of epsilon tensor must have the same dimension"));
649 if (!ex_to<idx>(i1).get_dim().is_equal(
_ex3))
650 throw(std::runtime_error(
"index dimension of epsilon tensor must match number of indices"));
652 if(is_a<wildcard>(i1.
op(0))||is_a<wildcard>(i2.
op(0))||is_a<wildcard>(i3.
op(0)))
660 static ex epsilon_neg = dynallocate<tensepsilon>(
true,
false);
661 static ex epsilon_pos = dynallocate<tensepsilon>(
true,
true);
663 if (!is_a<varidx>(i1) || !is_a<varidx>(i2) || !is_a<varidx>(i3) || !is_a<varidx>(i4))
664 throw(std::invalid_argument(
"indices of Lorentz epsilon tensor must be of type varidx"));
666 ex dim = ex_to<idx>(i1).get_dim();
667 if (!dim.
is_equal(ex_to<idx>(i2).get_dim()) || !dim.
is_equal(ex_to<idx>(i3).get_dim()) || !dim.
is_equal(ex_to<idx>(i4).get_dim()))
668 throw(std::invalid_argument(
"all indices of epsilon tensor must have the same dimension"));
669 if (!ex_to<idx>(i1).get_dim().is_equal(
_ex4))
670 throw(std::runtime_error(
"index dimension of epsilon tensor must match number of indices"));
672 if(is_a<wildcard>(i1.
op(0))||is_a<wildcard>(i2.
op(0))||is_a<wildcard>(i3.
op(0))||is_a<wildcard>(i4.
op(0)))
#define DEFAULT_PRINT(classname, text)
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
This class holds a spinor index that can be dotted or undotted and that also has a variance...
This class represents a Minkowski metric tensor.
Interface to GiNaC's indexed expressions.
ex metric_tensor(const ex &i1, const ex &i2)
Create a symmetric metric tensor with specified indices.
This class represents a general metric tensor which can be used to raise/lower indices.
int to_int(const numeric &x)
print_func< print_dflt >(&diracone::do_print). print_func< print_latex >(&diracone
Interface to GiNaC's symmetry definitions.
ex subs(const exmap &m, unsigned options=0) const
const basic & hold() const
Stop further evaluation.
bool is_equal(const ex &other) const
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
const basic & setflag(unsigned f) const
Set some status_flags.
int permutation_sign(It first, It last)
ex get_value() const
Get value of index.
bool minkowski
If true, tensor is in Minkowski-type space.
Archiving of GiNaC expressions.
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
This class holds one of GiNaC's predefined special tensors such as the delta and the metric tensors...
minkmetric(bool pos_sig)
Construct Lorentz metric tensor with given signature.
const symmetry & antisymmetric2()
void do_print_latex(const print_latex &c, unsigned level) const
virtual size_t nops() const
Number of operands/members.
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.
Interface to GiNaC's indices.
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed metric tensor.
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of an indexed metric tensor with something else.
Interface to several small and furry utilities needed within GiNaC but not of any interest to the use...
bool is_zero(const ex &thisex)
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed epsilon tensor.
Interface to GiNaC's special tensors.
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed metric tensor.
const symmetry & antisymmetric3()
ex replace_dim(const ex &new_dim) const
Make a new index with the same value but a different dimension.
bool info(unsigned inf) const override
Information about the object.
This class represents an antisymmetric spinor metric tensor which can be used to raise/lower indices ...
This class holds an indexed expression.
virtual ex op(size_t i) const
Return operand/member at position i.
#define DEFAULT_PRINT_LATEX(classname, text, latex)
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
ex minimal_dim(const idx &other) const
Return the minimum of the dimensions of this and another index.
ex epsilon_tensor(const ex &i1, const ex &i2)
Create an epsilon tensor in a Euclidean space with two indices.
bool pos_sig
If true, the metric is diag(-1,1,1...).
GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(add, expairseq, print_func< print_context >(&add::do_print). print_func< print_latex >(&add::do_print_latex). print_func< print_csrc >(&add::do_print_csrc). print_func< print_tree >(&add::do_print_tree). print_func< print_python_repr >(&add::do_print_python_repr)) add
void do_print(const print_context &c, unsigned level) const
bool is_dummy_pair(const idx &i1, const idx &i2)
Check whether two indices form a dummy pair.
Interface to symbolic matrices.
std::vector< ex > exvector
std::map< ex, ex, ex_is_less > exmap
Interface to GiNaC's overloaded operators.
tensepsilon(bool minkowski, bool pos_sig)
void do_print(const print_context &c, unsigned level) const
void archive(archive_node &n) const override
Save (a.k.a.
ex spinor_metric(const ex &i1, const ex &i2)
Create a spinor metric tensor with specified indices.
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...).
#define GINAC_IMPLEMENT_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the implementation of each registered class.
Definition of GiNaC's lst.
void do_print(const print_context &c, unsigned level) const
This class represents the totally antisymmetric epsilon tensor.
This class represents the delta tensor.
ex delta_tensor(const ex &i1, const ex &i2)
Create a delta tensor with specified indices.
void do_print(const print_context &c, unsigned level) const
This class holds an index with a variance (co- or contravariant).
void archive(archive_node &n) const override
Save (a.k.a.
bool info(unsigned inf) const override
Information about the object.
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Lightweight wrapper for GiNaC's symbolic objects.
void do_print_latex(const print_latex &c, unsigned level) const
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
virtual ex subs(const exmap &m, unsigned options=0) const
Substitute a set of objects by arbitrary expressions.
ex get_dim() const
Get dimension of index space.
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.
bool is_covariant() const
Check whether the index is covariant.
const symmetry & symmetric2()
virtual int compare_same_type(const basic &other) const
Returns order relation between two objects of same type.
const symmetry & antisymmetric4()
Wrapper template for making GiNaC classes out of STL containers.
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of epsilon tensor with something else.
.expand(0) has already done its job (other expand() options ignore this flag)
This class holds one index of an indexed object.
Interface to relations between expressions.
bool info(unsigned inf) const override
Information about the object.
Makes the interface to the underlying bignum package available.
#define DEFAULT_COMPARE(classname)
#define DEFAULT_CTOR(classname)
bool is_symbolic() const
Check whether the index is symbolic.
bool info(unsigned inf) const override
Information about the object.
.eval() has already done its job
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.
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...
GINAC_BIND_UNARCHIVER(add)
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed Lorentz metric tensor.
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of an indexed delta tensor with something else.