cf.Data.outerproduct

Data.outerproduct(a, inplace=False, i=False)[source]

Compute the outer product with another data array.

The axes of result will be the combined axes of the two input arrays.

See also

np.multiply.outer

Parameters
a: array_like

The data with which to form the outer product.

inplace: bool, optional

If True then do the operation in-place and return None.

i: deprecated at version 3.0.0

Use the inplace parameter instead.

Returns
Data or None

The outer product, or None if the operation was in-place.

Examples

>>> d = cf.Data([1, 2, 3], 'm')
>>> d
<CF Data(3): [1, 2, 3] m>
>>> f = d.outerproduct([4, 5, 6, 7])
>>> f
<CF Data(3, 4): [[4, ..., 21]] m>
>>> print(f.array)
[[ 4  5  6  7]
 [ 8 10 12 14]
 [12 15 18 21]]
>>> e = cf.Data([[4, 5, 6, 7], [6, 7, 8, 9]], 's-1')
>>> e
<CF Data(2, 4): [[4, ..., 9]] s-1>
>>> f = d.outerproduct(e)
>>> f
<CF Data(3, 2, 4): [[[4, ..., 27]]] m.s-1>
>>> print(f.array)
[[[ 4  5  6  7]
  [ 6  7  8  9]]
[[ 8 10 12 14]

[12 14 16 18]]

[[12 15 18 21]

[18 21 24 27]]]