colour.utilities.xp_ascontiguousarray#

colour.utilities.xp_ascontiguousarray(a: ArrayLike, *, xp: ProtocolArrayNamespace | ModuleType | None = None) → NDArray[source]#

Array API compatible implementation of numpy.ascontiguousarray().

Materialise a into a C-contiguous array with the same shape and dtype. The lazy stride-permuted view returned by xp.matrix_transpose() (and .T / .mT) poisons downstream broadcasts and forces BLAS to copy internally on every subsequent matmul; calling this function at the transpose boundary cascades the contiguous layout through all downstream operations.

Parameters:
Returns:

C-contiguous copy of \(a\) on the same backend.

Return type:

object

Examples

>>> xp_ascontiguousarray(np.array([[1, 2], [3, 4]]).T, xp=np).flags["C_CONTIGUOUS"]
True