[GiNaC-list] Equal indexed expressions

Vladimir Kisil kisilv at maths.leeds.ac.uk
Mon Apr 25 20:04:29 CEST 2005


		Dear Alexei,

		Thanks for the explanations. I added to your code just two lines
  at the end:

#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;

int main(int argc, char** argv)
{
	varidx i(symbol("i"), 2);
	varidx j(symbol("j"), 2);

	matrix mink2_matr(2, 2, lst(-1, 0, 0, 1));
	matrix a(1, 2, lst(symbol("a0"), symbol("a1")));

	ex test1 = indexed(mink2_matr, i, i)*indexed(a, i);
	ex test2 = indexed(mink2_matr, j.toggle_variance(), i)*indexed(a, j);

	cout << test1 << " = " << test1.simplify_indexed() << endl;
	cout << test2 << " = " << test2.simplify_indexed() << endl;
	cout << "test1 substituted = " << test1.simplify_indexed().subs(i == varidx(0, 2)) << endl;
	cout << "test2 substituted = " << test2.simplify_indexed().subs(i == varidx(0, 2)) << endl;
	return 0;
}

  and the output now becomes:

[[a0,a1]]~i*[[-1,0],[0,1]]~i~i = [[a0,a1]]~i*[[-1,0],[0,1]]~i~i
[[a0,a1]]~j*[[-1,0],[0,1]].j~i = [[-a0,a1]]~i
test1 substituted = -a0
test2 substituted = -a0

  i.e., the initial difference between objects disappeared after the
  substitution was made. Should it be classified as a bug? I would
  prefer if not all objects with indexes in GiNaC will be necessarily a
  tensors.

  I had already a code which expand dummy-index summations in order to
  see "equality" (in non-tensor sense) similar to above, but I wish to
  check, that this cannot be already done by some standard tools.

  Thanks,
  Vladimir
-- 
Vladimir V. Kisil     email: kisilv at maths.leeds.ac.uk
--                      www: http://maths.leeds.ac.uk/~kisilv/




More information about the GiNaC-list mailing list