rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ldg_evaluate_basis.m
1 function res = ldg_evaluate_basis(lcoord,df)
2 %function res = ldg_evaluate_basis(lcoord,df)
3 %
4 % evaluation of ldg reference basis `\hat \phi_i, i=1,\ldots,m` in point
5 % `\hat x` = 'lcoord'. The argument df can either be a ldg
6 % discretefunction or also be a simple structure with the
7 % fields pdeg and dimrange.
8 % Res is a ndofs_per_element x dimrange (=m) array, each row being
9 % evaluation of one basis vector
10 % lcoord is a 2-vector with the barycentric coordinates in the
11 % triangle.
12 %
13 % the basis is an orthonormal basis wrt the reference unit
14 % simplex obtained by orthonormalizing
15 % `1,x,y,x^2, xy, y^2`, etc.
16 % i.e. the power_vector2.
17 %
18 % with V being the ldg_weight_matrix and W=V' we have
19 %
20 % @code
21 % (\hat phi_1, ... \hat phi_nbasefct)^T =
22 %
23 % (c_1(x),0 ,0 ,c_2(x),0 ,0 ,... c_k(x), 0, 0)
24 % (0 ,c_1(x),0 ,0 ,c_2(x),0 ,... 0 ,c_k(x), 0 )
25 % (0 ,0 ,c_1(x),0 , 0,c_2(x),... 0 , 0 , c_k(x))^T
26 %
27 % and c_i(x)= w_i * p(x)
28 % @endcode
29 %
30 % with `w_i` = i-th row of W (i-th column of V) and p(x) the powervector
31 %
32 % with k = number of scalar base functions = dim(powervector2)
33 
34 % Bernard Haasdonk 28.1.2009
35 
36 switch df.pdeg
37  case 0
38  res = sqrt(2) * eye(df.dimrange);
39  case {1,2,3,4}
40  % case 1:
41  % res = [sqrt(2) * eye(df.dimrange), ...
42  % 6 *(lcoord(1)-1/3) * eye(df.dimrange),...
43  % 6 / sqrt(3)*(2 * lcoord(2)+lcoord(1)-1) * eye(df.dimrange)];
44  V = ldg_basis_weight_matrix(df.pdeg);
45  c = V' * power_vector2(lcoord,df.pdeg);
46  e = eye(df.dimrange);
47  nrep=[3,6,10,15];
48  res = zeros(df.dimrange,nrep(df.pdeg)*df.dimrange);
49  for i=1:nrep(df.pdeg)
50  ra = (1+(i-1)*df.dimrange):i*df.dimrange;
51  res(:,ra)=c(i)*e;
52  end;
53  % transposition in order to have one row per basis function
54  res = res';
55  otherwise
56  error('pdeg not yet supported!');
57 end;
58 
59 %| \docupdate