X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=check%2Fexam_indexed.cpp;h=96f6faa2e4157f4f64bb8a0b2b472e013e434a95;hb=4f71d7035d32e8f74d9b13e0d6a9c0ab4a58062d;hp=b7c12ba2ad2a52d11ac4d613caf3343f83ff5d91;hpb=83a7ee99a947cbbf331018b803ad6be43a9ccd45;p=ginac.git diff --git a/check/exam_indexed.cpp b/check/exam_indexed.cpp index b7c12ba2..96f6faa2 100644 --- a/check/exam_indexed.cpp +++ b/check/exam_indexed.cpp @@ -3,7 +3,7 @@ * Here we test manipulations on GiNaC's indexed objects. */ /* - * GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2020 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 @@ -20,11 +20,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "ginac.h" -using namespace std; using namespace GiNaC; +#include +using namespace std; + static unsigned check_equal(const ex &e1, const ex &e2) { ex e = e1 - e2; @@ -243,18 +244,16 @@ static unsigned edyn_check() symbol Bx("Bx"), By("By"), Bz("Bz"); // Lorentz transformation matrix (boost along x axis) - matrix L(4, 4); - L = gamma, -beta*gamma, 0, 0, - -beta*gamma, gamma, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1; + matrix 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); - F = 0, -Ex, -Ey, -Ez, - Ex, 0, -Bz, By, - Ey, Bz, 0, -Bx, - Ez, -By, Bx, 0; + matrix F = {{ 0, -Ex, -Ey, -Ez}, + {Ex, 0, -Bz, By}, + {Ey, Bz, 0, -Bx}, + {Ez, -By, Bx, 0}}; // Indices symbol s_mu("mu"), s_nu("nu"), s_rho("rho"), s_sigma("sigma"); @@ -266,12 +265,12 @@ static unsigned edyn_check() * indexed(F, rho, sigma)).simplify_indexed(); // Extract transformed electric and magnetic fields - ex Ex_p = e.subs(lst(mu == 1, nu == 0)).normal(); - ex Ey_p = e.subs(lst(mu == 2, nu == 0)).normal(); - ex Ez_p = e.subs(lst(mu == 3, nu == 0)).normal(); - ex Bx_p = e.subs(lst(mu == 3, nu == 2)).normal(); - ex By_p = e.subs(lst(mu == 1, nu == 3)).normal(); - ex Bz_p = e.subs(lst(mu == 2, nu == 1)).normal(); + ex Ex_p = e.subs(lst{mu == 1, nu == 0}).normal(); + ex Ey_p = e.subs(lst{mu == 2, nu == 0}).normal(); + ex Ez_p = e.subs(lst{mu == 3, nu == 0}).normal(); + ex Bx_p = e.subs(lst{mu == 3, nu == 2}).normal(); + ex By_p = e.subs(lst{mu == 1, nu == 3}).normal(); + ex Bz_p = e.subs(lst{mu == 2, nu == 1}).normal(); // Check results result += check_equal(Ex_p, Ex); @@ -284,7 +283,7 @@ static unsigned edyn_check() // Test 2: check energy density and Poynting vector of electromagnetic field // Minkowski metric - ex eta = diag_matrix(lst(1, -1, -1, -1)); + ex eta = diag_matrix(lst{1, -1, -1, -1}); // Covariant field tensor ex F_mu_nu = (indexed(eta, mu.toggle_variance(), rho.toggle_variance()) @@ -293,16 +292,16 @@ static unsigned edyn_check() // Energy-momentum tensor ex T = (-indexed(eta, rho, sigma) * F_mu_nu.subs(s_nu == s_rho) - * F_mu_nu.subs(lst(s_mu == s_nu, s_nu == s_sigma)) + * F_mu_nu.subs(lst{s_mu == s_nu, s_nu == s_sigma}) + indexed(eta, mu.toggle_variance(), nu.toggle_variance()) - * F_mu_nu.subs(lst(s_mu == s_rho, s_nu == s_sigma)) + * F_mu_nu.subs(lst{s_mu == s_rho, s_nu == s_sigma}) * indexed(F, rho, sigma) / 4).simplify_indexed() / (4 * Pi); // Extract energy density and Poynting vector - ex E = T.subs(lst(s_mu == 0, s_nu == 0)).normal(); - ex Px = T.subs(lst(s_mu == 0, s_nu == 1)); - ex Py = T.subs(lst(s_mu == 0, s_nu == 2)); - ex Pz = T.subs(lst(s_mu == 0, s_nu == 3)); + ex E = T.subs(lst{s_mu == 0, s_nu == 0}).normal(); + ex Px = T.subs(lst{s_mu == 0, s_nu == 1}); + ex Py = T.subs(lst{s_mu == 0, s_nu == 2}); + ex Pz = T.subs(lst{s_mu == 0, s_nu == 3}); // Check results result += check_equal(E, (Ex*Ex+Ey*Ey+Ez*Ez+Bx*Bx+By*By+Bz*Bz) / (8 * Pi)); @@ -381,7 +380,7 @@ static unsigned dummy_check() // GiNaC 1.2.1 had a bug here because p.i*p.i -> (p.i)^2 e = indexed(p, i) * indexed(p, i) * indexed(p, j) + indexed(p, j); ex fi = exprseq(e.get_free_indices()); - if (!fi.is_equal(exprseq(j))) { + if (!fi.is_equal(exprseq{j})) { clog << "get_free_indices(" << e << ") erroneously returned " << fi << " instead of (.j)" << endl; ++result;