* Here we test manipulations on GiNaC's indexed objects. */
/*
- * GiNaC Copyright (C) 1999-2002 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
return 0;
}
-static unsigned delta_check(void)
+static unsigned delta_check()
{
// checks identities of the delta tensor
return result;
}
-static unsigned metric_check(void)
+static unsigned metric_check()
{
// checks identities of the metric tensor
return result;
}
-static unsigned epsilon_check(void)
+static unsigned epsilon_check()
{
// checks identities of the epsilon tensor
return result;
}
-static unsigned symmetry_check(void)
+DECLARE_FUNCTION_2P(symm_fcn)
+REGISTER_FUNCTION(symm_fcn, set_symmetry(sy_symm(0, 1)));
+DECLARE_FUNCTION_2P(anti_fcn)
+REGISTER_FUNCTION(anti_fcn, set_symmetry(sy_anti(0, 1)));
+
+static unsigned symmetry_check()
{
// check symmetric/antisymmetric objects
unsigned result = 0;
idx i(symbol("i"), 3), j(symbol("j"), 3), k(symbol("k"), 3), l(symbol("l"), 3);
- symbol A("A"), B("B");
+ symbol A("A"), B("B"), C("C");
ex e;
result += check_equal(indexed(A, sy_symm(), i, j), indexed(A, sy_symm(), j, i));
result += check_equal(symmetrize(e), 0);
result += check_equal(antisymmetrize(e), e);
+ e = (indexed(A, sy_anti(), i, j, k, l) * (indexed(B, j) * indexed(C, k) + indexed(B, k) * indexed(C, j)) + indexed(B, i, l)).expand();
+ result += check_equal_simplify(e, indexed(B, i, l));
+
+ result += check_equal(symm_fcn(0, 1) + symm_fcn(1, 0), 2*symm_fcn(0, 1));
+ result += check_equal(anti_fcn(0, 1) + anti_fcn(1, 0), 0);
+ result += check_equal(anti_fcn(0, 0), 0);
+
return result;
}
-static unsigned scalar_product_check(void)
+static unsigned scalar_product_check()
{
// check scalar product replacement
return result;
}
-static unsigned edyn_check(void)
+static unsigned edyn_check()
{
// Relativistic electrodynamics
// Lorentz transformation matrix (boost along x axis)
matrix L(4, 4);
- L(0, 0) = gamma;
- L(0, 1) = -beta*gamma;
- L(1, 0) = -beta*gamma;
- L(1, 1) = gamma;
- L(2, 2) = 1; L(3, 3) = 1;
+ L = gamma, -beta*gamma, 0, 0,
+ -beta*gamma, gamma, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1;
// Electromagnetic field tensor
- matrix F(4, 4, lst(
- 0, -Ex, -Ey, -Ez,
+ matrix F(4, 4);
+ F = 0, -Ex, -Ey, -Ez,
Ex, 0, -Bz, By,
Ey, Bz, 0, -Bx,
- Ez, -By, Bx, 0
- ));
+ Ez, -By, Bx, 0;
// Indices
symbol s_mu("mu"), s_nu("nu"), s_rho("rho"), s_sigma("sigma");
return result;
}
-static unsigned spinor_check(void)
+static unsigned spinor_check()
{
// check identities of the spinor metric
return result;
}
-static unsigned dummy_check(void)
+static unsigned dummy_check()
{
// check dummy index renaming/repositioning
return result;
}
-unsigned exam_indexed(void)
+unsigned exam_indexed()
{
unsigned result = 0;