numpy.ma.outerproduct

numpy.ma.outerproduct(a, b)

Returns the outer product of two vectors.

Given two vectors, [a0, a1, ..., aM] and [b0, b1, ..., bN], the outer product becomes:

[[a0*b0  a0*b1 ... a0*bN ]
 [a1*b0    .
 [ ...          .
 [aM*b0            aM*bN ]]
Parameters:

a : array_like, shaped (M,)

First input vector. If either of the input vectors are not 1-dimensional, they are flattened.

b : array_like, shaped (N,)

Second input vector.

Returns:

out : ndarray, shaped (M, N)

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

Notes

Masked values are replaced by 0.

Examples

>>> x = np.array(['a', 'b', 'c'], dtype=object)
>>> np.outer(x, [1, 2, 3])
array([[a, aa, aaa],
       [b, bb, bbb],
       [c, cc, ccc]], dtype=object)

Previous topic

numpy.ma.outer

Next topic

numpy.ma.trace

This Page

Quick search