]> www.ginac.de Git - ginac.git/commitdiff
- the tensor returned by metric_tensor() is symmetric
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 21 Mar 2001 21:03:05 +0000 (21:03 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 21 Mar 2001 21:03:05 +0000 (21:03 +0000)
- (c*x)~mu with c being a number automatically gets converted to c*x~mu

ginac/indexed.cpp
ginac/tensor.cpp
ginac/tensor.h

index f5c53a6bb956e6606b125c80a248c840840cb809..4fa4256abfb286b86c95d427efa9a5c8de27c4c8 100644 (file)
@@ -330,10 +330,20 @@ ex indexed::eval(int level) const
        if (level > 1)
                return indexed(symmetry, evalchildren(level));
 
+       const ex &base = seq[0];
+
        // If the base object is 0, the whole object is 0
-       if (seq[0].is_zero())
+       if (base.is_zero())
                return _ex0();
 
+       // If the base object is a product, pull out the numeric factor
+       if (is_ex_exactly_of_type(base, mul) && is_ex_exactly_of_type(base.op(base.nops() - 1), numeric)) {
+               exvector v = seq;
+               ex f = ex_to_numeric(base.op(base.nops() - 1));
+               v[0] = seq[0] / f;
+               return f * thisexprseq(v);
+       }
+
        // Canonicalize indices according to the symmetry properties
        if (seq.size() > 2 && (symmetry != unknown && symmetry != mixed)) {
                exvector v = seq;
@@ -347,7 +357,7 @@ ex indexed::eval(int level) const
        }
 
        // Let the class of the base object perform additional evaluations
-       return seq[0].bp->eval_indexed(*this);
+       return base.bp->eval_indexed(*this);
 }
 
 ex indexed::thisexprseq(const exvector & v) const
index 8440a56c3151af093628db82f8a24ce9ecba1241..0e6b116250e69281283c012650dc674253c2ff97 100644 (file)
@@ -437,7 +437,7 @@ ex metric_tensor(const ex & i1, const ex & i2)
        if (!is_ex_of_type(i1, varidx) || !is_ex_of_type(i2, varidx))
                throw(std::invalid_argument("indices of metric tensor must be of type varidx"));
 
-       return indexed(tensmetric(), i1, i2);
+       return indexed(tensmetric(), indexed::symmetric, i1, i2);
 }
 
 ex lorentz_g(const ex & i1, const ex & i2, bool pos_sig)
index b8a65455f7ea6ae9ba71c031914644980d1c8b51..65c86c45bd5c703407980f390683f2a017f57a92 100644 (file)
@@ -135,9 +135,9 @@ inline const tensor &ex_to_tensor(const ex &e)
  *  @return newly constructed delta tensor */
 ex delta_tensor(const ex & i1, const ex & i2);
 
-/** Create a metric tensor with specified indices. The indices must be of
- *  class varidx or a subclass. A metric tensor with one covariant and one
- *  contravariant index is equivalent to the delta tensor.
+/** Create a symmetric metric tensor with specified indices. The indices
+ *  must be of class varidx or a subclass. A metric tensor with one
+ *  covariant and one contravariant index is equivalent to the delta tensor.
  *
  *  @param i1 First index
  *  @param i2 Second index