# decompose 4 random 1-cochains for i in range(4): omega = sc.get_cochain(1) omega.v[:] = rand(*omega.v.shape) (beta, gamma, h) = hodge_decomposition(omega) h = h.v for v in H: h -= inner(v, h) * v h /= norm(h) H.append(h) H = ortho(vstack(H)) # plot the results from pylab import figure, title, quiver, axis, show from pydec import triplot, simplex_quivers for n, h in enumerate(H): figure() title('Harmonic 1-cochain #%d' % n) triplot(vertices, triangles) bases, dirs = simplex_quivers(sc, h) quiver(bases[:, 0], bases[:, 1], dirs[:, 0], dirs[:, 1]) axis('equal') show()
#print 'norm(b2.T * h)', norm(b2.T * h) #should be small # plot the results from pylab import figure, title, plot, axis, xlim, ylim, show from pydec import triplot, lineplot # Nodes of the Rips complex figure() plot(pts[:, 0], pts[:, 1], 'ko') axis('off') title('Nodes of the Complex') # Rips complex (2d triangle mesh) figure() title('The Rips Complex') triplot(pts, simplices[2]) # Harmonic 1-chain figure() title('Harmonic 1-chain of the Rips complex') lineplot(pts, simplices[1], linewidths=(15 * abs(h)).clip(1, 15)) # fiddle with the figures for i in range(1, 4): figure(i) axis('off') axis('equal') xlim(-0.1, 1.1) ylim(-0.1, 1.1) show()
# plot the results from pylab import figure, title, plot, axis, xlim, ylim, show from pydec import triplot, lineplot # Nodes of the Rips complex figure() plot(pts[:,0],pts[:,1],'ko') axis('off') title('Nodes of the Complex') # Rips complex (2d triangle mesh) figure() title('The Rips Complex') triplot(pts,simplices[2]) # Harmonic 1-chain figure() title('Harmonic 1-chain of the Rips complex') lineplot(pts,simplices[1],linewidths=(15*abs(h)).clip(1,15) ) # fiddle with the figures for i in range(1,4): figure(i) axis('off') axis('equal') xlim(-0.1,1.1) ylim(-0.1,1.1) show()
for i in range(4): omega = sc.get_cochain(1) omega.v[:] = rand(*omega.v.shape) (beta,gamma,h) = hodge_decomposition(omega) h = h.v for v in H: h -= inner(v,h) * v h /= norm(h) H.append(h) H = ortho(vstack(H)) # plot the results from pylab import figure, title, quiver, axis, show from pydec import triplot, simplex_quivers for n,h in enumerate(H): figure() title('Harmonic 1-cochain #%d' % n) triplot(vertices,triangles) bases,dirs = simplex_quivers(sc,h) quiver(bases[:,0],bases[:,1],dirs[:,0],dirs[:,1]) axis('equal') show()