changeset 703:027f606fa691 feature/optim

megre with default
author Ylva Rydin <ylva.rydin@telia.com>
date Fri, 03 Nov 2017 10:43:27 +0100
parents 40299ae5fabe (current diff) 2ce903f28193 (diff)
children 111fcbcff2e9
files
diffstat 3 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Cell.m	Fri Oct 20 09:43:07 2017 +0200
+++ b/Cell.m	Fri Nov 03 10:43:27 2017 +0100
@@ -23,6 +23,10 @@
             s = size(A.data);
         end
 
+        function b = isempty(A)
+            b = prod(size(A)) == 0;
+        end
+
         function l = length(A)
             l = length(A.data);
         end
--- a/CellTest.m	Fri Oct 20 09:43:07 2017 +0200
+++ b/CellTest.m	Fri Nov 03 10:43:27 2017 +0100
@@ -36,6 +36,21 @@
     end
 end
 
+function testIsEmpty(testCase)
+    cases = {
+        {cell(0,0), true},
+        {cell(1,0), true},
+        {cell(0,1), true},
+        {cell(1,1), false},
+    };
+
+    for i = 1:length(cases)
+        A = Cell(cases{i}{1});
+        expected = cases{i}{2};
+        testCase.verifyEqual(isempty(A),expected);
+    end
+end
+
 function testTranspose(testCase)
     testCase.verifyEqual(Cell({1i, 2}).', Cell({1i; 2}));
     testCase.verifyEqual(Cell({1i; 2}).', Cell({1i, 2}));
--- a/spdiag.m	Fri Oct 20 09:43:07 2017 +0200
+++ b/spdiag.m	Fri Nov 03 10:43:27 2017 +0100
@@ -1,5 +1,10 @@
 function A = spdiag(a,i)
     default_arg('i',0);
+
+    if isrow(a)
+        a = a';
+    end
+
     n = length(a)-abs(i);
     A = spdiags(a,i,n,n);
 end
\ No newline at end of file