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