dpnp.outer
- dpnp.outer(a, b, out=None)[source]
Returns the outer product of two arrays.
For full documentation refer to
numpy.outer
.- Parameters:
a ({dpnp.ndarray, usm_ndarray}) -- First input vector. Input is flattened if not already 1-dimensional.
b ({dpnp.ndarray, usm_ndarray}) -- Second input vector. Input is flattened if not already 1-dimensional.
out ({None, dpnp.ndarray, usm_ndarray}, optional) -- A location where the result is stored. Default:
None
.
- Returns:
out --
out[i, j] = a[i] * b[j]
- Return type:
dpnp.ndarray
See also
dpnp.linalg.outer
Array API compatible version.
dpnp.einsum
Evaluates the Einstein summation convention on the operands.
dpnp.inner
Returns the inner product of two arrays.
dpnp.tensordot
dpnp.tensordot(a.ravel(), b.ravel(), axes=((), ())) is the equivalent.
Examples
>>> import dpnp as np >>> a = np.array([1, 1, 1]) >>> b = np.array([1, 2, 3]) >>> np.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.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.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]])