comparison reshapeKronVectorTest.m @ 163:51aaf67a7df5 feature/grids

Fixed naming and added functions for converting vectors to matrices for structured grid.
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 22 Feb 2016 13:55:19 +0100
parents c75c03f692b3
children
comparison
equal deleted inserted replaced
162:c75c03f692b3 163:51aaf67a7df5
1 function tests = funcToMatrixTest() 1 function tests = reshapeKronVectorTest()
2 tests = functiontests(localfunctions); 2 tests = functiontests(localfunctions);
3 end 3 end
4 4
5 function test1D(testCase) 5 function test1D(testCase)
6 inGf = [1 2 3 4 5]'; 6 inGf = [1 2 3 4 5]';
7 inM = 5; 7 inM = 5;
8 out = [1 2 3 4 5]'; 8 out = [1 2 3 4 5]';
9 testCase.verifyEqual(grid.funcToMatrix(inGf, inM),out); 9 testCase.verifyEqual(reshapeKronVector(inGf, inM),out);
10 end 10 end
11 11
12 function test2D(testCase) 12 function test2D(testCase)
13 inGf = [11; 12; 21; 22]; 13 inGf = [11; 12; 21; 22];
14 inM = [2, 2]; 14 inM = [2, 2];
16 out(1,1) = 11; 16 out(1,1) = 11;
17 out(1,2) = 12; 17 out(1,2) = 12;
18 out(2,1) = 21; 18 out(2,1) = 21;
19 out(2,2) = 22; 19 out(2,2) = 22;
20 20
21 testCase.verifyEqual(grid.funcToMatrix(inGf, inM),out); 21 testCase.verifyEqual(reshapeKronVector(inGf, inM),out);
22 end 22 end
23 23
24 function test3D(testCase) 24 function test3D(testCase)
25 inGf = [111; 112; 121; 122; 211; 212; 221; 222]; 25 inGf = [111; 112; 121; 122; 211; 212; 221; 222];
26 inM = [2, 2, 2]; 26 inM = [2, 2, 2];
32 out(2,1,1) = 211; 32 out(2,1,1) = 211;
33 out(2,1,2) = 212; 33 out(2,1,2) = 212;
34 out(2,2,1) = 221; 34 out(2,2,1) = 221;
35 out(2,2,2) = 222; 35 out(2,2,2) = 222;
36 36
37 testCase.verifyEqual(grid.funcToMatrix(inGf, inM),out); 37 testCase.verifyEqual(reshapeKronVector(inGf, inM),out);
38 end 38 end
39 39
40 function testNonSquare(testCase) 40 function testNonSquare(testCase)
41 inGf = [ 41 inGf = [
42 111; 42 111;
89 out(2,3,1) = 231; 89 out(2,3,1) = 231;
90 out(2,3,2) = 232; 90 out(2,3,2) = 232;
91 out(2,3,3) = 233; 91 out(2,3,3) = 233;
92 out(2,3,4) = 234; 92 out(2,3,4) = 234;
93 93
94 testCase.verifyEqual(grid.funcToMatrix(inGf, inM), out); 94 testCase.verifyEqual(reshapeKronVector(inGf, inM), out);
95 end 95 end