multiply_matrices

compas.geometry.multiply_matrices(A, B)[source]

Mutliply a matrix with a matrix.

Parameters:
Alist[list[float]] | compas.geometry.Transformation

The first matrix.

Blist[list[float]] | compas.geometry.Transformation

The second matrix.

Returns:
list[list[float]]

The result matrix.

Raises:
Exception

If the shapes of the matrices are not compatible. If the row length of B is inconsistent.

Notes

This is a pure Python version of the following linear algebra procedure:

AB=C

with A [m x n], B [n x o], and C [m x o].

Examples

>>> A = [[2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0]]
>>> B = [[2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0]]
>>> multiply_matrices(A, B)
[[4.0, 0.0, 0.0], [0.0, 4.0, 0.0], [0.0, 0.0, 4.0]]