Home > Src > Level_0 > legendre_tr_coef.m

legendre_tr_coef

PURPOSE ^

LEGENDRE_TR_COEF Computes Discrete Legendre Transform coefficients

SYNOPSIS ^

function [uk]=legendre_tr_coef(x,u);

DESCRIPTION ^

 LEGENDRE_TR_COEF   Computes Discrete Legendre Transform  coefficients

            formula (4.4.18)  pag. 118, Quarteroni-Valli, Springer 1997

  [uk]=legendre_tr(x,u) returns the discrete coefficients uk of 
       the expansion of (I_N u)(x) with respect to Legendre polynomials:
       (I_n u)(x)=\Sum_{k=0}^n u_k L_k(x)             (*)

       where L_k(x) are the Legendre polynomials

 Input: x = array of np LGL (Legendre Gauss Lobatto) nodes in [-1,1]
        u = array of np values of u at LGL nodes x : u_j=u(x_j)
            size(u)=[np,nc], where nc is the number of transforms which
            should be computed.
  If u is a 2-indices array, then every column of u is transformed 
  following formula (*)

 Output: uk = array containing discrete coefficients of the
              expansion of I_Nu(x) with respect to Legendre polynomials.
              size(uk)=[np,nc]=size(u)

 Reference: A. Quarteroni, A. Valli:
            "Numerical Approximation of Partial Differential Equations"
            Springer Verlag / 1997 (2nd Ed)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [uk]=legendre_tr_coef(x,u);
0002 % LEGENDRE_TR_COEF   Computes Discrete Legendre Transform  coefficients
0003 %
0004 %            formula (4.4.18)  pag. 118, Quarteroni-Valli, Springer 1997
0005 %
0006 %  [uk]=legendre_tr(x,u) returns the discrete coefficients uk of
0007 %       the expansion of (I_N u)(x) with respect to Legendre polynomials:
0008 %       (I_n u)(x)=\Sum_{k=0}^n u_k L_k(x)             (*)
0009 %
0010 %       where L_k(x) are the Legendre polynomials
0011 %
0012 % Input: x = array of np LGL (Legendre Gauss Lobatto) nodes in [-1,1]
0013 %        u = array of np values of u at LGL nodes x : u_j=u(x_j)
0014 %            size(u)=[np,nc], where nc is the number of transforms which
0015 %            should be computed.
0016 %  If u is a 2-indices array, then every column of u is transformed
0017 %  following formula (*)
0018 %
0019 % Output: uk = array containing discrete coefficients of the
0020 %              expansion of I_Nu(x) with respect to Legendre polynomials.
0021 %              size(uk)=[np,nc]=size(u)
0022 %
0023 % Reference: A. Quarteroni, A. Valli:
0024 %            "Numerical Approximation of Partial Differential Equations"
0025 %            Springer Verlag / 1997 (2nd Ed)
0026 %
0027 
0028 %   Written by Paola Gervasio
0029 %   $Date: 2007/04/01$
0030 %
0031 [np,nc]=size(u); n=np-1;
0032 uk=zeros(np,nc);
0033 nnp1=1/(n*(n+1));
0034 
0035 p=pnleg_all(x,n);
0036 ln2=u./((p(:,np)).^2*ones(1,nc));
0037 coef=(1:2:2*np)'*ones(1,nc);
0038 uk=coef.*(p'*ln2);
0039 uk=uk*nnp1;
0040 s=1./p(:,np);
0041 uk(np,:)=(u'*s)'/np;
0042 
0043 return

Generated on Fri 21-Sep-2007 10:07:00 by m2html © 2003