1 /** @file exam_clifford.cpp
3 * Here we test GiNaC's Clifford algebra objects. */
6 * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 using namespace GiNaC;
29 const numeric half(1, 2);
31 static unsigned check_equal(const ex &e1, const ex &e2)
33 ex e = normal(e1 - e2);
35 clog << "(" << e1 << ") - (" << e2 << ") erroneously returned "
36 << e << " instead of 0" << endl;
42 static unsigned check_equal_simplify(const ex &e1, const ex &e2)
44 ex e = normal(simplify_indexed(e1) - e2);
46 clog << "simplify_indexed(" << e1 << ") - (" << e2 << ") erroneously returned "
47 << e << " instead of 0" << endl;
53 static unsigned check_equal_lst(const ex & e1, const ex & e2)
55 for (unsigned int i = 0; i < e1.nops(); i++) {
56 ex e = e1.op(i) - e2.op(i);
57 if (!e.normal().is_zero()) {
58 clog << "(" << e1 << ") - (" << e2 << ") erroneously returned "
59 << e << " instead of 0 (in the entry " << i << ")" << endl;
66 static unsigned check_equal_simplify_term(const ex & e1, const ex & e2, idx & mu)
68 ex e = expand_dummy_sum(normal(simplify_indexed(e1) - e2), true);
70 for (int j=0; j<4; j++) {
74 mu == idx(j, mu.get_dim()),
75 ex_to<varidx>(mu).toggle_variance() == idx(j, mu.get_dim())
77 : lst(mu == idx(j, mu.get_dim()))
79 if (!(canonicalize_clifford(esub).is_zero())) {
80 clog << "simplify_indexed(" << e1 << ") - (" << e2 << ") erroneously returned "
81 << canonicalize_clifford(esub) << " instead of 0 for mu=" << j << endl;
88 static unsigned check_equal_simplify_term2(const ex & e1, const ex & e2)
90 ex e = expand_dummy_sum(normal(simplify_indexed(e1) - e2), true);
91 if (!(canonicalize_clifford(e).is_zero())) {
92 clog << "simplify_indexed(" << e1 << ") - (" << e2 << ") erroneously returned "
93 << canonicalize_clifford(e) << " instead of 0" << endl;
100 static unsigned clifford_check1()
102 // checks general identities and contractions
107 varidx mu(symbol("mu"), dim), nu(symbol("nu"), dim), rho(symbol("rho"), dim);
110 e = dirac_ONE() * dirac_ONE();
111 result += check_equal(e, dirac_ONE());
113 e = dirac_ONE() * dirac_gamma(mu) * dirac_ONE();
114 result += check_equal(e, dirac_gamma(mu));
116 e = dirac_gamma(varidx(2, dim)) * dirac_gamma(varidx(1, dim)) *
117 dirac_gamma(varidx(1, dim)) * dirac_gamma(varidx(2, dim));
118 result += check_equal(e, dirac_ONE());
120 e = dirac_gamma(mu) * dirac_gamma(nu) *
121 dirac_gamma(nu.toggle_variance()) * dirac_gamma(mu.toggle_variance());
122 result += check_equal_simplify(e, pow(dim, 2) * dirac_ONE());
124 e = dirac_gamma(mu) * dirac_gamma(nu) *
125 dirac_gamma(mu.toggle_variance()) * dirac_gamma(nu.toggle_variance());
126 result += check_equal_simplify(e, 2*dim*dirac_ONE()-pow(dim, 2)*dirac_ONE());
128 e = dirac_gamma(nu.toggle_variance()) * dirac_gamma(rho.toggle_variance()) *
129 dirac_gamma(mu) * dirac_gamma(rho) * dirac_gamma(nu);
130 e = e.simplify_indexed().collect(dirac_gamma(mu));
131 result += check_equal(e, pow(2 - dim, 2).expand() * dirac_gamma(mu));
136 static unsigned clifford_check2()
138 // checks identities relating to gamma5
143 varidx mu(symbol("mu"), dim), nu(symbol("nu"), dim);
146 e = dirac_gamma(mu) * dirac_gamma5() + dirac_gamma5() * dirac_gamma(mu);
147 result += check_equal(e, 0);
149 e = dirac_gamma5() * dirac_gamma(mu) * dirac_gamma5() + dirac_gamma(mu);
150 result += check_equal(e, 0);
155 static unsigned clifford_check3()
161 symbol dim("D"), m("m"), q("q"), l("l"), ldotq("ldotq");
162 varidx mu(symbol("mu"), dim), nu(symbol("nu"), dim), rho(symbol("rho"), dim),
163 sig(symbol("sig"), dim), kap(symbol("kap"), dim), lam(symbol("lam"), dim);
167 result += check_equal(dirac_trace(e), 0);
169 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho);
170 result += check_equal(dirac_trace(e), 0);
172 e = dirac_gamma5() * dirac_gamma(mu);
173 result += check_equal(dirac_trace(e), 0);
175 e = dirac_gamma5() * dirac_gamma(mu) * dirac_gamma(nu);
176 result += check_equal(dirac_trace(e), 0);
178 e = dirac_gamma5() * dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho);
179 result += check_equal(dirac_trace(e), 0);
182 sp.add(q, q, pow(q, 2));
183 sp.add(l, l, pow(l, 2));
186 e = pow(m, 2) * dirac_slash(q, dim) * dirac_slash(q, dim);
187 e = dirac_trace(e).simplify_indexed(sp);
188 result += check_equal(e, 4*pow(m, 2)*pow(q, 2));
190 // cyclicity without gamma5
191 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig)
192 - dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(mu);
194 result += check_equal(e, 0);
196 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(kap) * dirac_gamma(lam)
197 - dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(kap) * dirac_gamma(lam) * dirac_gamma(mu);
198 e = dirac_trace(e).expand();
199 result += check_equal(e, 0);
201 // cyclicity of gamma5 * S_4
202 e = dirac_gamma5() * dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig)
203 - dirac_gamma(sig) * dirac_gamma5() * dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho);
205 result += check_equal(e, 0);
207 // non-cyclicity of order D-4 of gamma5 * S_6
208 e = dirac_gamma5() * dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(kap) * dirac_gamma(mu.toggle_variance())
209 + dim * dirac_gamma5() * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(kap);
210 e = dirac_trace(e).simplify_indexed();
211 e = (e / (dim - 4)).normal();
212 result += check_equal(e, 8 * I * lorentz_eps(nu.replace_dim(4), rho.replace_dim(4), sig.replace_dim(4), kap.replace_dim(4)));
214 // one-loop vacuum polarization in QED
215 e = dirac_gamma(mu) *
216 (dirac_slash(l, dim) + dirac_slash(q, 4) + m * dirac_ONE()) *
217 dirac_gamma(mu.toggle_variance()) *
218 (dirac_slash(l, dim) + m * dirac_ONE());
219 e = dirac_trace(e).simplify_indexed(sp);
220 result += check_equal(e, 4*((2-dim)*l*l + (2-dim)*ldotq + dim*m*m).expand());
222 e = dirac_slash(q, 4) *
223 (dirac_slash(l, dim) + dirac_slash(q, 4) + m * dirac_ONE()) *
225 (dirac_slash(l, dim) + m * dirac_ONE());
226 e = dirac_trace(e).simplify_indexed(sp);
227 result += check_equal(e, 4*(2*ldotq*ldotq + q*q*ldotq - q*q*l*l + q*q*m*m).expand());
229 // stuff that had problems in the past
230 ex prop = dirac_slash(q, dim) - m * dirac_ONE();
231 e = dirac_slash(l, dim) * dirac_gamma5() * dirac_slash(l, dim) * prop;
232 e = dirac_trace(dirac_slash(q, dim) * e) - dirac_trace(m * e)
233 - dirac_trace(prop * e);
234 result += check_equal(e, 0);
236 e = (dirac_gamma5() + dirac_ONE()) * dirac_gamma5();
238 result += check_equal(e, 4);
240 // traces with multiple representation labels
241 e = dirac_ONE(0) * dirac_ONE(1) / 16;
242 result += check_equal(dirac_trace(e, 0), dirac_ONE(1) / 4);
243 result += check_equal(dirac_trace(e, 1), dirac_ONE(0) / 4);
244 result += check_equal(dirac_trace(e, 2), e);
245 result += check_equal(dirac_trace(e, lst(0, 1)), 1);
247 e = dirac_gamma(mu, 0) * dirac_gamma(mu.toggle_variance(), 1) * dirac_gamma(nu, 0) * dirac_gamma(nu.toggle_variance(), 1);
248 result += check_equal_simplify(dirac_trace(e, 0), 4 * dim * dirac_ONE(1));
249 result += check_equal_simplify(dirac_trace(e, 1), 4 * dim * dirac_ONE(0));
250 // Fails with new tinfo mechanism because the order of gamme matrices with different rl depends on luck.
251 // TODO: better check.
252 //result += check_equal_simplify(dirac_trace(e, 2), canonicalize_clifford(e)); // e will be canonicalized by the calculation of the trace
253 result += check_equal_simplify(dirac_trace(e, lst(0, 1)), 16 * dim);
258 static unsigned clifford_check4()
260 // simplify_indexed()/dirac_trace() cross-checks
265 varidx mu(symbol("mu"), dim), nu(symbol("nu"), dim), rho(symbol("rho"), dim),
266 sig(symbol("sig"), dim), lam(symbol("lam"), dim);
269 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(mu.toggle_variance());
270 t1 = dirac_trace(e).simplify_indexed();
271 t2 = dirac_trace(e.simplify_indexed());
272 result += check_equal((t1 - t2).expand(), 0);
274 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(mu.toggle_variance()) * dirac_gamma(lam);
275 t1 = dirac_trace(e).simplify_indexed();
276 t2 = dirac_trace(e.simplify_indexed());
277 result += check_equal((t1 - t2).expand(), 0);
279 e = dirac_gamma(sig) * dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(nu.toggle_variance()) * dirac_gamma(mu.toggle_variance());
280 t1 = dirac_trace(e).simplify_indexed();
281 t2 = dirac_trace(e.simplify_indexed());
282 result += check_equal((t1 - t2).expand(), 0);
284 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(mu.toggle_variance()) * dirac_gamma(sig) * dirac_gamma(nu.toggle_variance());
285 t1 = dirac_trace(e).simplify_indexed();
286 t2 = dirac_trace(e.simplify_indexed());
287 result += check_equal((t1 - t2).expand(), 0);
292 static unsigned clifford_check5()
294 // canonicalize_clifford() checks
299 varidx mu(symbol("mu"), dim), nu(symbol("nu"), dim), lam(symbol("lam"), dim);
302 e = dirac_gamma(mu) * dirac_gamma(nu) + dirac_gamma(nu) * dirac_gamma(mu);
303 result += check_equal(canonicalize_clifford(e), 2*dirac_ONE()*lorentz_g(mu, nu));
305 e = (dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(lam)
306 + dirac_gamma(nu) * dirac_gamma(lam) * dirac_gamma(mu)
307 + dirac_gamma(lam) * dirac_gamma(mu) * dirac_gamma(nu)
308 - dirac_gamma(nu) * dirac_gamma(mu) * dirac_gamma(lam)
309 - dirac_gamma(lam) * dirac_gamma(nu) * dirac_gamma(mu)
310 - dirac_gamma(mu) * dirac_gamma(lam) * dirac_gamma(nu)) / 6
311 + lorentz_g(mu, nu) * dirac_gamma(lam)
312 - lorentz_g(mu, lam) * dirac_gamma(nu)
313 + lorentz_g(nu, lam) * dirac_gamma(mu)
314 - dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(lam);
315 result += check_equal(canonicalize_clifford(e), 0);
320 /* We make two identical checks with metrics defined through a matrix in
321 * the cases when used indexes have or have not variance.
322 * To this end we recycle the code through the following macros */
324 template <typename IDX> unsigned clifford_check6(const matrix &A)
328 matrix A_symm(4,4), A2(4, 4);
329 A_symm = A.add(A.transpose()).mul(half);
330 A2 = A_symm.mul(A_symm);
332 IDX v(symbol("v"), 4), nu(symbol("nu"), 4), mu(symbol("mu"), 4),
333 psi(symbol("psi"),4), lam(symbol("lambda"), 4),
334 xi(symbol("xi"), 4), rho(symbol("rho"),4);
335 ex mu_TOGGLE = is_a<varidx>(mu) ? ex_to<varidx>(mu).toggle_variance() : mu;
336 ex nu_TOGGLE = is_a<varidx>(nu) ? ex_to<varidx>(nu).toggle_variance() : nu;
338 = is_a<varidx>(rho) ? ex_to<varidx>(rho).toggle_variance() : rho;
342 /* checks general identities and contractions for clifford_unit*/
343 e = dirac_ONE(2) * clifford_unit(mu, A, 2) * dirac_ONE(2);
344 result += check_equal(e, clifford_unit(mu, A, 2));
346 e = clifford_unit(IDX(2, 4), A) * clifford_unit(IDX(1, 4), A)
347 * clifford_unit(IDX(1, 4), A) * clifford_unit(IDX(2, 4), A);
348 result += check_equal(e, A(1, 1) * A(2, 2) * dirac_ONE());
350 e = clifford_unit(IDX(2, 4), A) * clifford_unit(IDX(1, 4), A)
351 * clifford_unit(IDX(1, 4), A) * clifford_unit(IDX(2, 4), A);
352 result += check_equal(e, A(1, 1) * A(2, 2) * dirac_ONE());
354 e = clifford_unit(nu, A) * clifford_unit(nu_TOGGLE, A);
355 result += check_equal_simplify(e, A.trace() * dirac_ONE());
357 e = clifford_unit(nu, A) * clifford_unit(nu, A);
358 result += check_equal_simplify(e, indexed(A_symm, sy_symm(), nu, nu) * dirac_ONE());
360 e = clifford_unit(nu, A) * clifford_unit(nu_TOGGLE, A) * clifford_unit(mu, A);
361 result += check_equal_simplify(e, A.trace() * clifford_unit(mu, A));
363 e = clifford_unit(nu, A) * clifford_unit(mu, A) * clifford_unit(nu_TOGGLE, A);
365 result += check_equal_simplify_term(e, 2 * indexed(A_symm, sy_symm(), nu_TOGGLE, mu) *clifford_unit(nu, A)-A.trace()*clifford_unit(mu, A), mu);
367 e = clifford_unit(nu, A) * clifford_unit(nu_TOGGLE, A)
368 * clifford_unit(mu, A) * clifford_unit(mu_TOGGLE, A);
369 result += check_equal_simplify(e, pow(A.trace(), 2) * dirac_ONE());
371 e = clifford_unit(mu, A) * clifford_unit(nu, A)
372 * clifford_unit(nu_TOGGLE, A) * clifford_unit(mu_TOGGLE, A);
373 result += check_equal_simplify(e, pow(A.trace(), 2) * dirac_ONE());
375 e = clifford_unit(mu, A) * clifford_unit(nu, A)
376 * clifford_unit(mu_TOGGLE, A) * clifford_unit(nu_TOGGLE, A);
378 result += check_equal_simplify_term2(e, 2*indexed(A_symm, sy_symm(), nu_TOGGLE, mu_TOGGLE) * clifford_unit(mu, A) * clifford_unit(nu, A) - pow(A.trace(), 2)*dirac_ONE());
380 e = clifford_unit(mu_TOGGLE, A) * clifford_unit(nu, A)
381 * clifford_unit(mu, A) * clifford_unit(nu_TOGGLE, A);
383 result += check_equal_simplify_term2(e, 2*indexed(A_symm, nu, mu) * clifford_unit(mu_TOGGLE, A) * clifford_unit(nu_TOGGLE, A) - pow(A.trace(), 2)*dirac_ONE());
385 e = clifford_unit(nu_TOGGLE, A) * clifford_unit(rho_TOGGLE, A)
386 * clifford_unit(mu, A) * clifford_unit(rho, A) * clifford_unit(nu, A);
387 e = e.simplify_indexed().collect(clifford_unit(mu, A));
389 result += check_equal_simplify_term(e, 4* indexed(A_symm, sy_symm(), nu_TOGGLE, rho)*indexed(A_symm, sy_symm(), rho_TOGGLE, mu) *clifford_unit(nu, A)
390 - 2*A.trace() * (clifford_unit(rho, A) * indexed(A_symm, sy_symm(), rho_TOGGLE, mu)
391 + clifford_unit(nu, A) * indexed(A_symm, sy_symm(), nu_TOGGLE, mu)) + pow(A.trace(),2)* clifford_unit(mu, A), mu);
393 e = clifford_unit(nu_TOGGLE, A) * clifford_unit(rho, A)
394 * clifford_unit(mu, A) * clifford_unit(rho_TOGGLE, A) * clifford_unit(nu, A);
395 e = e.simplify_indexed().collect(clifford_unit(mu, A));
397 result += check_equal_simplify_term(e, 4* indexed(A_symm, sy_symm(), nu_TOGGLE, rho)*indexed(A_symm, sy_symm(), rho_TOGGLE, mu) *clifford_unit(nu, A)
398 - 2*A.trace() * (clifford_unit(rho, A) * indexed(A_symm, sy_symm(), rho_TOGGLE, mu)
399 + clifford_unit(nu, A) * indexed(A_symm, sy_symm(), nu_TOGGLE, mu)) + pow(A.trace(),2)* clifford_unit(mu, A), mu);
401 e = clifford_unit(mu, A) * clifford_unit(nu, A) + clifford_unit(nu, A) * clifford_unit(mu, A);
402 result += check_equal(canonicalize_clifford(e), 2*dirac_ONE()*indexed(A_symm, sy_symm(), mu, nu));
404 e = (clifford_unit(mu, A) * clifford_unit(nu, A) * clifford_unit(lam, A)
405 + clifford_unit(nu, A) * clifford_unit(lam, A) * clifford_unit(mu, A)
406 + clifford_unit(lam, A) * clifford_unit(mu, A) * clifford_unit(nu, A)
407 - clifford_unit(nu, A) * clifford_unit(mu, A) * clifford_unit(lam, A)
408 - clifford_unit(lam, A) * clifford_unit(nu, A) * clifford_unit(mu, A)
409 - clifford_unit(mu, A) * clifford_unit(lam, A) * clifford_unit(nu, A)) / 6
410 + indexed(A_symm, sy_symm(), mu, nu) * clifford_unit(lam, A)
411 - indexed(A_symm, sy_symm(), mu, lam) * clifford_unit(nu, A)
412 + indexed(A_symm, sy_symm(), nu, lam) * clifford_unit(mu, A)
413 - clifford_unit(mu, A) * clifford_unit(nu, A) * clifford_unit(lam, A);
414 result += check_equal(canonicalize_clifford(e), 0);
416 /* lst_to_clifford() and clifford_inverse() check*/
417 realsymbol s("s"), t("t"), x("x"), y("y"), z("z");
419 ex c = clifford_unit(nu, A, 1);
420 e = lst_to_clifford(lst(t, x, y, z), mu, A, 1) * lst_to_clifford(lst(1, 2, 3, 4), c);
421 e1 = clifford_inverse(e);
422 result += check_equal_simplify_term2((e*e1).simplify_indexed(), dirac_ONE(1));
424 /* lst_to_clifford() and clifford_to_lst() check for vectors*/
426 result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, false), e);
427 result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, true), e);
429 /* lst_to_clifford() and clifford_to_lst() check for pseudovectors*/
430 e = lst(s, t, x, y, z);
431 result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, false), e);
432 result += check_equal_lst(clifford_to_lst(lst_to_clifford(e, c), c, true), e);
434 /* Moebius map (both forms) checks for symmetric metrics only */
435 matrix M1(2, 2), M2(2, 2);
436 c = clifford_unit(nu, A);
438 e = clifford_moebius_map(0, dirac_ONE(),
439 dirac_ONE(), 0, lst(t, x, y, z), A);
440 /* this is just the inversion*/
443 e1 = clifford_moebius_map(M1, lst(t, x, y, z), A);
444 /* the inversion again*/
445 result += check_equal_lst(e, e1);
447 e1 = clifford_to_lst(clifford_inverse(lst_to_clifford(lst(t, x, y, z), mu, A)), c);
448 result += check_equal_lst(e, e1);
450 e = clifford_moebius_map(dirac_ONE(), lst_to_clifford(lst(1, 2, 3, 4), nu, A),
451 0, dirac_ONE(), lst(t, x, y, z), A);
452 /*this is just a shift*/
453 M2 = dirac_ONE(), lst_to_clifford(lst(1, 2, 3, 4), c),
455 e1 = clifford_moebius_map(M2, lst(t, x, y, z), c);
457 result += check_equal_lst(e, e1);
459 result += check_equal(e, lst(t+1, x+2, y+3, z+4));
461 /* Check the group law for Moebius maps */
462 e = clifford_moebius_map(M1, ex_to<lst>(e1), c);
463 /*composition of M1 and M2*/
464 e1 = clifford_moebius_map(M1.mul(M2), lst(t, x, y, z), c);
465 /* the product M1*M2*/
466 result += check_equal_lst(e, e1);
470 static unsigned clifford_check7(const ex & G, const symbol & dim)
472 // checks general identities and contractions
476 varidx mu(symbol("mu"), dim), nu(symbol("nu"), dim), rho(symbol("rho"), dim),
477 psi(symbol("psi"),dim), lam(symbol("lambda"), dim), xi(symbol("xi"), dim);
480 clifford unit = ex_to<clifford>(clifford_unit(mu, G));
481 ex scalar = unit.get_metric(varidx(0, dim), varidx(0, dim));
483 e = dirac_ONE() * dirac_ONE();
484 result += check_equal(e, dirac_ONE());
486 e = dirac_ONE() * clifford_unit(mu, G) * dirac_ONE();
487 result += check_equal(e, clifford_unit(mu, G));
489 e = clifford_unit(varidx(2, dim), G) * clifford_unit(varidx(1, dim), G)
490 * clifford_unit(varidx(1, dim), G) * clifford_unit(varidx(2, dim), G);
491 result += check_equal(e, dirac_ONE()*pow(scalar, 2));
493 e = clifford_unit(mu, G) * clifford_unit(nu, G)
494 * clifford_unit(nu.toggle_variance(), G) * clifford_unit(mu.toggle_variance(), G);
495 result += check_equal_simplify(e, pow(dim*scalar, 2) * dirac_ONE());
497 e = clifford_unit(mu, G) * clifford_unit(nu, G)
498 * clifford_unit(mu.toggle_variance(), G) * clifford_unit(nu.toggle_variance(), G);
499 result += check_equal_simplify(e, (2*dim - pow(dim, 2))*pow(scalar,2)*dirac_ONE());
501 e = clifford_unit(nu.toggle_variance(), G) * clifford_unit(rho.toggle_variance(), G)
502 * clifford_unit(mu, G) * clifford_unit(rho, G) * clifford_unit(nu, G);
503 e = e.simplify_indexed().collect(clifford_unit(mu, G));
504 result += check_equal(e, pow(scalar*(dim-2), 2).expand() * clifford_unit(mu, G));
506 // canonicalize_clifford() checks, only for symmetric metrics
507 if (is_a<indexed>(ex_to<clifford>(clifford_unit(mu, G)).get_metric()) &&
508 ex_to<symmetry>(ex_to<indexed>(ex_to<clifford>(clifford_unit(mu, G)).get_metric()).get_symmetry()).has_symmetry()) {
509 e = clifford_unit(mu, G) * clifford_unit(nu, G) + clifford_unit(nu, G) * clifford_unit(mu, G);
510 result += check_equal(canonicalize_clifford(e), 2*dirac_ONE()*unit.get_metric(nu, mu));
512 e = (clifford_unit(mu, G) * clifford_unit(nu, G) * clifford_unit(lam, G)
513 + clifford_unit(nu, G) * clifford_unit(lam, G) * clifford_unit(mu, G)
514 + clifford_unit(lam, G) * clifford_unit(mu, G) * clifford_unit(nu, G)
515 - clifford_unit(nu, G) * clifford_unit(mu, G) * clifford_unit(lam, G)
516 - clifford_unit(lam, G) * clifford_unit(nu, G) * clifford_unit(mu, G)
517 - clifford_unit(mu, G) * clifford_unit(lam, G) * clifford_unit(nu, G)) / 6
518 + unit.get_metric(mu, nu) * clifford_unit(lam, G)
519 - unit.get_metric(mu, lam) * clifford_unit(nu, G)
520 + unit.get_metric(nu, lam) * clifford_unit(mu, G)
521 - clifford_unit(mu, G) * clifford_unit(nu, G) * clifford_unit(lam, G);
522 result += check_equal(canonicalize_clifford(e), 0);
524 e = clifford_unit(mu, G) * clifford_unit(nu, G) + clifford_unit(nu, G) * clifford_unit(mu, G);
525 result += check_equal(canonicalize_clifford(e), dirac_ONE()*(unit.get_metric(mu, nu) + unit.get_metric(nu, mu)));
527 e = (clifford_unit(mu, G) * clifford_unit(nu, G) * clifford_unit(lam, G)
528 + clifford_unit(nu, G) * clifford_unit(lam, G) * clifford_unit(mu, G)
529 + clifford_unit(lam, G) * clifford_unit(mu, G) * clifford_unit(nu, G)
530 - clifford_unit(nu, G) * clifford_unit(mu, G) * clifford_unit(lam, G)
531 - clifford_unit(lam, G) * clifford_unit(nu, G) * clifford_unit(mu, G)
532 - clifford_unit(mu, G) * clifford_unit(lam, G) * clifford_unit(nu, G)) / 6
533 + half * (unit.get_metric(mu, nu) + unit.get_metric(nu, mu)) * clifford_unit(lam, G)
534 - half * (unit.get_metric(mu, lam) + unit.get_metric(lam, mu)) * clifford_unit(nu, G)
535 + half * (unit.get_metric(nu, lam) + unit.get_metric(lam, nu)) * clifford_unit(mu, G)
536 - clifford_unit(mu, G) * clifford_unit(nu, G) * clifford_unit(lam, G);
537 result += check_equal(canonicalize_clifford(e), 0);
542 static unsigned clifford_check8()
547 varidx mu(symbol("mu", "\\mu"), 1);
549 ex e = clifford_unit(mu, diag_matrix(lst(-1))), e0 = e.subs(mu==0);
550 result += ( exp(a*e0)*e0*e0 == -exp(e0*a) ) ? 0 : 1;
555 unsigned exam_clifford()
559 cout << "examining clifford objects" << flush;
561 result += clifford_check1(); cout << '.' << flush;
562 result += clifford_check2(); cout << '.' << flush;
563 result += clifford_check3(); cout << '.' << flush;
564 result += clifford_check4(); cout << '.' << flush;
565 result += clifford_check5(); cout << '.' << flush;
567 // anticommuting, symmetric examples
568 result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-1, 1, 1, 1))));
569 result += clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-1, 1, 1, 1))));; cout << '.' << flush;
570 result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-1, -1, -1, -1))))+clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-1, -1, -1, -1))));; cout << '.' << flush;
571 result += clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-1, 1, 1, -1))))+clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-1, 1, 1, -1))));; cout << '.' << flush;
572 result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-1, 0, 1, -1))))+clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-1, 0, 1, -1))));; cout << '.' << flush;
573 result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-3, 0, 2, -1))))+clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-3, 0, 2, -1))));; cout << '.' << flush;
575 realsymbol s("s"), t("t"); // symbolic entries in matric
576 result += clifford_check6<varidx>(ex_to<matrix>(diag_matrix(lst(-1, 1, s, t))))+clifford_check6<idx>(ex_to<matrix>(diag_matrix(lst(-1, 1, s, t))));; cout << '.' << flush;
579 A = 1, 0, 0, 0, // anticommuting, not symmetric, Tr=0
583 result += clifford_check6<varidx>(A)+clifford_check6<idx>(A);; cout << '.' << flush;
585 A = 1, 0, 0, 0, // anticommuting, not symmetric, Tr=2
589 result += clifford_check6<varidx>(A)+clifford_check6<idx>(A);; cout << '.' << flush;
591 A = 1, 0, 0, 0, // not anticommuting, symmetric, Tr=0
595 result += clifford_check6<varidx>(A)+clifford_check6<idx>(A);; cout << '.' << flush;
597 A = 1, 0, 0, 0, // not anticommuting, symmetric, Tr=2
601 result += clifford_check6<varidx>(A)+clifford_check6<idx>(A);; cout << '.' << flush;
603 A = 1, 1, 0, 0, // not anticommuting, not symmetric, Tr=4
607 result += clifford_check6<varidx>(A)+clifford_check6<idx>(A);; cout << '.' << flush;
610 result += clifford_check7(minkmetric(), dim); cout << '.' << flush;
612 varidx chi(symbol("chi"), dim), xi(symbol("xi"), dim);
613 result += clifford_check7(delta_tensor(xi, chi), dim); cout << '.' << flush;
615 result += clifford_check7(lorentz_g(xi, chi), dim); cout << '.' << flush;
617 result += clifford_check7(indexed(-2*minkmetric(), sy_symm(), xi, chi), dim); cout << '.' << flush;
618 result += clifford_check7(-2*delta_tensor(xi, chi), dim); cout << '.' << flush;
620 result += clifford_check8(); cout << '.' << flush;
625 int main(int argc, char** argv)
627 return exam_clifford();