Inner

Inner[f, list1, list2, g]
is a generalization of Dot in which f plays the role of multiplication and g of addition.

DetailsDetails

  • Inner[f, {{a, b}, {c, d}}, {x, y}, g]->{g[f[a, x], f[b, y]], g[f[c, x], f[d, y]]}.
  • Like Dot, Inner effectively contracts the last index of the first tensor with the first index of the second tensor. Applying Inner to a rank r tensor and a rank s tensor gives a rank tensor.
  • Inner[f, list1, list2] uses Plus for g.
  • Inner[f, list1, list2, g, n] contracts index n of the first tensor with the first index of the second tensor.
  • The heads of and must be the same, but need not necessarily be List. »

ExamplesExamplesopen allclose all

Basic Examples (3)Basic Examples (3)

Compute the "inner f" of two lists, with "plus operation" g:

In[1]:=
Click for copyable input
Out[1]=

Compute a generalized inner product of a matrix and a vector:

In[1]:=
Click for copyable input
Out[1]=

Use familiar operations:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
New in 1
New to Mathematica? Find your learning path »
Have a question? Ask support »