Is there a more efficient way (without loops) to do this with Numpy?:
for i, x in enumerate(array1):
for j, y in enumerate(array2):
result[i, j] = x + y
I was trying to use einsum without success yet.
Thank you !
Simply use broadcasting with an extra dimension:
result = array1[:,None]+array2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.