colour.algebra.spow#

colour.algebra.spow(a: float | DTypeFloat, p: float | DTypeFloat) DTypeFloat[source]#
colour.algebra.spow(a: NDArray, p: ArrayLike) NDArrayFloat
colour.algebra.spow(a: ArrayLike, p: NDArray) NDArrayFloat
colour.algebra.spow(a: ArrayLike, p: ArrayLike) DTypeFloat | NDArrayFloat

Raise specified array \(a\) to the power \(p\) as follows: \(\text{sign}(a) \cdot |a|^p\).

This definition avoids NaN generation when array \(a\) is negative and power \(p\) is fractional. This behaviour can be enabled or disabled with the colour.algebra.set_spow_enable() definition or with the spow_enable() context manager.

Parameters:
Returns:

Array \(a\) safely raised to the power \(p\).

Return type:

np.float or numpy.ndarray

Examples

>>> np.power(-2, 0.15)
np.float64(nan)
>>> spow(-2, 0.15)
np.float64(-1.1095694...)
>>> spow(0, 0)
np.float64(0.0)