]> www.ginac.de Git - ginac.git/commitdiff
Add proper functions to make clifford_bar() and clifford_star().
authorVladimir Kisil <kisilv@maths.leeds.ac.uk>
Thu, 11 Aug 2016 18:47:08 +0000 (20:47 +0200)
committerRichard Kreckel <kreckel@ginac.de>
Thu, 11 Aug 2016 18:48:02 +0000 (20:48 +0200)
Previously operations clifford_bar() and clifford_star() called
conjugate() method. This results in reversion of all non-commutative
entries (not only Clifford units) and produced complex conjugation
of all non-real items. The new routine operates on Clifford units only.

check/exam_clifford.cpp
doc/tutorial/ginac.texi
ginac/clifford.cpp
ginac/clifford.h

index 6b1f53f8c4a5bca1de13dde74b50b43b4b1f39c1..fc58c9f0511e59671edb6f9911694e8db75a1d9b 100644 (file)
@@ -542,12 +542,49 @@ static unsigned clifford_check8()
 {
        unsigned result = 0;
 
-       realsymbol a("a");
+       realsymbol a("a"), b("b"), x("x");
        varidx mu(symbol("mu", "\\mu"), 1);
 
        ex e = clifford_unit(mu, diag_matrix({-1})), e0 = e.subs(mu==0);
        result += ( exp(a*e0)*e0*e0 == -exp(e0*a) ) ? 0 : 1;
 
+       ex P = color_T(idx(a,8))*color_T(idx(b,8))*(x*dirac_ONE()+sqrt(x-1)*e0);
+       ex P_prime = color_T(idx(a,8))*color_T(idx(b,8))*(x*dirac_ONE()-sqrt(x-1)*e0);
+
+       result += check_equal(clifford_prime(P), P_prime);
+       result += check_equal(clifford_star(P), P);
+       result += check_equal(clifford_bar(P), P_prime);
+
+       return result;
+}
+
+static unsigned clifford_check9()
+{
+       unsigned result = 0;
+
+       realsymbol a("a"), b("b"), x("x");;
+       varidx mu(symbol("mu", "\\mu"), 4),  nu(symbol("nu", "\\nu"), 4);
+
+       ex e = clifford_unit(mu, lorentz_g(mu, nu));
+       ex e0 = e.subs(mu==0);
+       ex e1 = e.subs(mu==1);
+       ex e2 = e.subs(mu==2);
+       ex e3 = e.subs(mu==3);
+       ex one = dirac_ONE();
+
+       ex P = color_T(idx(a,8))*color_T(idx(b,8))
+              *(x*one+sqrt(x-1)*e0+sqrt(x-2)*e0*e1 +sqrt(x-3)*e0*e1*e2 +sqrt(x-4)*e0*e1*e2*e3);
+       ex P_prime = color_T(idx(a,8))*color_T(idx(b,8))
+              *(x*one-sqrt(x-1)*e0+sqrt(x-2)*e0*e1 -sqrt(x-3)*e0*e1*e2 +sqrt(x-4)*e0*e1*e2*e3);
+       ex P_star = color_T(idx(a,8))*color_T(idx(b,8))
+              *(x*one+sqrt(x-1)*e0+sqrt(x-2)*e1*e0 +sqrt(x-3)*e2*e1*e0 +sqrt(x-4)*e3*e2*e1*e0);
+       ex P_bar = color_T(idx(a,8))*color_T(idx(b,8))
+              *(x*one-sqrt(x-1)*e0+sqrt(x-2)*e1*e0 -sqrt(x-3)*e2*e1*e0 +sqrt(x-4)*e3*e2*e1*e0);
+
+       result += check_equal(clifford_prime(P), P_prime);
+       result += check_equal(clifford_star(P), P_star);
+       result += check_equal(clifford_bar(P), P_bar);
+
        return result;
 }
 
@@ -618,6 +655,8 @@ unsigned exam_clifford()
 
        result += clifford_check8(); cout << '.' << flush;
 
+       result += clifford_check9(); cout << '.' << flush;
+
        return result;
 }
 
index b69455d7104f5aeed36be8b6ae87a44a45e815b1..804e29db4a5b0d382d290cef7a38e95b4cf7805a 100644 (file)
@@ -3486,14 +3486,13 @@ There are several functions for (anti-)automorphisms of Clifford algebras:
 
 @example
     ex clifford_prime(const ex & e)
