# Can substitution rules be compiled?

I am thinking of having a custom multiplication operation CenterDot[A,B] for non-commutative operators, and some rules that should commute the operators to a desired ordering. The calculation would be very time intensive, while manipulations would just be trivial swapping of entries and addition of other entries. Therefore, I wonder if there is any (perhaps hacky?) way to Compile a code of this type in Mathematica? Thanks for any suggestion!

• Let's say you could compile it. You are aware of the fact that a compiled function only takes numerical arguments of a specific, pre-determined type, yes? Can you provide the code for CenterDot and a small example on how to use it? – halirutan Dec 6 '17 at 9:13
• @halirutan Yes, now I'm thinking of some way to only use lists and integers as labels, since AppendTo is compilable. I'll have to think more about it. – Kagaratsch Dec 6 '17 at 14:48
• When you have a minimal example that works without compiling, then we can have a look at it and discuss if it is compilable. – halirutan Dec 6 '17 at 15:15
• Perhaps Dispatch would be useful? – WReach Dec 6 '17 at 15:45
• @WReach It is indeed interesting. Unfortunately it does not appear in the list of compilable functions though. mathematica.stackexchange.com/questions/1096/… – Kagaratsch Dec 6 '17 at 17:37