function w = letrfm1(N, v, x, s, iflag) % The function w = letrfm1(N,x,s,iflag) computes the Legendre % tranforms w.r.t. to the Legendre-Gauss-Lobatto nodes. % % Input: % N: Degree of polynomials, must be even % v: Sequence to be transformed % x,s: output of leinit.m (x: LGL nodes, s_jk=L_k(x_j)) % iflag=1: Spectral to Physical % iflag.ne.1: Physical to Spectral % % % Output: % w: transformed sequence %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (iflag==1) w=s*v; else for i=1:N+1 v(i)=v(i)/(s(i,N+1)^2); end w=s'*v; for i=1:N w(i)=w(i)*(2*i-1)/(N*(N+1)); end w(N+1)=w(N+1)/(N+1); end