Patch for get_dummy_indices
# Dear All, Presently the method get_dummy_indices() has a non-intuitive behaviour that it forgets about variance of indices and return all of them dotted. This is illustrated by the test included after the signature. This can be altered in many they and include a patch to idx.cpp which uses a sorting rule indifferent to variance of indices. If this patch is applied than a small simplification to clifford.cpp can be done as well. Best wishes, Vladimir -- Vladimir V. Kisil email: kisilv@maths.leeds.ac.uk -- www: http://maths.leeds.ac.uk/~kisilv/ ##include <iostream> ##include <ginac/ginac.h> using namespace std; using namespace GiNaC; int main() { varidx mu(symbol("mu"), 4); varidx nu(symbol("nu"), 4, true); symbol A("A"); symbol B("B"); ex e = indexed(A, nu, mu); ex e1 = indexed(B, nu.toggle_variance(), mu.toggle_variance()); lst rl = lst(mu, nu); cout << rl << endl; // -> {~mu,.nu} exvector ind_vec = ex_to<indexed>(e).get_dummy_indices(ex_to<indexed>(e1)); for (exvector::const_iterator it = ind_vec.begin(); it != ind_vec.end(); it++) { cout << ex_to<varidx>(*it) << endl; // -> .nu .mu } return 0; } #
Hi! On Mon, Nov 08, 2004 at 12:29:02PM +0000, Vladimir Kisil wrote:
Presently the method get_dummy_indices() has a non-intuitive behaviour that it forgets about variance of indices and return all of them dotted.
(I stumbled over the word "dotted" here, which is a spinidx feature. I assume you mean "covariant".) This is on purpose. Since dummy indices always come in pairs, GiNaC chooses to return only one element of each pair, in this case the covariant one (arguably, it might make more sense to return the contravariant one as this is the varidx default). If you want to replace both instances of a varidx, it might be sufficient to just replace the index value. Bye, Christian -- / Physics is an algorithm \/ http://www.uni-mainz.de/~bauec002/
"CB" == Christian Bauer <Christian.Bauer@uni-mainz.de> writes:
CB> This is on purpose. Since dummy indices always come in pairs, I meant a case like "a.get_dummy_indices(b)", where my intuitive expectation was that the return value should has the same covariance as in "a". Since this expectation once took a day for me to realise the problem I propose either: 1. Change it. The old and new behaviour can be easily switched by a an optional boolean argument keep_covariance (with a whatever default value) in idx.cpp as follows: 528c539 < shaker_sort(v.begin(), v.end(), ex_is_less(), ex_swap()); ---
if (keep_covariance) shaker_sort(v.begin(), v.end(), idx_is_less(), ex_swap()); else shaker_sort(v.begin(), v.end(), ex_is_less(), ex_swap());
; or 2. Left it as it is already in GiNaC and add somewhere a line of documentation for the feature in indexed.h. (ginac.info does not mention get_dummy_indices() at present). Best, Vladimir -- Vladimir V. Kisil email: kisilv@maths.leeds.ac.uk -- www: http://maths.leeds.ac.uk/~kisilv/
Hi! On Tue, Nov 16, 2004 at 03:00:25PM +0000, Vladimir Kisil wrote:
I meant a case like "a.get_dummy_indices(b)", where my intuitive expectation was that the return value should has the same covariance as in "a".
Well, this functions is supposed to be symmetric: a.get_dummy_indices(b) == b.get_dummy_indices(a).
2. Left it as it is already in GiNaC and add somewhere a line of documentation for the feature in indexed.h.
OK.
(ginac.info does not mention get_dummy_indices() at present).
It's more of an internal function, really... Bye, Christian -- / Physics is an algorithm \/ http://www.uni-mainz.de/~bauec002/
participants (2)
-
Christian Bauer
-
Vladimir Kisil