matmul

Contents

matmul#

class saiunit.linalg.matmul(a, b, *, precision=None, preferred_element_type=None, **kwargs)#

Compute the matrix product of two arrays or quantities.

The resulting unit is a.unit * b.unit.

Parameters:
  • a (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – First argument.

  • b (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – Second argument.

  • precision (Any) – Either None (default) or a Precision enum value, or a tuple of two such values for a and b.

  • preferred_element_type (str | type[Any] | dtype | SupportsDType | None) – Accumulation and result dtype.

Returns:

output – The matrix product of the inputs. 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], [3.0, 4.0]]) * u.meter
>>> b = u.math.array([[5.0, 6.0], [7.0, 8.0]]) * u.second
>>> u.math.matmul(a, b)  # shape (2, 2), unit meter * second