Mercurial > repos > public > sbplib
annotate +blockmatrix/toMatrixTest.m @ 1031:2ef20d00b386 feature/advectionRV
For easier comparison, return both the first order and residual viscosity when evaluating the residual. Add the first order and residual viscosity to the state of the RungekuttaRV time steppers
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 17 Jan 2019 10:25:06 +0100 |
parents | a5f1b0267dba |
children |
rev | line source |
---|---|
206
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
1 function tests = toMatrixTest() |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
2 tests = functiontests(localfunctions); |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
3 end |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
4 |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
5 function testError(testCase) |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
6 testCase.verifyError(@()blockmatrix.toMatrix([]), 'blockmatrix:toMatrix:NotABlockmatrix') |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
7 end |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
8 |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
9 function testToMatrix(testCase) |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
10 cases = { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
11 { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
12 {}, |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
13 [], |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
14 }, |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
15 { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
16 {1, 2; 3, 4}, |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
17 [1,2; 3,4], |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
18 } |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
19 { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
20 { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
21 [2 2; 2 1], [1; 2]; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
22 [2 2], [1] |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
23 }, |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
24 [2 2 1; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
25 2 1 2; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
26 2 2 1], |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
27 }, |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
28 { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
29 { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
30 [2 2; 2 1], []; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
31 [2 2], [1] |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
32 }, |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
33 [2 2 0; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
34 2 1 0; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
35 2 2 1], |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
36 }, |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
37 { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
38 { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
39 [2 2; 2 1], []; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
40 [2 2], [] |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
41 }, |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
42 [2 2; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
43 2 1; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
44 2 2], |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
45 }, |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
46 { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
47 { |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
48 [2 2; 2 1], [1; 2]; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
49 [], [] |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
50 }, |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
51 [2 2 1; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
52 2 1 2], |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
53 }, |
579
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
54 { |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
55 {zeros(0,0)}, |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
56 [], |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
57 }, |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
58 { |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
59 {zeros(3,0), zeros(3,0)}, |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
60 zeros(3,0), |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
61 }, |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
62 { |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
63 {zeros(3,0); zeros(2,0)}, |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
64 zeros(5,0), |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
65 }, |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
66 { |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
67 {zeros(0,3), zeros(0,2)}, |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
68 zeros(0,5), |
a5f1b0267dba
Be less strict about what is considered a block matrix
Jonatan Werpers <jonatan@werpers.com>
parents:
206
diff
changeset
|
69 }, |
206
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
70 }; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
71 |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
72 for i = 1:length(cases) |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
73 in = cases{i}{1}; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
74 out = full(blockmatrix.toMatrix(in)); |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
75 expected = cases{i}{2}; |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
76 testCase.verifyEqual(out, expected); |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
77 end |
50a323da7c7f
blockmatrix: Added function to convert blockmatrix to a regular matrix.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
78 end |