outer

Contents

outer#

class saiunit.linalg.outer(a, b, out=None, **kwargs)#

Compute the outer product of two vectors or quantities.

Given two 1-D arrays a of length M and b of length N, the outer product is an (M, N) array where out[i, j] = a[i] * b[j]. The resulting unit is a.unit * b.unit.

Parameters:
  • a (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – First argument (flattened if not 1-D).

  • b (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – Second argument (flattened if not 1-D).

  • out (Any | None) – A location into which the result is stored. If not provided, a freshly-allocated array is returned.

Returns:

output – The outer product of the inputs, shape (M, N). The resulting unit is a.unit * b.unit.

Return type:

Array | saiunit.Quantity

Examples

>>> import saiunit as u
>>> a = u.math.array([1.0, 2.0]) * u.meter
>>> b = u.math.array([3.0, 4.0, 5.0]) * u.second
>>> u.math.outer(a, b)  # shape (2, 3), unit meter * second