Outer

Outer[f,list1,list2,]

gives the generalized outer product of the listi, forming all possible combinations of the lowestlevel elements in each of them, and feeding them as arguments to f.

Outer[f,list1,list2,,n]

treats as separate elements only sublists at level n in the listi.

Outer[f,list1,list2,,n1,n2,]

treats as separate elements only sublists at level ni in the corresponding listi.

Details

  • Outer[Times,list1,list2] gives an outer product.
  • The result of applying Outer to the tensors Ti1i2...ir and Uj1j2...js is the tensor Vi1i2...irj1j2...js with elements f[Ti1i2...ir,Uj1j2...js]. Applying Outer to two tensors of ranks r and s gives a tensor of rank r+s.
  • The heads of all listi must be the same, but need not necessarily be List. »
  • Outer[f] returns f[].
  • The listi need not necessarily be cuboidal arrays.
  • The specifications ni of levels must be positive integers, or Infinity.
  • If only a single level specification is given, it is assumed to apply to all the listi. If there are several ni, but fewer than the number of listi, the lowestlevel elements in the remaining listi will be used.
  • Outer can be used on SparseArray objects, returning a SparseArray object when possible. »

Examples

open allclose all

Basic Examples  (2)

Outer product of vectors:

Outer product of matrices:

Scope  (4)

Treat nested lists as rank-1 vectors of sublists:

Arrays can be ragged:

Outer product of SparseArray objects:

Generalizations & Extensions  (1)

The head need not be List:

Applications  (6)

Word combinations:

Function combinations:

Complete bipartite graph:

Lower-triangular matrix:

Generate all possible binary trees with nodes from f and leaves from e to depth n:

Apply a function on a tensor product grid:

Show a contour plot of the values and the grid:

Include coordinates:

Make a piecewise polynomial that interpolates the data:

Properties & Relations  (6)

The dimensions of the result are a concatenation of the dimensions of the inputs:

Outer[f] returns f[]:

Distribute forms the same combinations of all elements, but in a flat structure:

KroneckerProduct is a flattened outer product of matrices:

Part effectively uses an outer product when given lists of parts at multiple levels:

Table can also make a generalized outer product from lists:

Possible Issues  (1)

If backgrounds are inconsistent, a generalized outer product may not be sparse:

You can convert it into a SparseArray by choosing a background:

Wolfram Research (1988), Outer, Wolfram Language function, https://reference.wolfram.com/language/ref/Outer.html (updated 2020).

Text

Wolfram Research (1988), Outer, Wolfram Language function, https://reference.wolfram.com/language/ref/Outer.html (updated 2020).

CMS

Wolfram Language. 1988. "Outer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/Outer.html.

APA

Wolfram Language. (1988). Outer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Outer.html

BibTeX

@misc{reference.wolfram_2024_outer, author="Wolfram Research", title="{Outer}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/Outer.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_outer, organization={Wolfram Research}, title={Outer}, year={2020}, url={https://reference.wolfram.com/language/ref/Outer.html}, note=[Accessed: 22-November-2024 ]}