colour.algebra.vecmul#
- colour.algebra.vecmul(m: ArrayLike, v: ArrayLike) NDArrayFloat[source]#
Perform batched multiplication between the matrix array \(m\) and vector array \(v\).
This function is equivalent to
numpy.matmul()but specifically designed for vector multiplication by a matrix. Vector dimensionality is automatically increased to enable broadcasting. The operation can be expressed usingnumpy.einsum()with subscripts ‘…ij,…j->…i’.- Parameters:
- Returns:
Multiplied vector array \(v\).
- Return type:
Examples
>>> m = np.array( ... [ ... [0.7328, 0.4296, -0.1624], ... [-0.7036, 1.6975, 0.0061], ... [0.0030, 0.0136, 0.9834], ... ] ... ) >>> m = np.reshape(np.tile(m, (6, 1)), (6, 3, 3)) >>> v = np.array([0.20654008, 0.12197225, 0.05136952]) >>> v = np.tile(v, (6, 1)) >>> vecmul(m, v) array([[ 0.1954094..., 0.0620396..., 0.0527952...], [ 0.1954094..., 0.0620396..., 0.0527952...], [ 0.1954094..., 0.0620396..., 0.0527952...], [ 0.1954094..., 0.0620396..., 0.0527952...], [ 0.1954094..., 0.0620396..., 0.0527952...], [ 0.1954094..., 0.0620396..., 0.0527952...]])