How to raise each element of 2D array of each element of other 2D array in Python

2 Answers

0 votes
import numpy as np

arr1 = np.array([[2, 4, 9, 1], [8, 5, 0, 3]])
arr2 = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])

result = np.float_power(arr1, arr2)

print(result)



'''
run:

[[2.0000e+00 1.6000e+01 7.2900e+02 1.0000e+00]
 [3.2768e+04 1.5625e+04 0.0000e+00 6.5610e+03]]
 
'''

 



answered Jun 17, 2023 by avibootz
0 votes
import numpy as np

arr1 = np.array([[2, 4, 9, 1], [8, 5, 0, 3]])
arr2 = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])

result = np.power(arr1, arr2)

print(result)



'''
run:

[[    2    16   729     1]
 [32768 15625     0  6561]]

'''

 



answered Jun 17, 2023 by avibootz

Related questions

2 answers 118 views
1 answer 184 views
1 answer 163 views
1 answer 164 views
1 answer 192 views
...