
function demo_orthogonality

%--------------------------------------------------------------------------
% Object:
% This routine checks the orthogonality of the Dubiner basis on the
% unit-simplex [0 0; 1 0; 0 1] at points "pts" and of degree "n".
%
% a) it evaluates the Vandermonde matrix of columns V(j,k)=p_k(x_j).
% b) computes err(s,t)=int(p_s*p_t)-knonecker(s,t)
% c) it computes the maximum absolute value of "err(s,t)" varying "s", "t".
%--------------------------------------------------------------------------

degree=10;
[xyw,xyw_bar,pointset_stats]=cub_triangle(2*degree);

pts=xyw(:,1:2); w=xyw(:,3);
V=vandermonde_dubiner(degree,pts);
D=diag(sqrt(w));
W=D*V;
orthmat=W'*W;
val=max(max(abs(orthmat-eye(size(orthmat)))));

fprintf('\n \t: degree    : %-3.0f',degree);
fprintf('\n \t: orth.error: %-1.2e \n',val);

