From 01c7c05771447053d8c27b0bf905b7835760aa95 Mon Sep 17 00:00:00 2001 From: "Colin B. Macdonald" Date: Thu, 21 Jan 2016 16:43:36 -0800 Subject: [PATCH 1/2] isempty(finiteset()) returns true Seems obvious but it might be dangerous: maybe somewhere in the code assumes isempty means one dimension of an array is zero (as is the case for matrices). For example: `e = finiteset()`, now `size(e)` gives `[1 1]` but `isempty(e)` is true. Also: `length(e)` gives 1. Maybe we need to overload `e` as well. --- inst/@sym/isempty.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/inst/@sym/isempty.m b/inst/@sym/isempty.m index cc4ebbe90..ee3f840a0 100644 --- a/inst/@sym/isempty.m +++ b/inst/@sym/isempty.m @@ -41,6 +41,12 @@ function r = isempty(x) + % special case + if (strcmp(char(e), 'EmptySet()')) + r = true; + return; + end + d = size(x); % Octave can have n x 0 and 0 x m empty arrays @@ -92,3 +98,8 @@ %! assert (isempty (A)) %! A = sym('A', [n 0]); %! assert (isempty (A)) + +%!test +%! % special case for empty set +%! e = finiteset(); +%! assert (isempty (e)) From 409b614c21b33fffe904c85236ad48e93c55f014 Mon Sep 17 00:00:00 2001 From: "Colin B. Macdonald" Date: Fri, 22 Jan 2016 00:21:00 -0800 Subject: [PATCH 2/2] typo fix --- inst/@sym/isempty.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/@sym/isempty.m b/inst/@sym/isempty.m index ee3f840a0..93f12af25 100644 --- a/inst/@sym/isempty.m +++ b/inst/@sym/isempty.m @@ -42,7 +42,7 @@ function r = isempty(x) % special case - if (strcmp(char(e), 'EmptySet()')) + if (strcmp(char(x), 'EmptySet()')) r = true; return; end