colour.algebra.vecmul#

colour.algebra.vecmul(m: ArrayLike, v: ArrayLike) NDArrayFloat[source]#

Perform the batched multiplication between the matrix array \(m\) and vector array \(v\).

It is in intent equivalent to np.matmul() but with the specific intent of vector multiplication by a matrix. With that intent, vector dimensionality will be increased to enable broadcasting. This definition can be expressed with np.einsum() using the following subscripts: ‘…ij,…j->…i’.

Parameters:
  • m (ArrayLike) – Matrix array \(m\).

  • v (ArrayLike) – Vector array \(v\).

Returns:

Multiplied vector array \(v\).

Return type:

numpy.ndarray

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...]])