315
315
plt.imshow( np.log10(np.abs(I_tmp)), interpolation='none')
317
317
plt.show(block=False)
320
####################################################
326
X = np.linspace(-1.,1.,N)
329
P = S1D.Poly1D(S1D.JACOBI,[0.,0.])
331
(xG,wG) = P.GaussQuadrature(l,normed=True)
334
for i in range(tot_it):
335
# Compute moments of orthonormal polys
336
npoint = (l+1)**(i+2) - 1
337
(x,w) = P.GaussQuadrature(npoint,normed=True)
338
v = P.GradVandermonde1D(x,npoint,0,norm=True)
341
# Throw additional points
342
X = np.hstack((x_list[-1],np.linspace(xspan[0],xspan[1],N)))
344
# Construct Vandermonde matrix
345
V_cp = P.GradVandermonde1D(X,npoint,0,norm=True)
348
V_cp[:len(x_list[-1]),:] *= 10.
351
(I, VsqInv, it) = DT.maxvol(V_cp, delta=1e-10,maxit=1000)
353
# Compute sorting indices
354
idxs = np.argsort(X[I])
359
# Compute Vandermonde matrix
360
V = P.GradVandermonde1D(X, npoint,0,norm=True)
363
(W,res,rank,s) = npla.lstsq(V.T,b)
364
# (W,res) = opt.nnls(V.T,b)
366
# Test orthogonality of new quadrature rule
367
I_tmp = np.dot(V.T,np.dot(np.diag(W),V))
369
plt.imshow( np.log10(np.abs(I_tmp)), interpolation='none')
371
plt.title("Iter %d" % it)
372
plt.show(block=False)
374
x_list.append( X[:] )
378
for i in range(tot_it-1):
379
plt.plot(x_list[i+1], i * np.ones(x_list[i+1].shape), 'go')
380
plt.plot(x_list[i], i * np.ones(x_list[i].shape), 'ko')
382
plt.ylim([-1,tot_it-1])