def plot_eigenvectors(Vh, U, mytitle, which = [0,1,2,5,10,15]):
assert len(which) % 3 == 0
nrows = len(which) / 3
subplot_loc = nrows*100 + 30
plt.figure(figsize=(18,4*nrows))
title_stamp = mytitle + " {0}"
u = dl.Function(Vh)
counter=1
for i in which:
assert i < U.shape[1]
Ui = U[:,i]
if Ui[0] >= 0:
s = 1./np.linalg.norm(Ui, np.inf)
else:
s = -1./np.linalg.norm(Ui, np.inf)
u.vector().set_local(s*Ui)
plot(u, subplot_loc=(subplot_loc+counter), mytitle=title_stamp.format(i), vmin=-1, vmax=1)
counter = counter+1
评论列表
文章目录