Mercurial > repos > public > sbplib
comparison diracPrimDiscr.m @ 1130:99fd66ffe714 feature/laplace_curvilinear_test
Add derivative of delta functions and corresponding tests, tested for 1D.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Tue, 21 May 2019 18:44:01 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1129:b29892853daf | 1130:99fd66ffe714 |
---|---|
1 | |
2 function d = diracPrimDiscr(x_s, x, m_order, s_order, H, derivDir) | |
3 % n-dimensional delta function, with derivative in direction number derivDir | |
4 % x_s: source point coordinate vector, e.g. [x, y] or [x, y, z]. | |
5 % x: cell array of grid point column vectors for each dimension. | |
6 % m_order: Number of moment conditions | |
7 % s_order: Number of smoothness conditions | |
8 % H: cell array of 1D norm matrices | |
9 default_arg('derivDir', 1); | |
10 | |
11 dim = length(x_s); | |
12 d_1D = cell(dim,1); | |
13 | |
14 % If 1D, non-cell input is accepted | |
15 if dim == 1 && ~iscell(x) | |
16 d = diracPrimDiscr1D(x_s, x, m_order, s_order, H); | |
17 else | |
18 for i = 1:dim | |
19 if i == derivDir | |
20 d_1D{i} = diracPrimDiscr1D(x_s(i), x{i}, m_order, s_order, H{i}); | |
21 else | |
22 d_1D{i} = diracDiscr1D(x_s(i), x{i}, m_order, s_order, H{i}); | |
23 end | |
24 end | |
25 | |
26 d = d_1D{dim}; | |
27 for i = dim-1: -1: 1 | |
28 % Perform outer product, transpose, and then turn into column vector | |
29 d = (d_1D{i}*d')'; | |
30 d = d(:); | |
31 end | |
32 end | |
33 | |
34 end |