multiply_matrices
- compas.geometry.multiply_matrices(A, B)[source]
Mutliply a matrix with a matrix.
- Parameters
A (sequence of sequence of float) – The first matrix.
B (sequence of sequence of float) – The second matrix.
- Returns
C (list of list of 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:
\[\mathbf{A} \cdot \mathbf{B} = \mathbf{C}\]with \(\mathbf{A}\) a m by n matrix, \(\mathbf{B}\) a n by o matrix, and \(\mathbf{C}\) a m by o matrix.
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]]