dpnp.linalg.outer

dpnp.linalg.outer(x1, x2, /)[source]

Compute the outer product of two vectors.

This function is Array API compatible. Compared to dpnp.outer, it accepts 1-dimensional inputs only.

For full documentation refer to numpy.linalg.outer.

Parameters:
  • a ((M,) {dpnp.ndarray, usm_ndarray}) -- One-dimensional input array of size M. Must have a numeric data type.

  • b ((N,) {dpnp.ndarray, usm_ndarray}) -- One-dimensional input array of size N. Must have a numeric data type.

Returns:

out -- out[i, j] = a[i] * b[j]

Return type:

(M, N) dpnp.ndarray

See also

dpnp.outer

Similar function with support for more keyword arguments.

Examples

>>> import dpnp as np
>>> a = np.array([1, 1, 1])
>>> b = np.array([1, 2, 3])
>>> np.linalg.outer(a, b)
array([[1, 2, 3],
       [1, 2, 3],
       [1, 2, 3]])

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

>>> rl = np.linalg.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.]])
>>> im = np.linalg.outer(1j*np.linspace(2, -2, 5), np.ones((5,)))
>>> im
array([[0.+2.j, 0.+2.j, 0.+2.j, 0.+2.j, 0.+2.j],
       [0.+1.j, 0.+1.j, 0.+1.j, 0.+1.j, 0.+1.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.-1.j, 0.-1.j, 0.-1.j, 0.-1.j, 0.-1.j],
       [0.-2.j, 0.-2.j, 0.-2.j, 0.-2.j, 0.-2.j]])
>>> grid = rl + im
>>> grid
array([[-2.+2.j, -1.+2.j,  0.+2.j,  1.+2.j,  2.+2.j],
       [-2.+1.j, -1.+1.j,  0.+1.j,  1.+1.j,  2.+1.j],
       [-2.+0.j, -1.+0.j,  0.+0.j,  1.+0.j,  2.+0.j],
       [-2.-1.j, -1.-1.j,  0.-1.j,  1.-1.j,  2.-1.j],
       [-2.-2.j, -1.-2.j,  0.-2.j,  1.-2.j,  2.-2.j]])