dpnp.ufunc.outer
- ufunc.outer(x1, x2, out=None, where=True, order='K', dtype=None, subok=True, **kwargs)[source]
Apply the ufunc op to all pairs (a, b) with a in A and b in B.
- Parameters:
x1 ({dpnp.ndarray, usm_ndarray}) -- First input array.
x2 ({dpnp.ndarray, usm_ndarray}) -- Second input array.
out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Output array to populate. Array must have the correct shape and the expected data type.
**kwargs -- For other keyword-only arguments, see the
dpnp.ufunc.
- Returns:
out -- Output array. The data type of the returned array is determined by the Type Promotion Rules.
- Return type:
dpnp.ndarray
Limitations
Parameters where and subok are supported with their default values. Keyword argument kwargs is currently unsupported. Otherwise
NotImplementedErrorexception will be raised.See also
dpnp.outerA less powerful version of dpnp.multiply.outer that ravels all inputs to 1D. This exists primarily for compatibility with old code.
dpnp.tensordotdpnp.tensordot(a, b, axes=((), ())) and dpnp.multiply.outer(a, b) behave same for all dimensions of a and b.
Examples
>>> import dpnp as np >>> A = np.array([1, 2, 3]) >>> B = np.array([4, 5, 6]) >>> np.multiply.outer(A, B) array([[ 4, 5, 6], [ 8, 10, 12], [12, 15, 18]])
A multi-dimensional example:
>>> A = np.array([[1, 2, 3], [4, 5, 6]]) >>> A.shape (2, 3) >>> B = np.array([[1, 2, 3, 4]]) >>> B.shape (1, 4) >>> C = np.multiply.outer(A, B) >>> C.shape; C (2, 3, 1, 4) array([[[[ 1, 2, 3, 4]], [[ 2, 4, 6, 8]], [[ 3, 6, 9, 12]]], [[[ 4, 8, 12, 16]], [[ 5, 10, 15, 20]], [[ 6, 12, 18, 24]]]])