colour.utilities.row_as_diagonal#

colour.utilities.row_as_diagonal(a: ArrayLike) ndarray[Any, dtype[_ScalarType_co]][source]#

Return the rows of given array \(a\) as diagonal matrices.

Parameters:

a (ArrayLike) – Array \(a\) to returns the rows of as diagonal matrices.

Returns:

Array \(a\) rows as diagonal matrices.

Return type:

numpy.ndarray

References

[Cas14]

Examples

>>> a = np.array(
...     [
...         [0.25891593, 0.07299478, 0.36586996],
...         [0.30851087, 0.37131459, 0.16274825],
...         [0.71061831, 0.67718718, 0.09562581],
...         [0.71588836, 0.76772047, 0.15476079],
...         [0.92985142, 0.22263399, 0.88027331],
...     ]
... )
>>> row_as_diagonal(a)
array([[[ 0.25891593,  0.        ,  0.        ],
        [ 0.        ,  0.07299478,  0.        ],
        [ 0.        ,  0.        ,  0.36586996]],

       [[ 0.30851087,  0.        ,  0.        ],
        [ 0.        ,  0.37131459,  0.        ],
        [ 0.        ,  0.        ,  0.16274825]],

       [[ 0.71061831,  0.        ,  0.        ],
        [ 0.        ,  0.67718718,  0.        ],
        [ 0.        ,  0.        ,  0.09562581]],

       [[ 0.71588836,  0.        ,  0.        ],
        [ 0.        ,  0.76772047,  0.        ],
        [ 0.        ,  0.        ,  0.15476079]],

       [[ 0.92985142,  0.        ,  0.        ],
        [ 0.        ,  0.22263399,  0.        ],
        [ 0.        ,  0.        ,  0.88027331]]])