# megengine.functional.pow¶

pow(x, y)[源代码]

Element-wise power.

Tensor

• 如果 $$x_i$$ 不为 1$$y_i$$NaN, 则幂运算的结果为 NaN.

• If $$y_i$$ is +0, the result is 1, even if $$x_i$$ is NaN.

• If $$y_i$$ is -0, the result is 1, even if $$x_i$$ is NaN.

• If $$x_i$$ is NaN and $$y_i$$ is not equal to 0, the result is NaN.

• If $$\abs{x_i}$$ is greater than 1 and $$y_i$$ is +infinity, the result is +infinity.

• If $$\abs{x_i}$$ is greater than 1 and $$y_i$$ is -infinity, the result is +0.

• If $$\abs{x_i}$$ is 1 and $$y_i$$ is +infinity, the result is 1.

• If $$\abs{x_i}$$ is 1 and $$y_i$$ is -infinity, the result is 1.

• If $$x_i$$ is 1 and $$y_i$$ is not NaN, the result is 1.

• If $$\abs{x_i}$$ is less than 1 and $$y_i$$ is +infinity, the result is +0.

• If $$\abs{x_i}$$ is less than 1 and $$y_i$$ is -infinity, the result is +infinity.

• If $$x_i$$ is +infinity and $$y_i$$ is greater than 0, the result is +infinity.

• If $$x_i$$ is +infinity and $$y_i$$ is less than 0, the result is +0.

• If $$x_i$$ is -infinity, $$y_i$$ is greater than 0, and $$y_i$$ is an odd integer value, the result is -infinity.

• If $$x_i$$ is -infinity, $$y_i$$ is greater than 0, and $$y_i$$ is not an odd integer value, the result is +infinity.

• If $$x_i$$ is -infinity, $$y_i$$ is less than 0, and $$y_i$$ is an odd integer value, the result is -0.

• If $$x_i$$ is -infinity, $$y_i$$ is less than 0, and $$y_i$$ is not an odd integer value, the result is +0.

• If $$x_i$$ is +0 and $$y_i$$ is greater than 0, the result is +0.

• If $$x_i$$ is +0 and $$y_i$$ is less than 0, the result is +infinity.

• If $$x_i$$ is -0, $$y_i$$ is greater than 0, and $$y_i$$ is an odd integer value, the result is -0.

• If $$x_i$$ is -0, $$y_i$$ is greater than 0, and $$y_i$$ is not an odd integer value, the result is +0.

• If $$x_i$$ is -0, $$y_i$$ is less than 0, and $$y_i$$ is an odd integer value, the result is -infinity.

• If $$x_i$$ is -0, $$y_i$$ is less than 0, and $$y_i$$ is not an odd integer value, the result is +infinity.

• If $$x_i$$ is less than 0, $$x_i$$ is a finite number, $$y_i$$ is a finite number, and $$y_i$$ is not an integer value, the result is NaN.

>>> F.pow(2.0, 3.0)
Tensor(8.0, device=xpux:0)


Element-wise power:

>>> x = Tensor([1, 2, 3, 4, 5])
>>> y = Tensor([1, 2, 1, 2, 1])
>>> F.pow(x, y)
Tensor([ 1.  4.  3. 16.  5.], device=xpux:0)


>>> F.pow(x, 2)