nlcpy.ufunc.outer
- ufunc.outer(self, A, B, **kwargs)
Applies the ufunc op to all pairs (a, b) with a in A and b in B.
Let
M = A.ndim
,N = B.ndim
. Then the result, C, ofop.outer(A, B)
is an array of dimension M + N such that:- Parameters
- A(M,) array_like
First array
- B(N,) array_like
Second array
- kwargsany
Arguments to pass on to the ufunc. Typically dtype or out.
- Returns
- rndarray
Output array
Examples
>>> import nlcpy as vp >>> vp.multiply.outer([1, 2, 3], [4, 5, 6]) array([[ 4, 5, 6], [ 8, 10, 12], [12, 15, 18]])
A multi-dimensional example:
>>> A = vp.array([[1, 2, 3], [4, 5, 6]]) >>> A.shape (2, 3) >>> B = vp.array([[1, 2, 3, 4]]) >>> B.shape (1, 4) >>> C = vp.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]]]])