ktk.geometry.matmul

Contents

ktk.geometry.matmul#

matmul(op1, op2, /)[source]#

Matrix multiplication between series of matrices.

This function is a wrapper for numpy’s matmul function (operator @), that uses Kinetics Toolkit’s convention that the first dimension always corresponds to time, to broadcast time correctly between operands.

Parameters:
  • op1 (ArrayLike) – Series of floats, vectors or matrices.

  • op2 (ArrayLike) – Series of floats, vectors or matrices.

Returns:

The product, usually as a series of Nx4 or Nx4xM matrices.

Return type:

np.ndarray

Example

A matrix multiplication between one matrix and a series of 3 vectors results in a series of 3 vectors.

>>> import kineticstoolkit as ktk
>>> mat_series = np.array([[[2.0, 0.0], [0.0, 1.0]]])
>>> vec_series = np.array([[4.0, 5.0], [6.0, 7.0], [8.0, 9.0]])
>>> ktk.geometry.matmul(mat_series, vec_series)
array([[ 8.,  5.],
       [12.,  7.],
       [16.,  9.]])