ianhinder / Kranc

A Mathematica package for generating code for solving time dependent partial differential equations
http://kranccode.org
GNU General Public License v2.0
28 stars 10 forks source link

Patch Implement DeleteDuplicates breaks thorns with SymmetricDecreasing tensors #41

Closed tbode closed 12 years ago

tbode commented 12 years ago

The last patch to the main branch of Kranc breaks thorns whose Kranc scripts designate a tensor as SymmetricDecreasing. The sorting action included in DeleteDuplicates breaks the order of tensor component declarations in the resulting interface.ccl file for these tensors. Is this really necessary?

ianhinder commented 12 years ago

This patch was added because DeleteDuplicates doesn't exist in Mathematica 6. I found the following from StackOverflow which should work on version 6 and later:

UnsortedUnion[x__List] := Tally[Join@x][[All, 1]]

You could replace the deleteDuplicates function with that. Can you try it and check that it works for you, and then we can commit it? I'd rather not make people upgrade their Mathematica version unless it's really necessary, though we haven't made much of an effort to think about this much so far.

tbode commented 12 years ago

The replacement

avoids the reordering of SymmetricDecreasing tensor components. Thanks.

ianhinder commented 12 years ago

You're welcome! Actually I would probably put this in the definition of deleteDuplicates instead, which is a function which tries to emulate DeleteDuplicates (available in v7 and later).

tbode commented 12 years ago

Works for me. Please push when you can (I don't have write access).

ianhinder commented 12 years ago

I've replaced the definition of deleteDuplicates with the definition of UnsortedUnion above, and verified that this introduces no changes in McLachlan. Committed in 4afe013.