mirror of https://github.com/Nonannet/copapy.git
python pow function fixed and changed to musl implementation
This commit is contained in:
parent
443d1d19d3
commit
a395e180e6
|
|
@ -243,7 +243,7 @@ class variable(Generic[TNum], Net):
|
||||||
@overload
|
@overload
|
||||||
def __rpow__(self, other: float) -> 'variable[float]': ...
|
def __rpow__(self, other: float) -> 'variable[float]': ...
|
||||||
def __rpow__(self, other: NumLike) -> Any:
|
def __rpow__(self, other: NumLike) -> Any:
|
||||||
return add_op('rpow', [other, self])
|
return cp.pow(other, self)
|
||||||
|
|
||||||
def __hash__(self) -> int:
|
def __hash__(self) -> int:
|
||||||
return super().__hash__()
|
return super().__hash__()
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ def pow(x: NumLike, y: NumLike) -> NumLike:
|
||||||
Returns:
|
Returns:
|
||||||
result of x**y
|
result of x**y
|
||||||
"""
|
"""
|
||||||
if isinstance(y, int) and 0 <= y < 16:
|
if isinstance(y, int) and 0 <= y < 8:
|
||||||
if y == 0:
|
if y == 0:
|
||||||
return 1
|
return 1
|
||||||
m = x
|
m = x
|
||||||
|
|
@ -66,7 +66,10 @@ def pow(x: NumLike, y: NumLike) -> NumLike:
|
||||||
return m
|
return m
|
||||||
if y == -1:
|
if y == -1:
|
||||||
return 1 / x
|
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
|
@overload
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue