python pow function fixed and changed to musl implementation

This commit is contained in:
Nicolas 2025-11-12 21:51:05 +01:00
parent 443d1d19d3
commit a395e180e6
2 changed files with 6 additions and 3 deletions

View File

@ -243,7 +243,7 @@ class variable(Generic[TNum], Net):
@overload
def __rpow__(self, other: float) -> 'variable[float]': ...
def __rpow__(self, other: NumLike) -> Any:
return add_op('rpow', [other, self])
return cp.pow(other, self)
def __hash__(self) -> int:
return super().__hash__()

View File

@ -57,7 +57,7 @@ def pow(x: NumLike, y: NumLike) -> NumLike:
Returns:
result of x**y
"""
if isinstance(y, int) and 0 <= y < 16:
if isinstance(y, int) and 0 <= y < 8:
if y == 0:
return 1
m = x
@ -66,7 +66,10 @@ def pow(x: NumLike, y: NumLike) -> NumLike:
return m
if y == -1:
return 1 / x
return exp(y * log(x))
if isinstance(x, variable) or isinstance(y, variable):
return add_op('pow', [x, y])
else:
return float(x ** y)
@overload