Compute the result of applying op to all pairs (a,b)
op.outer(A,B) is equivalent to op(A[:,:,...,:,newaxis,...,newaxis]*B[newaxis,...,newaxis,:,...,:]) where A has B.ndim new axes appended and B has A.ndim new axes prepended.
For A and B one-dimensional, this is equivalent to
r = empty(len(A),len(B))
for i in xrange(len(A)):
for j in xrange(len(B)):
r[i,j] = A[i]*B[j]
If A and B are higher-dimensional, the result has dimension A.ndim+B.ndim
Parameters: | A : array_like
B : array_like
|
---|---|
Returns: | r : ndarray
|
Examples
>>> np.multiply.outer([1,2,3],[4,5,6])
array([[ 4, 5, 6],
[ 8, 10, 12],
[12, 15, 18]])