-    inline ex clifford_star(const ex & e) @{ return e.conjugate(); @}
-    inline ex clifford_bar(const ex & e) @{ return clifford_prime(e.conjugate()); @}
+    inline ex clifford_star(const ex & e)
+    inline ex clifford_bar(const ex & e)
 @end example
 
 The automorphism of a Clifford algebra @code{clifford_prime()} simply
 changes signs of all Clifford units in the expression. The reversion
-of a Clifford algebra @code{clifford_star()} coincides with the
-@code{conjugate()} method and effectively reverses the order of Clifford
+of a Clifford algebra @code{clifford_star()} reverses the order of Clifford
 units in any product. Finally the main anti-automorphism
 of a Clifford algebra @code{clifford_bar()} is the composition of the
 previous two, i.e. it makes the reversion and changes signs of all Clifford units
index 57d6ce6d1e725c215c654f6e558ea9f24a5b1c17..311ef216d23a5e7bd90261d5c0c80abad77e7809 100644 (file)
@@ -1087,6 +1087,47 @@ next_sym:        ;
        }
 }
 
+ex clifford_star_bar(const ex & e, bool do_bar, unsigned options)
+{
+       pointer_to_map_function_2args<bool, unsigned> fcn(clifford_star_bar, do_bar, options | 1);
+
+       // is a child, no need to expand
+       ex e1= (options & 1 ? e : e.expand());
+
+       if (is_a<ncmul>(e1) ) { // reversing order of clifford units
+               exvector ev, cv;
+               ev.reserve(e1.nops());
+               cv.reserve(e1.nops());
+               // separate clifford and non-clifford entries
+               for (int i= 0; i < e1.nops(); ++i) {
+                       if (is_a<clifford>(e1.op(i)) && is_a<cliffordunit>(e1.op(i).op(0)))
+                               cv.push_back(e1.op(i));
+                       else
+                               ev.push_back(e1.op(i));
+               }
+               for (auto i=cv.rbegin(); i!=cv.rend(); ++i) { // reverse order of Clifford units
+                       ev.push_back(i->conjugate());
+               }
+               // For clifford_bar an odd number of clifford units reverts the sign
+               if (do_bar && (cv.size() % 2 == 1))
+                       return -dynallocate<ncmul>(std::move(ev));
+               else
+                       return dynallocate<ncmul>(std::move(ev));
+       } else if (is_a<clifford>(e1) && is_a<cliffordunit>(e1.op(0))) {
+               if (do_bar)
+                       return -e;
+               else
+                       return e;
+       } else if (is_a<power>(e1)) {
+               // apply the procedure to the base of a power
+               return pow(clifford_star_bar(e1.op(0), do_bar, 0), e1.op(1));
+       } else if (is_a<add>(e1) || is_a<mul>(e1) || e.info(info_flags::list)) {
+               // recurse into subexpressions
+               return e1.map(fcn);
+       } else  // nothing meaningful can be done
+               return e;
+}
+
 ex clifford_prime(const ex & e)
 {
        pointer_to_map_function fcn(clifford_prime);
index 9708b0b6813dd750bf458e2ca26303cf5d5f17e7..0402f9305655a96087e38c01ab1aa07c4d6dbce4 100644 (file)
@@ -282,12 +282,16 @@ ex canonicalize_clifford(const ex & e);
  *  clifford units. */
 ex clifford_prime(const ex & e);
 
+/** An auxillary function performing clifford_star() and clifford_bar().*/
+ex clifford_star_bar(const ex & e, bool do_bar, unsigned options);
+
 /** Main anti-automorphism of the Clifford algebra: makes reversion
  *  and changes signs of all clifford units. */
-inline ex clifford_bar(const ex & e) { return clifford_prime(e.conjugate()); }
+inline ex clifford_bar(const ex & e) { return clifford_star_bar(e, true, 0); }
 
-/** Reversion of the Clifford algebra, coincides with the conjugate(). */
-inline ex clifford_star(const ex & e) { return e.conjugate(); }
+/** Reversion of the Clifford algebra, reverse the order of all clifford units
+ *  in ncmul. */
+inline ex clifford_star(const ex & e) { return clifford_star_bar(e, false, 0); }
 
 /** Replaces dirac_ONE's (with a representation_label no less than rl) in e with 1.
  *  For the default value rl = 0 remove all of them. Aborts if e contains any