如何将符号张量与给定了分量的张量正确相加?
mathematica吧
全部回复
仅看楼主
level 1
eEEee 楼主
如图,首先约定了v1 v2都是四维向量,这时v1和v2的张量积应该是一个二阶张量,TensorRank也能正确给出2。但是这时候试图将v1⊗v2与给定的4×4矩阵相加,发现v1⊗v2被当做数而非4×4矩阵加在了每个分量上。应该如何让mma将这个当做
正确的
矩阵加法?
2023年12月11日 10点12分 1
level 1
eEEee 楼主
补代码
In[77]:= $Assumptions =
v1 \[Element] Vectors[4] && v2 \[Element] Vectors[4]
Out[77]=
v1 \[Element] Vectors[4, Complexes] &&
v2 \[Element] Vectors[4, Complexes]
In[78]:= TensorDimensions[TensorProduct[v1, v2]]
Out[78]= {4, 4}
In[79]:= TensorProduct[v1, v2] + DiagonalMatrix[{1, 2, 3, 4}]
Out[79]= {{1 + v1\[TensorProduct]v2, v1\[TensorProduct]v2,
v1\[TensorProduct]v2, v1\[TensorProduct]v2}, {v1\[TensorProduct]v2,
2 + v1\[TensorProduct]v2, v1\[TensorProduct]v2,
v1\[TensorProduct]v2}, {v1\[TensorProduct]v2, v1\[TensorProduct]v2,
3 + v1\[TensorProduct]v2,
v1\[TensorProduct]v2}, {v1\[TensorProduct]v2, v1\[TensorProduct]v2,
v1\[TensorProduct]v2, 4 + v1\[TensorProduct]v2}}
2023年12月11日 10点12分 2
吧务
level 10
符号张量和列表的混合运算目前应该没简单办法。
2023年12月13日 09点12分 3
1