multiply_matrix_vector
- compas.geometry.multiply_matrix_vector(A, b)[source]
Multiply a matrix with a vector.
- Parameters
A (list[list[float]] |
Transformation
) – The matrix.b ([float, float, float] |
Vector
) – The vector.
- Returns
[float, float, float] – The resulting vector.
- Raises
Exception – If not all rows of the matrix have the same length as the vector.
Notes
This is a Python version of the following linear algebra procedure:
\[\mathbf{A} \cdot \mathbf{x} = \mathbf{b}\]with \(\mathbf{A}\) a m by n matrix, \(\mathbf{x}\) a vector of length n, and \(\mathbf{b}\) a vector of length m.
Examples
>>> matrix = [[2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0]] >>> vector = [1.0, 2.0, 3.0] >>> multiply_matrix_vector(matrix, vector) [2.0, 4.0, 6.0]