numpy.float_power()
?The numpy.float_power()
method gives a result that raises each element of the first array x1
to the power of each element of the second array x2
.
Note: In Python, a list of lists can be used to create a two-dimensional (2-D) array.
numpy.float_power(x1, x2, dtype=None, out=None)
x1
: array-like, which represents the data input.x2
: array-like, which represents the data input.dtype
: This is an optional parameter. It represents the array’s return type.out
: This is an optional parameter. It denotes the alternate output array where the result will be stored.Note: If
x1
andx2
have different shapes, they must be broadcastable to a common output shape.
The method numpy.float power()
returns an array with x1
elements raised to exponents in x2
.
The following code shows how to use the numpy.float_power()
method for 2-D arrays.
# import numpyimport numpy as np# create a two 2D arraysx1 = np.array([[2,7,3,9],[6,2,5,8]])x2 = np.array([[5,4,6,11],[2,9,10,1]])# compute the power of the 2D arrays# and store the result in resres = np.float_power(x1, x2)print(res)
numpy
library.x1
and x2
2-D arrays.x1
and x2
, we utilize the np.float_power()
function. The outcome is saved in a new variable named res
.