problem with anti-symmetric functions and tensors --> solved?
Hello everybody, I found that the program #include<iostream> #include<ginac/ginac.h> using namespace std; using namespace GiNaC; DECLARE_FUNCTION_2P(f) ex f_eval(const ex&x,const ex&y) { return f(x,y).hold(); } REGISTER_FUNCTION(f,eval_func(f_eval).set_symmetry(sy_anti(0,1))); int main() { cout << f(0,1) << endl; cout << f(1,0) << endl; cout << f(0,0) << endl; } which defines an anti-symmetric function and then tries it with some values, gives as output f(0,1) -f(0,1) f(0,0) The last result is not as expected, since an anti-symmetric function is equal to zero when both arguments are the same. I found that this happens because in the function *canonicalize* in the file symmetry.cpp the value of *sign* (which, as expected, turns out to be zero if the two arguments are the same) is ignored if the variable *something_changed* is *false* (which is the case in the third example because the two arguments are the same and thus already sorted in ascending order). The problem is solved by adding after the line (which appears in the function *canonicalize*) sign *= permutation_sign(first, last, sy_is_less(v), sy_swap(v,something_changed)); the new line if(!sign)return 0; After this my testprogram gives the result f(0,1) -f(0,1) 0 which is what I would have expected in the first place. Note that this also fixes the same problem for anti-symmetric tensors. Greetings, Chris Dams
Hi! On 2002.07.22 17:22 Chris Dams wrote:
I found that this happens because in the function *canonicalize* in the file symmetry.cpp the value of *sign* (which, as expected, turns out to be zero if the two arguments are the same) is ignored if the variable *something_changed* is *false*
Well spotted, thanks! Your fix is in the CVS. Bye, Christian -- / Coding on PowerPC and proud of it \/ http://www.uni-mainz.de/~bauec002/
participants (2)
-
Chris Dams
-
Christian Bauer