diff +blockmatrix/zeroTest.m @ 207:d521e17f72b6 feature/grids

blockmatrix: Added function to create zero blockmatrices.
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 15 Jun 2016 16:55:40 +0200
parents
children a5f1b0267dba
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+blockmatrix/zeroTest.m	Wed Jun 15 16:55:40 2016 +0200
@@ -0,0 +1,52 @@
+function tests = zeroTest()
+    tests = functiontests(localfunctions);
+end
+
+function testZero(testCase)
+    cases = {
+        {
+            {[],[]},
+            {},
+        },
+        {
+            {0,0},
+            {[]};
+        },
+        {
+            {1,1},
+            {0};
+        },
+        {
+            {2,1},
+            {[0; 0]};
+        },
+        {
+            {1,2},
+            {[0 0]};
+        },
+        {
+            {[1 2],2},
+            {[0 0];[0 0; 0 0]};
+        },
+        {
+            {[1 2],[2 1]},
+            {[0 0],[0];[0 0; 0 0],[0; 0]};
+        },
+    };
+
+    for i = 1:length(cases)
+        out = convertToFull(blockmatrix.zero(cases{i}{1}));
+        expected = cases{i}{2};
+        testCase.verifyEqual(out,expected);
+    end
+end
+
+
+function C = convertToFull(C)
+    [N,M] = size(C);
+    for i = 1:N
+        for j = 1:M
+            C{i,j} = full(C{i,j});
+        end
+    end
+end
\ No newline at end of file