rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ldg_basis_orthonormalization_matrix.m
1 function [G, Vstr] = ldg_basis_orthonormalization_matrix(pdeg,quaddeg)
2 %function [G, Vstr] = ldg_basis_orthonormalization_matrix(pdeg,quaddeg)
3 %
4 % computation of Gram matrix of ldg basis of degree pdeg with
5 % quadrature of degree quaddeg. Inner product is L2-inner product
6 % over reference triangle.
7 %
8 % If the resulting matrix is not unity, the strin Vstr defines an
9 % orthogonal matrix V, that realizes an orthonormalization.
10 % i.e. if G=X' * X then (XV)'(XV) is the identity matrix.
11 % This matrix must be multiplied in evaluate_basis with the
12 % current basis in order to produce an orthonormal basis.
13 
14 % Bernard Haasdonk 28.1.2009
15 
16 % set ldg parameters
17 params.nelements = 1;
18 params.pdeg = pdeg;
19 params.dimrange = 1;
20 
21 % test orthogonality of basis functions:
22 G = ldg_local_mass_matrix(quaddeg,params);
23 
24 %f = @(lcoord) gram_matrix(ldg_evaluate_basis(params,lcoord));
25 %G = triaquadrature(quaddeg,f);
26 
27 % determine V such that Id = V' * G * V, i.e. V is the
28 % coefficient matrix for orthonormalization of the input vectors
29 G = 0.5*(G+G');
30 [v,e] = eig(G); % so G = v * e * v', v' * G * v = e,
31  % e.^(-0.5) * v' * G * v e.^(-0.5) = Id
32 V = v * diag(diag(e).^(-0.5));
33 
34 %keyboard;
35 
36 if abs(max(V' * G * V -eye(size(G))))>1e-4
37  disp('error in orthonomalization matrix')
38 end;
39 
40 Vstr = matrix2str(V);
41 %| \docupdate