annotate diracDiscrTest.m @ 836:049e4c6fa630 feature/poroelastic

Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
author Martin Almquist <malmquist@stanford.edu>
date Wed, 05 Sep 2018 14:46:39 -0700
parents
children 43a1c3ac07b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
836
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
1 function tests = diracDiscrTest()
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
2 tests = functiontests(localfunctions);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
3 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
4
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
5 function testLeftGP(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
6
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
7 orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
8 mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
9
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
10 for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
11 order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
12 mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
13 [xl, xr, m, h, x, H, fs] = setupStuff(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
14
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
15 % Test left boundary grid points
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
16 x0s = xl + [0, h, 2*h];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
17
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
18 for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
19 f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
20 fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
21 for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
22 x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
23 delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
24 integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
25 err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26 testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
28 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
29 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
30 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
31
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
32 function testLeftRandom(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
33
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
34 orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
35 mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
36
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
37 for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
38 order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
39 mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
40 [xl, xr, m, h, x, H, fs] = setupStuff(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
41
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
42 % Test random points near left boundary
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
43 x0s = xl + 2*h*rand(1,10);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
44
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
45 for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
46 f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
47 fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
48 for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
49 x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
50 delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
51 integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
52 err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
53 testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
54 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
55 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
56 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
57 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
58
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
59 function testRightGP(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
60
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
61 orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
62 mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
63
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
64 for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
65 order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
66 mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
67 [xl, xr, m, h, x, H, fs] = setupStuff(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
68
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
69 % Test right boundary grid points
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
70 x0s = xr-[0, h, 2*h];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
71
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
72 for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
73 f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
74 fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
75 for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
76 x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
77 delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
78 integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
79 err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
80 testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
81 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
82 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
83 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
84 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
85
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
86 function testRightRandom(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
87
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
88 orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
89 mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
90
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
91 for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
92 order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
93 mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
94 [xl, xr, m, h, x, H, fs] = setupStuff(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
95
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
96 % Test random points near right boundary
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
97 x0s = xr - 2*h*rand(1,10);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
98
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
99 for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
100 f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
101 fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
102 for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
103 x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
104 delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
105 integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
106 err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
107 testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
108 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
109 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
110 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
111 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
112
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
113 function testInteriorGP(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
114
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
115 orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
116 mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
117
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
118 for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
119 order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
120 mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
121 [xl, xr, m, h, x, H, fs] = setupStuff(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
122
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
123 % Test interior grid points
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
124 m_half = round(m/2);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
125 x0s = xl + (m_half-1:m_half+1)*h;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
126
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
127 for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
128 f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
129 fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
130 for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
131 x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
132 delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
133 integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
134 err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
135 testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
136 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
137 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
138 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
139 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
140
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
141 function testInteriorRandom(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
142
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
143 orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
144 mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
145
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
146 for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
147 order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
148 mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
149 [xl, xr, m, h, x, H, fs] = setupStuff(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
150
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
151 % Test random points in interior
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
152 x0s = (xl+2*h) + (xr-xl-4*h)*rand(1,20);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
153
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
154 for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
155 f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
156 fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
157 for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
158 x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
159 delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
160 integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
161 err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
162 testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
163 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
164 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
165 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
166 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
167
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
168 % x0 outside grid should yield 0 integral!
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
169 function testX0OutsideGrid(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
170
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
171 orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
172 mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
173
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
174 for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
175 order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
176 mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
177 [xl, xr, m, h, x, H, fs] = setupStuff(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
178
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
179 % Test points outisde grid
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
180 x0s = [xl-1.1*h, xr+1.1*h];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
181
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
182 for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
183 f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
184 fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
185 for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
186 x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
187 delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
188 integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
189 err = abs(integral - 0);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
190 testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
191 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
192 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
193 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
194 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
195
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
196 function testAllGP(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
197
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
198 orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
199 mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
200
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
201 for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
202 order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
203 mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
204 [xl, xr, m, h, x, H, fs] = setupStuff(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
205
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
206 % Test all grid points
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
207 x0s = x;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
208
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
209 for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
210 f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
211 fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
212 for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
213 x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
214 delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
215 integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
216 err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
217 testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
218 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
219 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
220 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
221 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
222
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
223 function testHalfGP(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
224
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
225 orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
226 mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
227
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
228 for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
229 order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
230 mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
231 [xl, xr, m, h, x, H, fs] = setupStuff(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
232
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
233 % Test halfway between all grid points
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
234 x0s = 1/2*( x(2:end)+x(1:end-1) );
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
235
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
236 for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
237 f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
238 fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
239 for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
240 x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
241 delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
242 integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
243 err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
244 testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
245 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
246 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
247 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
248 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
249
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
250 % function testAllGPStaggered(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
251
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
252 % orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
253 % mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
254
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
255 % for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
256 % order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
257 % mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
258 % [xl, xr, m, h, x, H, fs] = setupStaggered(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
259
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
260 % % Test all grid points
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
261 % x0s = x;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
262
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
263 % for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
264 % f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
265 % fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
266 % for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
267 % x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
268 % delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
269 % integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
270 % err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
271 % testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
272 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
273 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
274 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
275 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
276
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
277 % function testHalfGPStaggered(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
278
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
279 % orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
280 % mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
281
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
282 % for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
283 % order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
284 % mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
285 % [xl, xr, m, h, x, H, fs] = setupStaggered(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
286
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
287 % % Test halfway between all grid points
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
288 % x0s = 1/2*( x(2:end)+x(1:end-1) );
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
289
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
290 % for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
291 % f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
292 % fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
293 % for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
294 % x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
295 % delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
296 % integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
297 % err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
298 % testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
299 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
300 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
301 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
302 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
303
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
304 % function testRandomStaggered(testCase)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
305
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
306 % orders = [2, 4, 6];
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
307 % mom_conds = orders;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
308
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
309 % for o = 1:length(orders)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
310 % order = orders(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
311 % mom_cond = mom_conds(o);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
312 % [xl, xr, m, h, x, H, fs] = setupStaggered(order, mom_cond);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
313
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
314 % % Test random points within grid boundaries
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
315 % x0s = xl + (xr-xl)*rand(1,300);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
316
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
317 % for j = 1:length(fs)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
318 % f = fs{j};
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
319 % fx = f(x);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
320 % for i = 1:length(x0s)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
321 % x0 = x0s(i);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
322 % delta = diracDiscr(x0, x, mom_cond, 0, H);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
323 % integral = delta'*H*fx;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
324 % err = abs(integral - f(x0));
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
325 % testCase.verifyLessThan(err, 1e-12);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
326 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
327 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
328 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
329 % end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
330
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
331
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
332 % ============== Setup functions =======================
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
333 function [xl, xr, m, h, x, H, fs] = setupStuff(order, mom_cond)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
334
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
335 % Grid
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
336 xl = -3;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
337 xr = 900;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
338 L = xr-xl;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
339 m = 101;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
340 h = (xr-xl)/(m-1);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
341 g = grid.equidistant(m, {xl, xr});
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
342 x = g.points();
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
343
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
344 % Quadrature
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
345 ops = sbp.D2Standard(m, {xl, xr}, order);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
346 H = ops.H;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
347
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
348 % Moment conditions
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
349 fs = cell(mom_cond,1);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
350 for p = 0:mom_cond-1
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
351 fs{p+1} = @(x) (x/L).^p;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
352 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
353
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
354 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
355
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
356 function [xl, xr, m, h, x, H, fs] = setupStaggered(order, mom_cond)
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
357
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
358 % Grid
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
359 xl = -3;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
360 xr = 900;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
361 L = xr-xl;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
362 m = 101;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
363 [~, g_dual] = grid.primalDual1D(m, {xl, xr});
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
364 x = g_dual.points();
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
365 h = g_dual.h;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
366
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
367 % Quadrature
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
368 ops = sbp.D1Staggered(m, {xl, xr}, order);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
369 H = ops.H_dual;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
370
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
371 % Moment conditions
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
372 fs = cell(mom_cond,1);
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
373 for p = 0:mom_cond-1
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
374 fs{p+1} = @(x) (x/L).^p;
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
375 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
376
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
377 end
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
378
049e4c6fa630 Add dirac delta function, with corresponding test. Commented out tests for staggered grid because they do not yet exist on this branch.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
379