78spinmetric::spinmetric()
100 inherited::read_archive(
n, sym_lst);
107 inherited::archive(
n);
113 inherited::read_archive(
n, sym_lst);
121 inherited::archive(
n);
163 return inherited::compare_same_type(other);
184 return inherited::compare_same_type(other);
216 const idx & i1 = ex_to<idx>(i.op(1));
217 const idx & i2 = ex_to<idx>(i.op(2));
233 }
catch (std::exception &e) {
240 int n1 = ex_to<numeric>(i1.
get_value()).to_int(), n2 = ex_to<numeric>(i2.
get_value()).to_int();
260 const varidx & i1 = ex_to<varidx>(i.
op(1));
261 const varidx & i2 = ex_to<varidx>(i.
op(2));
291 const varidx & i1 = ex_to<varidx>(i.
op(1));
292 const varidx & i2 = ex_to<varidx>(i.
op(2));
296 int n1 = ex_to<numeric>(i1.
get_value()).to_int(), n2 = ex_to<numeric>(i2.
get_value()).to_int();
306 return inherited::eval_indexed(i);
318 const spinidx & i1 = ex_to<spinidx>(i.
op(1));
319 const spinidx & i2 = ex_to<spinidx>(i.
op(2));
322 if (!(
static_cast<const indexed &
>(i).get_dummy_indices().empty()))
327 int n1 = ex_to<numeric>(i1.
get_value()).to_int(), n2 = ex_to<numeric>(i2.
get_value()).to_int();
348 if (!(
static_cast<const indexed &
>(i).get_dummy_indices().empty()))
357 v.reserve(i.
nops() - 1);
358 for (
size_t j=1; j<i.
nops(); j++)
359 v.push_back(ex_to<numeric>(ex_to<idx>(i.
op(j)).get_value()).to_int());
364 for (
size_t j=1; j<i.
nops(); j++) {
365 const ex &
x = i.
op(j);
366 if (!is_a<varidx>(
x)) {
367 throw(std::runtime_error(
"indices of epsilon tensor in Minkowski space must be of type varidx"));
369 if (ex_to<varidx>(
x).is_covariant()) {
370 if (ex_to<idx>(
x).get_value().
is_zero()) {
371 sign = (
pos_sig ? -sign : sign);
374 sign = (
pos_sig ? sign : -sign);
390 const idx *self_idx = &ex_to<idx>(self->op(1));
391 const idx *free_idx = &ex_to<idx>(self->op(2));
392 bool first_index_tried =
false;
396 for (
size_t i=1; i<other->nops(); i++) {
397 if (! is_a<idx>(other->op(i)))
399 const idx &other_idx = ex_to<idx>(other->op(i));
410 }
catch (std::exception &e) {
417 if (!first_index_tried) {
420 self_idx = &ex_to<idx>(self->op(2));
421 free_idx = &ex_to<idx>(self->op(1));
422 first_index_tried =
true;
452 if (is_a<tensdelta>(other->op(0)))
469 if (is_a<spinmetric>(other->op(0))) {
470 const idx &self_i1 = ex_to<idx>(self->op(1));
471 const idx &self_i2 = ex_to<idx>(self->op(2));
472 const idx &other_i1 = ex_to<idx>(other->op(1));
473 const idx &other_i2 = ex_to<idx>(other->op(2));
502 if (is_a<tensdelta>(other->op(0)))
506 const idx *self_idx = &ex_to<idx>(self->op(1));
507 const idx *free_idx = &ex_to<idx>(self->op(2));
508 bool first_index_tried =
false;
513 for (
size_t i=1; i<other->nops(); i++) {
514 const idx &other_idx = ex_to<idx>(other->op(i));
520 *other = other->subs(other_idx == *free_idx);
521 *self = (
static_cast<const spinidx *
>(self_idx)->is_covariant() ? sign : -sign);
527 if (!first_index_tried) {
530 self_idx = &ex_to<idx>(self->op(2));
531 free_idx = &ex_to<idx>(self->op(1));
532 first_index_tried =
true;
546 size_t num = self->nops() - 1;
548 if (is_exactly_a<tensepsilon>(other->op(0)) && num+1 == other->nops()) {
551 bool variance = is_a<varidx>(self->op(1));
553 for (
size_t i=0; i<num; i++) {
554 for (
size_t j=0; j<num; j++) {
578 static ex delta = dynallocate<tensdelta>();
580 if (!is_a<idx>(i1) || !is_a<idx>(i2))
581 throw(std::invalid_argument(
"indices of delta tensor must be of type idx"));
588 static ex metric = dynallocate<tensmetric>();
590 if (!is_a<varidx>(i1) || !is_a<varidx>(i2))
591 throw(std::invalid_argument(
"indices of metric tensor must be of type varidx"));
598 static ex metric_neg = dynallocate<minkmetric>(
false);
599 static ex metric_pos = dynallocate<minkmetric>(
true);
601 if (!is_a<varidx>(i1) || !is_a<varidx>(i2))
602 throw(std::invalid_argument(
"indices of metric tensor must be of type varidx"));
609 static ex metric = dynallocate<spinmetric>();
611 if (!is_a<spinidx>(i1) || !is_a<spinidx>(i2))
612 throw(std::invalid_argument(
"indices of spinor metric must be of type spinidx"));
613 if (!ex_to<idx>(i1).get_dim().is_equal(2) || !ex_to<idx>(i2).get_dim().is_equal(2))
614 throw(std::runtime_error(
"index dimension for spinor metric must be 2"));
621 static ex epsilon = dynallocate<tensepsilon>();
623 if (!is_a<idx>(i1) || !is_a<idx>(i2))
624 throw(std::invalid_argument(
"indices of epsilon tensor must be of type idx"));
626 ex dim = ex_to<idx>(i1).get_dim();
627 if (!dim.
is_equal(ex_to<idx>(i2).get_dim()))
628 throw(std::invalid_argument(
"all indices of epsilon tensor must have the same dimension"));
629 if (!ex_to<idx>(i1).get_dim().is_equal(
_ex2))
630 throw(std::runtime_error(
"index dimension of epsilon tensor must match number of indices"));
632 if(is_a<wildcard>(i1.
op(0))||is_a<wildcard>(i2.
op(0)))
640 static ex epsilon = dynallocate<tensepsilon>();
642 if (!is_a<idx>(i1) || !is_a<idx>(i2) || !is_a<idx>(i3))
643 throw(std::invalid_argument(
"indices of epsilon tensor must be of type idx"));
645 ex dim = ex_to<idx>(i1).get_dim();
646 if (!dim.
is_equal(ex_to<idx>(i2).get_dim()) || !dim.
is_equal(ex_to<idx>(i3).get_dim()))
647 throw(std::invalid_argument(
"all indices of epsilon tensor must have the same dimension"));
648 if (!ex_to<idx>(i1).get_dim().is_equal(
_ex3))
649 throw(std::runtime_error(
"index dimension of epsilon tensor must match number of indices"));
651 if(is_a<wildcard>(i1.
op(0))||is_a<wildcard>(i2.
op(0))||is_a<wildcard>(i3.
op(0)))
659 static ex epsilon_neg = dynallocate<tensepsilon>(
true,
false);
660 static ex epsilon_pos = dynallocate<tensepsilon>(
true,
true);
662 if (!is_a<varidx>(i1) || !is_a<varidx>(i2) || !is_a<varidx>(i3) || !is_a<varidx>(i4))
663 throw(std::invalid_argument(
"indices of Lorentz epsilon tensor must be of type varidx"));
665 ex dim = ex_to<idx>(i1).get_dim();
666 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()))
667 throw(std::invalid_argument(
"all indices of epsilon tensor must have the same dimension"));
668 if (!ex_to<idx>(i1).get_dim().is_equal(
_ex4))
669 throw(std::runtime_error(
"index dimension of epsilon tensor must match number of indices"));
671 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)))
Archiving of GiNaC expressions.
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
virtual size_t nops() const
Number of operands/members.
virtual ex op(size_t i) const
Return operand/member at position i.
const basic & hold() const
Stop further evaluation.
virtual ex subs(const exmap &m, unsigned options=0) const
Substitute a set of objects by arbitrary expressions.
virtual int compare_same_type(const basic &other) const
Returns order relation between two objects of same type.
Wrapper template for making GiNaC classes out of STL containers.
Lightweight wrapper for GiNaC's symbolic objects.
bool is_equal(const ex &other) const
ex simplify_indexed(unsigned options=0) const
Simplify/canonicalize expression containing indexed objects.
ex subs(const exmap &m, unsigned options=0) const
This class holds one index of an indexed object.
ex replace_dim(const ex &new_dim) const
Make a new index with the same value but a different dimension.
ex get_dim() const
Get dimension of index space.
bool is_symbolic() const
Check whether the index is symbolic.
ex minimal_dim(const idx &other) const
Return the minimum of the dimensions of this and another index.
ex get_value() const
Get value of index.
This class holds an indexed expression.
ex determinant(unsigned algo=determinant_algo::automatic) const
Determinant of square matrix.
This class represents a Minkowski metric tensor.
minkmetric(bool pos_sig)
Construct Lorentz metric tensor with given signature.
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed Lorentz metric tensor.
bool pos_sig
If true, the metric is diag(-1,1,1...).
void archive(archive_node &n) const override
Save (a.k.a.
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
bool info(unsigned inf) const override
Information about the object.
Context for default (ginsh-parsable) output.
Context for latex-parsable output.
This class holds a spinor index that can be dotted or undotted and that also has a variance.
This class represents an antisymmetric spinor metric tensor which can be used to raise/lower indices ...
bool info(unsigned inf) const override
Information about the object.
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 spinor metric with something else.
@ expanded
.expand(0) has already done its job (other expand() options ignore this flag)
@ evaluated
.eval() has already done its job
@ no_pattern
disable pattern matching
This class represents the delta tensor.
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of an indexed delta tensor with something else.
This class represents the totally antisymmetric epsilon tensor.
bool minkowski
If true, tensor is in Minkowski-type space.
bool pos_sig
If true, the metric is assumed to be diag(-1,1,1...).
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of epsilon tensor with something else.
bool info(unsigned inf) const override
Information about the object.
tensepsilon(bool minkowski, bool pos_sig)
void archive(archive_node &n) const override
Save (a.k.a.
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of an indexed epsilon tensor.
This class represents a general metric tensor which can be used to raise/lower indices.
bool info(unsigned inf) const override
Information about the object.
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.
This class holds one of GiNaC's predefined special tensors such as the delta and the metric tensors.
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...
This class holds an index with a variance (co- or contravariant).
bool is_covariant() const
Check whether the index is covariant.
Interface to GiNaC's indices.
Interface to GiNaC's indexed expressions.
Definition of GiNaC's lst.
Interface to symbolic matrices.
const symmetry & antisymmetric4()
bool is_zero(const ex &thisex)
ex spinor_metric(const ex &i1, const ex &i2)
Create a spinor metric tensor with specified indices.
ex metric_tensor(const ex &i1, const ex &i2)
Create a symmetric metric tensor with specified indices.
std::map< ex, ex, ex_is_less > exmap
const symmetry & antisymmetric3()
const symmetry & antisymmetric2()
const symmetry & symmetric2()
bool is_dummy_pair(const idx &i1, const idx &i2)
Check whether two indices form a dummy pair.
ex delta_tensor(const ex &i1, const ex &i2)
Create a delta tensor with specified indices.
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.
ex lorentz_g(const ex &i1, const ex &i2, bool pos_sig)
Create a Minkowski metric tensor with specified indices.
int permutation_sign(It first, It last)
GINAC_IMPLEMENT_REGISTERED_CLASS_OPT_T(lst, basic, print_func< print_context >(&lst::do_print). print_func< print_tree >(&lst::do_print_tree)) template<> bool lst GINAC_BIND_UNARCHIVER(lst)
Specialization of container::info() for lst.
std::vector< ex > exvector
ex epsilon_tensor(const ex &i1, const ex &i2)
Create an epsilon tensor in a Euclidean space with two indices.
Makes the interface to the underlying bignum package available.
Interface to GiNaC's overloaded operators.
#define GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(classname, supername, options)
Macro for inclusion in the implementation of each registered class.
#define GINAC_IMPLEMENT_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the implementation of each registered class.
Interface to relations between expressions.
Interface to GiNaC's symmetry definitions.
Interface to GiNaC's special tensors.
Interface to several small and furry utilities needed within GiNaC but not of any interest to the use...
#define DEFAULT_PRINT_LATEX(classname, text, latex)
#define DEFAULT_PRINT(classname, text)
#define DEFAULT_CTOR(classname)
#define DEFAULT_COMPARE(classname)