Skip to main content
1 of 3
jak
  • 950
  • 4
  • 14

TensorContract with KroneckerProduct instead of ordinary Times

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}};
 B={b1,b2,b3};
 x=TensorProduct[A,B];
 TensorContract[x,{1,3}];

and get instead of the ordinary Times between elements like a1b1 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,a3,b2]. Thus replacing here Times->KroneckerProduct yields something nonsensible, because -1 is not a tensor.

jak
  • 950
  • 4
  • 14