[GiNaC-devel] lst_to_clifford() and clifford_to_lst() patch

Vladimir Kisil kisilv at maths.leeds.ac.uk
Mon Aug 13 15:23:14 CEST 2007


		Apologies, for resubmission---the correct patch should amend one
  more line. It is attached to this mail.
-- 
Vladimir V. Kisil     email: kisilv at maths.leeds.ac.uk
--                      www: http://maths.leeds.ac.uk/~kisilv/
-------------- next part --------------
Index: doc/tutorial/ginac.texi
===================================================================
RCS file: /home/cvs/GiNaC/doc/tutorial/ginac.texi,v
retrieving revision 1.197
diff -u -r1.197 ginac.texi
--- doc/tutorial/ginac.texi	2 Aug 2007 14:56:44 -0000	1.197
+++ doc/tutorial/ginac.texi	13 Aug 2007 13:20:46 -0000
@@ -3401,8 +3401,20 @@
 with @samp{e.k}
 directly supplied in the second form of the procedure. In the first form
 the Clifford unit @samp{e.k} is generated by the call of
- at code{clifford_unit(mu, metr, rl)}. The previous code may be rewritten
-with the help of @code{lst_to_clifford()} as follows
+ at code{clifford_unit(mu, metr, rl)}. 
+ at cindex pseudo-vector
+If the number of components supplied
+by @code{v} exceeds the dimensionality of the Clifford unit @code{e} by
+1 then function @code{lst_to_clifford()} uses the following
+pseudo-vector representation: 
+ at tex
+$v^0 {\bf 1} + v^1 e_0 + v^2 e_1 + ... + v^{n+1} e_n$
+ at end tex
+ at ifnottex
+ at samp{v~0 ONE + v~1 e.0 + v~2 e.1 + ... + v~[n+1] e.n}
+ at end ifnottex
+
+The previous code may be rewritten with the help of @code{lst_to_clifford()} as follows
 
 @example
 @{
@@ -3432,17 +3444,25 @@
 @ifnottex
 @samp{v = (v~0, v~1, ..., v~n)} 
 @end ifnottex
-such that 
+such that the expression is either vector 
 @tex
 $e = v^0 c_0 + v^1 c_1 + ... + v^n c_n$
 @end tex
 @ifnottex
 @samp{e = v~0 c.0 + v~1 c.1 + ... + v~n c.n}
 @end ifnottex
-with respect to the given Clifford units @code{c} and with none of the
- at samp{v~k} containing Clifford units @code{c} (of course, this
+or pseudo-vector 
+ at tex
+$v^0 {\bf 1} + v^1 e_0 + v^2 e_1 + ... + v^{n+1} e_n$
+ at end tex
+ at ifnottex
+ at samp{v~0 ONE + v~1 e.0 + v~2 e.1 + ... + v~[n+1] e.n}
+ at end ifnottex
+with respect to the given Clifford units @code{c}. Here none of the
+ at samp{v~k} should contain Clifford units @code{c} (of course, this
 may be impossible). This function can use an @code{algebraic} method
-(default) or a symbolic one. With the @code{algebraic} method the @samp{v~k} are calculated as
+(default) or a symbolic one. With the @code{algebraic} method the
+ at samp{v~k} are calculated as 
 @tex
 $(e c_k + c_k e)/c_k^2$. If $c_k^2$
 @end tex
Index: ginac/clifford.cpp
===================================================================
RCS file: /home/cvs/GiNaC/ginac/clifford.cpp,v
retrieving revision 1.102
diff -u -r1.102 clifford.cpp
--- ginac/clifford.cpp	1 Aug 2007 14:27:25 -0000	1.102
+++ ginac/clifford.cpp	13 Aug 2007 13:20:46 -0000
@@ -1183,13 +1183,20 @@
 			if (min == 1) {
 				if (dim == max)
 					return indexed(v, mu_toggle) * e;
-				else
+				else if (max - dim == 1) {
+					if (ex_to<matrix>(v).cols() > ex_to<matrix>(v).rows())
+						return v.op(0) * dirac_ONE(ex_to<clifford>(e).get_representation_label()) + indexed(sub_matrix(ex_to<matrix>(v), 0, 1, 1, dim), mu_toggle) * e;
+					else 
+						return v.op(0) * dirac_ONE(ex_to<clifford>(e).get_representation_label()) + indexed(sub_matrix(ex_to<matrix>(v), 1, dim, 0, 1), mu_toggle) * e;
+ 				} else
 					throw(std::invalid_argument("lst_to_clifford(): dimensions of vector and clifford unit mismatch"));
 			} else
 				throw(std::invalid_argument("lst_to_clifford(): first argument should be a vector (nx1 or 1xn matrix)"));
 		} else if (v.info(info_flags::list)) {
 			if (dim == ex_to<lst>(v).nops())
 				return indexed(matrix(dim, 1, ex_to<lst>(v)), mu_toggle) * e;
+			else if (ex_to<lst>(v).nops() - dim == 1)
+				return v.op(0) * dirac_ONE(ex_to<clifford>(e).get_representation_label()) + indexed(sub_matrix(matrix(dim+1, 1, ex_to<lst>(v)), 1, dim, 0, 1), mu_toggle) * e;
 			else
 				throw(std::invalid_argument("lst_to_clifford(): list length and dimension of clifford unit mismatch"));
 		} else
@@ -1274,19 +1281,28 @@
 				or (not is_a<numeric>(pow(c.subs(mu == i, subs_options::no_pattern), 2))))
 				algebraic = false;
 	lst V; 
