is a generalization of Dot in which f plays the role of multiplication and g of addition.
- 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 list1 and list2 must be the same, but need not necessarily be List. »
Examplesopen allclose all
Basic Examples (3)
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:
Generalized inner product of two matrices:
Inner product of a matrix with a vector:
Inner product of a vector with a matrix:
Hermitian inner product of two vectors:
Check this is the same as using Dot and conjugating the second vector:
Generalizations & Extensions (2)
Contract over the first index of the first matrix:
Inner works with heads other than List:
Boolean (inner) product:
Block matrix (inner) product:
The divergence of a vector field is an inner differentiation:
Applying the functions in a list to corresponding arguments:
Properties & Relations (2)
This gives the scalar product of two vectors:
This does the same thing:
Combining the products with List gives the same result as MapThread: