Is it possible somehow to contract two tensors, say A={{a1,a2,a3},{a4,a5,a6}}
and B={b1,b2,b3}
, where the elements a1
,a2,...,b1,b2
are themselves vectors:
A = {{a1, a2, -a3}, {a4, -a5, a6}, {a7, a8, a9}};
B={b1,b2,b3};
x=TensorProduct[A,B];
TensorContract[x,{1,3}];
(*{a1 b1 + a4 b2 + a7 b3, a2 b1 - a5 b2 + a8 b3, -a3 b1 + a6 b2 + a9 b3} *)
and get instead of the ordinary Times
between elements like a1 b1
the KroneckerProduct[a1,b1]
. A replacement rule like Times->KroneckerProduct
does not work unfortunately, because a minus sign in Mathematica is handled as Times[-1,a5,b2]
. Thus replacing here Times->KroneckerProduct
yields something nonsensible, because -1 is not a tensor.
a1....b3
are not defined as lists - but if you go ahead and define them as lists, likea1= {a11, a12}
etc, then you can't do aKroneckerProduct
like you want to. Do you want to make this substitution at the level on theTensorProduct
or not untilTensorContract
? $\endgroup$