嗨,我有以下代码:
import numpy as np
from scipy import pi,sin,cos
import matplotlib.pyplot as plt
import math as m
image = np.zeros(shape=(201,201))
a=4
b=3
pa = 45
def dE(i,j,a,b,PA,x0,y0):
the = -PA+90.0
x=i - x0
y=j - y0
cos_a,sin_a=cos(the*pi/180.0),sin(the*pi/180.0)
Xs = (x*cos_a - y*sin_a)**2.0
Ys = (x*sin_a + y*cos_a)**2.0
r = np.sqrt((Xs/a**2) + (Ys/b**2))
return r
for i in range(0,len(image)):
for j in range(0,len(image)):
image[j,i] = dE(i,j,a,b,pa,100.0,100.0)
plt.imshow(image)
plt.show()
如何并行化底部的两个 for 循环?提前致谢!
我已经添加了上面的完整代码。干杯克里斯