Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > List Manipulation > Applying Functions to Lists >
Mathematica > Data Manipulation > Handling Arrays of Data > Applying Functions to Lists >

Inner

Inner[f, list1, list2, g]
is a generalization of Dot in which f plays the role of multiplication and g of addition.
  • Inner[f, {{a, b}, {c, d}}, {x, y}, g]LongRightArrow{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 r+s-2 tensor.
  • Inner[f, list1, list2, g, n] contracts index n of the first tensor with the first index of the second tensor.
  • The heads of list1 and list2 must be the same, but need not necessarily be List.  »
Compute the "inner f" of two lists, with "plus operation" g:
Compute a generalized inner product of a matrix and a vector:
Use familiar operations:
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]=
Generalized inner product of two matrices:
Inner product of a matrix with a vector:
Inner product of a vector with a matrix:
Contract over the first index of the first matrix:
Inner works with heads other than List:
The divergence of a vector field is an inner differentiation:
Inner product of two Boolean matrices:
Applying the functions in a list to corresponding arguments:
This gives the scalar product of two vectors:
This does the same thing:
Combining the products with List gives the same result as MapThread:
New in 1
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team