Mercurial > repos > public > sbplib
comparison diracDiscrTest.m @ 1243:4e0b88f3def1 feature/dirac_discr
Use rng(1) to set seed in diracDiscrTest because hex-speak crashed.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Tue, 19 Nov 2019 17:11:33 -0800 |
parents | f1806475498b |
children | 25efceb0c392 |
comparison
equal
deleted
inserted
replaced
1242:ff613067dec6 | 1243:4e0b88f3def1 |
---|---|
1 function tests = diracDiscrTest() | 1 function tests = diracDiscrTest() |
2 tests = functiontests(localfunctions); | 2 tests = functiontests(localfunctions); |
3 end | 3 end |
4 | 4 |
5 %TODO: | 5 %TODO: |
6 % 1. Test discretizing with smoothness conditions. | 6 % 1. Test discretizing with smoothness conditions. |
7 % Only discretization with moment conditions currently tested. | 7 % Only discretization with moment conditions currently tested. |
8 % 2. Test using other types of grids. Only equidistant grids currently used. | 8 % 2. Test using other types of grids. Only equidistant grids currently used. |
9 | 9 |
10 function testLeftRandom(testCase) | 10 function testLeftRandom(testCase) |
11 | 11 |
12 orders = [2, 4, 6]; | 12 orders = [2, 4, 6]; |
13 mom_conds = orders; | 13 mom_conds = orders; |
14 rng(0xDABBAD00) % Set seed. Jabba-dabba-doooo! | 14 rng(1) % Set seed |
15 | 15 |
16 for o = 1:length(orders) | 16 for o = 1:length(orders) |
17 order = orders(o); | 17 order = orders(o); |
18 mom_cond = mom_conds(o); | 18 mom_cond = mom_conds(o); |
19 [g, H, fs] = setup1D(order, mom_cond); | 19 [g, H, fs] = setup1D(order, mom_cond); |
40 | 40 |
41 function testRightRandom(testCase) | 41 function testRightRandom(testCase) |
42 | 42 |
43 orders = [2, 4, 6]; | 43 orders = [2, 4, 6]; |
44 mom_conds = orders; | 44 mom_conds = orders; |
45 rng(0xDABBAD00) % Set seed. Jabba-dabba-doooo! | 45 rng(1) % Set seed |
46 | 46 |
47 for o = 1:length(orders) | 47 for o = 1:length(orders) |
48 order = orders(o); | 48 order = orders(o); |
49 mom_cond = mom_conds(o); | 49 mom_cond = mom_conds(o); |
50 [g, H, fs] = setup1D(order, mom_cond); | 50 [g, H, fs] = setup1D(order, mom_cond); |
71 | 71 |
72 function testInteriorRandom(testCase) | 72 function testInteriorRandom(testCase) |
73 | 73 |
74 orders = [2, 4, 6]; | 74 orders = [2, 4, 6]; |
75 mom_conds = orders; | 75 mom_conds = orders; |
76 rng(0xDABBAD00) % Set seed. Jabba-dabba-doooo! | 76 rng(1) % Set seed |
77 | 77 |
78 for o = 1:length(orders) | 78 for o = 1:length(orders) |
79 order = orders(o); | 79 order = orders(o); |
80 mom_cond = mom_conds(o); | 80 mom_cond = mom_conds(o); |
81 [g, H, fs] = setup1D(order, mom_cond); | 81 [g, H, fs] = setup1D(order, mom_cond); |
220 | 220 |
221 function testAllRandom2D(testCase) | 221 function testAllRandom2D(testCase) |
222 | 222 |
223 orders = [2, 4, 6]; | 223 orders = [2, 4, 6]; |
224 mom_conds = orders; | 224 mom_conds = orders; |
225 rng(0xDABBAD00) % Set seed. Jabba-dabba-doooo! | 225 rng(1) % Set seed |
226 | 226 |
227 for o = 1:length(orders) | 227 for o = 1:length(orders) |
228 order = orders(o); | 228 order = orders(o); |
229 mom_cond = mom_conds(o); | 229 mom_cond = mom_conds(o); |
230 [g, H, fs] = setup2D(order, mom_cond); | 230 [g, H, fs] = setup2D(order, mom_cond); |
233 xl = g.lim{1}{1}; | 233 xl = g.lim{1}{1}; |
234 xr = g.lim{1}{2}; | 234 xr = g.lim{1}{2}; |
235 yl = g.lim{2}{1}; | 235 yl = g.lim{2}{1}; |
236 yr = g.lim{2}{2}; | 236 yr = g.lim{2}{2}; |
237 h = g.scaling(); | 237 h = g.scaling(); |
238 | 238 |
239 | 239 |
240 % Test random points, even outside grid | 240 % Test random points, even outside grid |
241 Npoints = 100; | 241 Npoints = 100; |
242 x0s = [(xl-3*h(1)) + (xr-xl+6*h(1))*rand(Npoints,1), ... | 242 x0s = [(xl-3*h(1)) + (xr-xl+6*h(1))*rand(Npoints,1), ... |
243 (yl-3*h(2)) + (yr-yl+6*h(2))*rand(Npoints,1) ]; | 243 (yl-3*h(2)) + (yr-yl+6*h(2))*rand(Npoints,1) ]; |
293 | 293 |
294 function testAllRandom3D(testCase) | 294 function testAllRandom3D(testCase) |
295 | 295 |
296 orders = [2, 4, 6]; | 296 orders = [2, 4, 6]; |
297 mom_conds = orders; | 297 mom_conds = orders; |
298 rng(0xDABBAD00) % Set seed. Jabba-dabba-doooo! | 298 rng(1) % Set seed |
299 | 299 |
300 for o = 1:length(orders) | 300 for o = 1:length(orders) |
301 order = orders(o); | 301 order = orders(o); |
302 mom_cond = mom_conds(o); | 302 mom_cond = mom_conds(o); |
303 [g, H, fs] = setup3D(order, mom_cond); | 303 [g, H, fs] = setup3D(order, mom_cond); |