]> www.ginac.de Git - ginac.git/commitdiff
added missing minimal_dim() from 1.1 branch
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Tue, 21 Jan 2003 23:06:28 +0000 (23:06 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Tue, 21 Jan 2003 23:06:28 +0000 (23:06 +0000)
ginac/clifford.cpp
ginac/idx.cpp
ginac/idx.h

index b12e385ce4f03f2ca6f9bc7d6fd09342f5f6ef28..352ee194e99e001271900ee23952dec8cd5d271f 100644 (file)
@@ -208,10 +208,11 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
        GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(is_a<diracgamma>(self->op(0)));
        unsigned char rl = ex_to<clifford>(*self).get_representation_label();
        GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(is_a<diracgamma>(self->op(0)));
        unsigned char rl = ex_to<clifford>(*self).get_representation_label();
+
        ex dim = ex_to<idx>(self->op(1)).get_dim();
        ex dim = ex_to<idx>(self->op(1)).get_dim();
+       if (other->nops() > 1)
+               dim = minimal_dim(dim, ex_to<idx>(self->op(1)).get_dim());
 
 
-      if (other->nops() > 1)
-              dim = minimal_dim(dim, ex_to<idx>(self->op(1)).get_dim());
        if (is_a<clifford>(*other)) {
 
                // Contraction only makes sense if the represenation labels are equal
        if (is_a<clifford>(*other)) {
 
                // Contraction only makes sense if the represenation labels are equal
index 503a74ace174f6ab32c03a07bea7c3b9236dbb0d..82052d88f45d36a17db90129682c5861779b586f 100644 (file)
@@ -449,12 +449,7 @@ ex idx::replace_dim(const ex & new_dim) const
 
 ex idx::minimal_dim(const idx & other) const
 {
 
 ex idx::minimal_dim(const idx & other) const
 {
-       if (dim.is_equal(other.dim) || dim < other.dim || (is_exactly_a<numeric>(dim) && is_a<symbol>(other.dim)))
-               return dim;
-       else if (dim > other.dim || (is_a<symbol>(dim) && is_exactly_a<numeric>(other.dim)))
-               return other.dim;
-       else
-               throw (std::runtime_error("idx::minimal_dim: index dimensions cannot be ordered"));
+       return GiNaC::minimal_dim(dim, other.dim);
 }
 
 ex varidx::toggle_variance(void) const
 }
 
 ex varidx::toggle_variance(void) const
@@ -545,4 +540,14 @@ void find_free_and_dummy(exvector::const_iterator it, exvector::const_iterator i
                out_free.push_back(*last);
 }
 
                out_free.push_back(*last);
 }
 
+ex minimal_dim(const ex & dim1, const ex & dim2)
+{
+       if (dim1.is_equal(dim2) || dim1 < dim2 || (is_exactly_a<numeric>(dim1) && is_a<symbol>(dim2)))
+               return dim1;
+       else if (dim1 > dim2 || (is_a<symbol>(dim1) && is_exactly_a<numeric>(dim2)))
+               return dim2;
+       else
+               throw (std::runtime_error("minimal_dim(): index dimensions cannot be ordered"));
+}
+
 } // namespace GiNaC
 } // namespace GiNaC
index ecc6f468439bb7c25d9fc12b2cdcfcd2077bc711..3811a4efe400123bc1d0f63303b87ec36ef3fc7b 100644 (file)
@@ -263,6 +263,11 @@ inline unsigned count_free_indices(const exvector & v)
        return free_indices.size();
 }
 
        return free_indices.size();
 }
 
+/** Return the minimum of two index dimensions. If this is undecidable,
+ *  throw an exception. Numeric dimensions are always considered "smaller"
+ *  than symbolic dimensions. */
+ex minimal_dim(const ex & dim1, const ex & dim2);
+
 } // namespace GiNaC
 
 #endif // ndef __GINAC_IDX_H__
 } // namespace GiNaC
 
 #endif // ndef __GINAC_IDX_H__