Outer
Usage
• Outer[f, , , ... ] 给出  的一般外积,形成它们中每一个最底层元素的所有可能组合,并反馈它们作为 f 的自变量。
• Outer[f, , , ... , n] 处理为在  中 n 层子列表的分离元素。
• Outer[f, , , ... , , , ... ]处理为在相应的  中  层子列表的分离元素。
Notes
• Outer[Times, , ] 给出外积。
• 应用 Outer给张量  和  的结果是有元素 f[ , ]的张量  。应用 Outer到秩为  和  的两个张量给出秩为  的一个张量。
•  的头必须是相同的,但不必是 List。
•  不必是立方数组。
• 层的规范  必须是整数。
• 如果仅给出了一个单层,假设它应用到所有的  。如果有几个  ,但少于  的数目,在剩下的  中所有的层被使用。
Further Examples
Outer is potentially useful whenever you want to combine each element from one array with each element of another. This gives all possible pairs from the two lists.
In[1]:=
|
Out[1]=
|
You can also combine elements from more than two arrays.
In[2]:=
|
Out[2]=
|
The arrays being combined may be more complicated than simply lists. The outer product of a tensor and a tensor is a tensor.
In[3]:=
|
Out[3]=
|
In[4]:=
|
Out[4]=
|
By given Outer additional numerical arguments, you can make it treat multidimensional tensors as if they were shallower. Here we're combining the first-level entries of tensor1 ({a,b}, etc.) with the second-level entries of tensor2 ({1,2}, etc.), rather than combining a with 1, etc.
In[5]:=
|
Out[5]=
|
In[6]:=
|
|