diff +blockmatrix/isDivision.m @ 886:8894e9c49e40 feature/timesteppers

Merge with default for latest changes
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 15 Nov 2018 16:36:21 -0800
parents a5f1b0267dba
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+blockmatrix/isDivision.m	Thu Nov 15 16:36:21 2018 -0800
@@ -0,0 +1,34 @@
+function b = isDivision(div)
+    % Make sure it is a cellarray
+    if ~iscell(div)
+        b = false;
+        return
+    end
+
+    % Make sure it has the right shape
+    if numel(div) ~= 2
+        b = false;
+        return
+    end
+
+    if ~isDivisionVector(div{1}) || ~isDivisionVector(div{2})
+        b = false;
+        return
+    end
+
+    b = true;
+end
+
+function b = isDivisionVector(v)
+    if isempty(v)
+        b = true;
+        return
+    end
+
+    if any(v < 0)
+        b = false;
+        return
+    end
+
+    b = true;
+end