pangolin.interface.matmul

Contents

pangolin.interface.matmul#

pangolin.interface.matmul(a, b)#

Multiply two vectors or matrices.

The behavior follows NumPy’s matmul except that both inputs must be one- or two-dimensional:

  • Two vectors produce their scalar inner product.

  • A vector and a matrix produce a vector.

  • A matrix and a vector produce a vector.

  • Two matrices produce a matrix.

The contracted dimensions must match. Higher-dimensional batched matrix multiplication is not currently supported.

Parameters:
  • a (RVLike) – Left vector or matrix.

  • b (RVLike) – Right vector or matrix.

Return type:

RV

Examples

>>> import pangolin.interface as pi
>>> pi.matmul([1, 2, 3], [4, 5, 6]).shape
()
>>> pi.matmul([[1, 2, 3], [4, 5, 6]], [7, 8, 9]).shape
(2,)