# mxnet.np.outer¶

outer(a, b)

Compute the outer product of two vectors. Given two vectors, a = [a0, a1, ..., aM] and b = [b0, b1, ..., bN], the outer product 1 is:: [[a0*b0 a0*b1 … a0*bN ] [a1*b0 . [ … . [aM*b0 aM*bN ]]

Parameters
• a ((M,) ndarray) – First input vector. Input is flattened if not already 1-dimensional.

• b ((N,) ndarray) – Second input vector. Input is flattened if not already 1-dimensional.

Returns

outout[i, j] = a[i] * b[j]

Return type

(M, N) ndarray

inner()

einsum()

einsum('i,j->ij', a.ravel(), b.ravel()) is the equivalent.

ufunc.outer()

A generalization to N dimensions and other operations. np.multiply.outer(a.ravel(), b.ravel()) is the equivalent.

References

1

: G. H. Golub and C. F. Van Loan, Matrix Computations, 3rd ed., Baltimore, MD, Johns Hopkins University Press, 1996, pg. 8.

Examples

Make a (very coarse) grid for computing a Mandelbrot set:

>>> rl = np.outer(np.ones((5,)), np.linspace(-2, 2, 5))
>>> rl
array([[-2., -1.,  0.,  1.,  2.],
[-2., -1.,  0.,  1.,  2.],
[-2., -1.,  0.,  1.,  2.],
[-2., -1.,  0.,  1.,  2.],
[-2., -1.,  0.,  1.,  2.]])