]> www.ginac.de Git - ginac.git/blobdiff - ginac/color.cpp
- Cleanups: My evil plot of making ex::bp private may finally be carried
[ginac.git] / ginac / color.cpp
index 45521b7aa9ec13dd8683ff479fc82c37ad139879..3c316d413dc67163d4e4d27562a81e75586aad96 100644 (file)
@@ -28,6 +28,7 @@
 #include "ncmul.h"
 #include "symmetry.h"
 #include "numeric.h"
+#include "mul.h"
 #include "power.h" // for sqrt()
 #include "symbol.h"
 #include "print.h"
@@ -124,12 +125,12 @@ DEFAULT_ARCHIVING(su3f)
 DEFAULT_ARCHIVING(su3d)
 
 //////////
-// functions overriding virtual functions from bases classes
+// functions overriding virtual functions from base classes
 //////////
 
 int color::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(other.tinfo() == TINFO_color);
+       GINAC_ASSERT(is_a<color>(other));
        const color &o = static_cast<const color &>(other);
 
        if (representation_label != o.representation_label) {
@@ -140,6 +141,14 @@ int color::compare_same_type(const basic & other) const
        return inherited::compare_same_type(other);
 }
 
+bool color::match_same_type(const basic & other) const
+{
+       GINAC_ASSERT(is_a<color>(other));
+       const color &o = static_cast<const color &>(other);
+
+       return representation_label == o.representation_label;
+}
+
 DEFAULT_COMPARE(su3one)
 DEFAULT_COMPARE(su3t)
 DEFAULT_COMPARE(su3f)
@@ -165,7 +174,7 @@ ex color::simplify_ncmul(const exvector & v) const
                it++;
        }
 
-       if (s.size() == 0)
+       if (s.empty())
                return color(su3one(), representation_label);
        else
                return simplified_ncmul(s);
@@ -215,12 +224,12 @@ static ex permute_free_index_to_front(const exvector & iv3, const exvector & iv2
 /** Automatic symbolic evaluation of indexed symmetric structure constant. */
 ex su3d::eval_indexed(const basic & i) const
 {
-       GINAC_ASSERT(is_of_type(i, indexed));
+       GINAC_ASSERT(is_a<indexed>(i));
        GINAC_ASSERT(i.nops() == 4);
-       GINAC_ASSERT(is_ex_of_type(i.op(0), su3d));
+       GINAC_ASSERT(is_a<su3d>(i.op(0)));
 
        // Convolutions are zero
-       if (static_cast<const indexed &>(i).get_dummy_indices().size() != 0)
+       if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
                return _ex0();
 
        // Numeric evaluation
@@ -260,9 +269,9 @@ ex su3d::eval_indexed(const basic & i) const
 /** Automatic symbolic evaluation of indexed antisymmetric structure constant. */
 ex su3f::eval_indexed(const basic & i) const
 {
-       GINAC_ASSERT(is_of_type(i, indexed));
+       GINAC_ASSERT(is_a<indexed>(i));
        GINAC_ASSERT(i.nops() == 4);
-       GINAC_ASSERT(is_ex_of_type(i.op(0), su3f));
+       GINAC_ASSERT(is_a<su3f>(i.op(0)));
 
        // Numeric evaluation
        if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
@@ -298,10 +307,10 @@ ex su3f::eval_indexed(const basic & i) const
 /** Contraction of generator with something else. */
 bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(self->nops() == 2);
-       GINAC_ASSERT(is_ex_of_type(self->op(0), su3t));
+       GINAC_ASSERT(is_a<su3t>(self->op(0)));
        unsigned char rl = ex_to<color>(*self).get_representation_label();
 
        if (is_ex_exactly_of_type(other->op(0), su3t)) {
@@ -348,10 +357,10 @@ bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exve
 /** Contraction of an indexed symmetric structure constant with something else. */
 bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(self->nops() == 4);
-       GINAC_ASSERT(is_ex_of_type(self->op(0), su3d));
+       GINAC_ASSERT(is_a<su3d>(self->op(0)));
 
        if (is_ex_exactly_of_type(other->op(0), su3d)) {
 
@@ -407,10 +416,10 @@ bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exve
 /** Contraction of an indexed antisymmetric structure constant with something else. */
 bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(self->nops() == 4);
-       GINAC_ASSERT(is_ex_of_type(self->op(0), su3f));
+       GINAC_ASSERT(is_a<su3f>(self->op(0)));
 
        if (is_ex_exactly_of_type(other->op(0), su3f)) { // f*d is handled by su3d class
 
@@ -565,7 +574,7 @@ ex color_trace(const ex & e, unsigned char rl)
 
                        exvector v1;
                        v1.reserve(num - 2);
-                       for (int i=0; i<num-2; i++)
+                       for (unsigned i=0; i<num-2; i++)
                                v1.push_back(e.op(i));
 
                        exvector v2 = v1;