INTLAG_LG Computes matrix "a" to evaluate 1D Lagrange interpolant at LG (Legendre Gauss) nodes in [-1,1] at another mesh x_new in [-1,1] [a]=intlag_lg(x_lg, w_lg, x_new) Input: x_lg = array of np_lg LG nodes in [-1,1] w_lg = array of np_lg LG weights in [-1,1] x_new = array of np_new another set in [-1,1] Output: a = matrix of size (np_new,np_lg) If u_lg is the array with evaluations of a function u at nodes x_lg, it holds: u_new = a * u_lg, i.e. u_new=u(x_new) Reference: CHQZ2 = C. Canuto, M.Y. Hussaini, A. Quarteroni, T.A. Zang, "Spectral Methods. Fundamentals in Single Domains" Springer Verlag, Berlin Heidelberg New York, 2006.
0001 function [a]=intlag_lg(x_lg, w_lg, x_new); 0002 % INTLAG_LG Computes matrix "a" to evaluate 1D Lagrange interpolant at LG 0003 % 0004 % (Legendre Gauss) nodes in [-1,1] at another mesh x_new in [-1,1] 0005 % 0006 % [a]=intlag_lg(x_lg, w_lg, x_new) 0007 % 0008 % Input: x_lg = array of np_lg LG nodes in [-1,1] 0009 % w_lg = array of np_lg LG weights in [-1,1] 0010 % x_new = array of np_new another set in [-1,1] 0011 % 0012 % Output: a = matrix of size (np_new,np_lg) 0013 % 0014 % If u_lg is the array with evaluations of a function u at nodes 0015 % x_lg, it holds: u_new = a * u_lg, i.e. u_new=u(x_new) 0016 % 0017 % Reference: CHQZ2 = C. Canuto, M.Y. Hussaini, A. Quarteroni, T.A. Zang, 0018 % "Spectral Methods. Fundamentals in Single Domains" 0019 % Springer Verlag, Berlin Heidelberg New York, 2006. 0020 0021 % Written by Paola Gervasio 0022 % $Date: 2007/04/01$ 0023 0024 np_lg=length(x_lg); 0025 np_new=length(x_new); 0026 n_lg=np_lg-1; 0027 a=zeros(np_new,np_lg); 0028 0029 pn=pnleg_all([x_lg;x_new],n_lg); 0030 pn1=pn(np_lg+1:np_lg+np_new,:); 0031 pn=pn(1:np_lg,:); 0032 nor=0.5+(0:n_lg); 0033 for i=1:np_new 0034 for j=1:np_lg 0035 a(i,j)=sum(nor.*pn(j,:).*pn1(i,:))*w_lg(j); 0036 end 0037 end 0038 0039 return