Tr
Usage
• Tr[list]求矩阵或张量list的迹。
• Tr[list, f]求一个广义迹,代替Plus,结合具有f 的项。
• Tr[list, f, n]向下到list中的第n层。
Notes
• Tr[list]求list[[i, i, ... ]]中的对角元素的和。 • Tr 对矩阵、方阵和张量使用。 • 参见 Mathematica 全书 : 节 3.7.7.
Further Examples
This gives the trace of a x matrix.
In[1]:=
|
Out[1]=
|
This gives a generalized trace of the same matrix.
In[2]:=
|
Out[2]=
|
This gives another generalized trace.
In[3]:=
|
In[4]:=
|
Out[4]=
|
Here is a tensor.
In[5]:=
|
Out[5]//MatrixForm=
|
Here are its dimensions.
In[6]:=
|
Out[6]=
|
This gives the trace.
In[7]:=
|
Out[7]=
|
This gives a generalized trace.
In[8]:=
|
Out[8]=
|
This gives a generalized trace down to level .
In[9]:=
|
Out[9]=
|
In[10]:=
|
|