changeset 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 772365e2cf96
files +grid/funcToMatrix.m +grid/funcToPlotMatrix.m reshapeKronVector.m reshapeKronVectorTest.m reshapeToPlotMatrix.m reshapeToPlotMatrixTest.m
diffstat 6 files changed, 22 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+grid/funcToMatrix.m	Mon Feb 22 13:55:19 2016 +0100
@@ -0,0 +1,5 @@
+% Converts a gridfunction to a matrix
+% Takes a grid function and and a structured grid.
+function F = funcToMatrix(g, gf)
+    reshapeKronVector(gf, g.size());
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+grid/funcToPlotMatrix.m	Mon Feb 22 13:55:19 2016 +0100
@@ -0,0 +1,5 @@
+% Converts a gridfunction to a plot matrix
+% Takes a grid function and and a structured grid.
+function F = funcToPlotMatrix(g, gf)
+    reshapeToPlotMatrix(gf, g.size());
+end
\ No newline at end of file
--- a/reshapeKronVector.m	Mon Feb 22 13:34:50 2016 +0100
+++ b/reshapeKronVector.m	Mon Feb 22 13:55:19 2016 +0100
@@ -1,6 +1,5 @@
 % Takes a grid function and reshapes it into a matrix of shape m.
-% Called by class methods.
-function F = funcToMatrix(gf, m)
+function F = reshapeKronVector(gf, m)
     D = length(m);
 
     if D == 1
--- a/reshapeKronVectorTest.m	Mon Feb 22 13:34:50 2016 +0100
+++ b/reshapeKronVectorTest.m	Mon Feb 22 13:55:19 2016 +0100
@@ -1,4 +1,4 @@
-function tests = funcToMatrixTest()
+function tests = reshapeKronVectorTest()
     tests = functiontests(localfunctions);
 end
 
@@ -6,7 +6,7 @@
     inGf = [1 2 3 4 5]';
     inM = 5;
     out = [1 2 3 4 5]';
-    testCase.verifyEqual(grid.funcToMatrix(inGf, inM),out);
+    testCase.verifyEqual(reshapeKronVector(inGf, inM),out);
 end
 
 function test2D(testCase)
@@ -18,7 +18,7 @@
     out(2,1) = 21;
     out(2,2) = 22;
 
-    testCase.verifyEqual(grid.funcToMatrix(inGf, inM),out);
+    testCase.verifyEqual(reshapeKronVector(inGf, inM),out);
 end
 
 function test3D(testCase)
@@ -34,7 +34,7 @@
     out(2,2,1) = 221;
     out(2,2,2) = 222;
 
-    testCase.verifyEqual(grid.funcToMatrix(inGf, inM),out);
+    testCase.verifyEqual(reshapeKronVector(inGf, inM),out);
 end
 
 function testNonSquare(testCase)
@@ -91,5 +91,5 @@
     out(2,3,3) = 233;
     out(2,3,4) = 234;
 
-    testCase.verifyEqual(grid.funcToMatrix(inGf, inM), out);
+    testCase.verifyEqual(reshapeKronVector(inGf, inM), out);
 end
\ No newline at end of file
--- a/reshapeToPlotMatrix.m	Mon Feb 22 13:34:50 2016 +0100
+++ b/reshapeToPlotMatrix.m	Mon Feb 22 13:55:19 2016 +0100
@@ -1,10 +1,7 @@
 % Takes a grid function and reshapes it into a matrix of shape m for plotting.
-% Called by class methods.
-function F = funcToPlotMatrix(gf, m)
+function F = reshapeToPlotMatrix(gf, m)
     D = length(m);
 
-
-
     switch D
         case 1
             F = gf;
@@ -15,6 +12,6 @@
             p = [2 3 1]; % Permuation
             F = permute(reshape(gf,rot90(m,2)), p);
         otherwise
-            error('grid:funcToMatrix:NotImplemented','Grid function to matrix is not implemented for dimension = %d', length(m));
+            error('reshapeToPlotMatrix:NotImplemented','Grid function to matrix is not implemented for dimension = %d', length(m));
     end
 end
\ No newline at end of file
--- a/reshapeToPlotMatrixTest.m	Mon Feb 22 13:34:50 2016 +0100
+++ b/reshapeToPlotMatrixTest.m	Mon Feb 22 13:55:19 2016 +0100
@@ -1,4 +1,4 @@
-function tests = funcToPlotMatrixTest()
+function tests = reshapeToPlotMatrixTest()
     tests = functiontests(localfunctions);
 end
 
@@ -6,7 +6,7 @@
     inGf = [1 2 3 4 5]';
     inM = 5;
     out = [1 2 3 4 5]';
-    testCase.verifyEqual(grid.funcToPlotMatrix(inGf, inM),out);
+    testCase.verifyEqual(reshapeToPlotMatrix(inGf, inM),out);
 end
 
 function test2D(testCase)
@@ -24,7 +24,7 @@
 
     inM = [2, 3];
 
-    testCase.verifyEqual(grid.funcToPlotMatrix(inGf, inM),out);
+    testCase.verifyEqual(reshapeToPlotMatrix(inGf, inM),out);
 end
 
 function test3D(testCase)
@@ -44,5 +44,5 @@
 
     inM = [2, 3, 4];
 
-    testCase.verifyEqual(grid.funcToPlotMatrix(inGf, inM),out);
+    testCase.verifyEqual(reshapeToPlotMatrix(inGf, inM),out);
 end
\ No newline at end of file