Is there a way to change operator precedence for built-in symbols?
I'd like \[TensorProduct]
(which I redefine to KroneckerProduct
) to take precedence after dot, so that the following is true
A.B\[TensorProduct]C.D == (A.B)\[TensorProduct](C.D)
If you enter \[TensorProduct]
using the input alias t*
, then you can override the input alias to produce a TemplateBox
with a SyntaxForm
setting to lower the precedence:
CurrentValue[EvaluationNotebook[], {InputAliases,"t*"}]=TemplateBox[
{},
"TensorProduct",
DisplayFunction->("\[TensorProduct]"&),
InterpretationFunction:>(Sequence["~","TensorProduct","~"]&),
SyntaxForm->"*"
];
Your example (as an image to show the alias in action):
TensorProduct
aHoldAll
attribute and define downvalues (to TensorProduct) when aDot
object appears inTensorProduct
. $\endgroup$\[TensorProduct]
toKroneckerProduct
? $\endgroup$TensorProduct=KroneckerProduct
$\endgroup$CircleTimes = KroneckerProduct
and thenA.B\[CircleTimes]C.D
$\endgroup$