+	ex v0 = remove_dirac_ONE(canonicalize_clifford(e+clifford_prime(e)).normal())/2;
+	if (not v0.is_zero())
+		V.append(v0);
+	ex e1 = canonicalize_clifford(e - v0 * dirac_ONE(ex_to<clifford>(c).get_representation_label())); 
 	if (algebraic) {
 		for (unsigned int i = 0; i < D; i++) 
 			V.append(remove_dirac_ONE(
-						simplify_indexed(canonicalize_clifford(e * c.subs(mu == i, subs_options::no_pattern) +  c.subs(mu == i, subs_options::no_pattern) * e))
+						simplify_indexed(canonicalize_clifford(e1 * c.subs(mu == i, subs_options::no_pattern) +  c.subs(mu == i, subs_options::no_pattern) * e1))
 						/ (2*pow(c.subs(mu == i, subs_options::no_pattern), 2))));
 	} else {
-		ex e1 = canonicalize_clifford(e);
 		try {
 			for (unsigned int i = 0; i < D; i++) 
 				V.append(get_clifford_comp(e1, c.subs(c.op(1) == i, subs_options::no_pattern)));
 		} catch  (std::exception &p) {
 			/* Try to expand dummy summations to simplify the expression*/
-			e1 = canonicalize_clifford(expand_dummy_sum(e1, true));
+			e1 = canonicalize_clifford(expand_dummy_sum(e, true));
+			V.remove_all();
+			v0 = remove_dirac_ONE(canonicalize_clifford(e1+clifford_prime(e1)).normal())/2;
+			if (not v0.is_zero()) {
+				V.append(v0);
+				e1 = canonicalize_clifford(e1 - v0 * dirac_ONE(ex_to<clifford>(c).get_representation_label())); 
+			}
 			for (unsigned int i = 0; i < D; i++) 
 				V.append(get_clifford_comp(e1, c.subs(c.op(1) == i, subs_options::no_pattern)));
 		}
Index: check/exam_clifford.cpp
===================================================================
RCS file: /home/cvs/GiNaC/check/exam_clifford.cpp,v
retrieving revision 1.36
diff -u -r1.36 exam_clifford.cpp
--- check/exam_clifford.cpp	31 Jan 2007 22:29:19 -0000	1.36
+++ check/exam_clifford.cpp	13 Aug 2007 13:20:46 -0000
@@ -410,13 +410,23 @@
 	result += check_equal(canonicalize_clifford(e), 0);
 
 /* lst_to_clifford() and clifford_inverse()  check*/
-	realsymbol x("x"), y("y"), t("t"), z("z");
+	realsymbol s("s"), t("t"), x("x"), y("y"), z("z");
 
 	ex c = clifford_unit(nu, A, 1);
 	e = lst_to_clifford(lst(t, x, y, z), mu, A, 1) * lst_to_clifford(lst(1, 2, 3, 4), c);
 	e1 = clifford_inverse(e);
 	result += check_equal_simplify_term2((e*e1).simplify_indexed(), dirac_ONE(1));
 
+/* lst_to_clifford() and clifford_to_lst()  check for vectors*/
+	e = lst(t, x, y, z);
+	result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, false), e);
+	result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, true), e);
+
+/* lst_to_clifford() and clifford_to_lst()  check for pseudovectors*/
+	e = lst(s, t, x, y, z);
+	result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, false), e);
+	result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, true), e);
+
 /* Moebius map (both forms) checks for symmetric metrics only */
 	matrix M1(2, 2),  M2(2, 2);
 	c = clifford_unit(nu, A);


More information about the GiNaC-devel mailing list