[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
an unreported fix to union.m
From: |
Juan Pablo Carbajal |
Subject: |
an unreported fix to union.m |
Date: |
Fri, 31 Jul 2015 13:02:38 +0200 |
Hi,
The developer of this software (see commments)
http://journal.frontiersin.org/article/10.3389/fninf.2013.00008/abstract
fixed an compatibility issue in union.m of octave. Of course the fix
is not compatible with Octave standards. However if we need this fix I
will port it.
The difference is
--- /home/juanpi/Devel/octave/default/scripts/set/union.m
+++ /home/juanpi/Downloads/ndt.1.0.4_exported/octave_code/union.m
@@ -40,7 +40,7 @@
## @seealso{unique, intersect, setdiff, setxor, ismember}
## @end deftypefn
-## Author: jwe
+## Author: jwe, modified by Ethan Meyers 2015
function [y, ia, ib] = union (a, b, varargin)
@@ -48,11 +48,35 @@
print_usage ();
endif
- [a, b] = validsetargs ("union", a, b, varargin{:});
+
by_rows = nargin == 3;
isrowvec = isvector (a) && isvector (b) && isrow (a) && isrow (b);
+
+ % Modified by Ethan to deal with creating a union between an empty
vector and a cell array
+ if isempty(a)
+ if by_rows
+ y = unique(b, 'rows');
+ else
+ y = unique(b);
+ end
+ return
+ end
+
+ if isempty(b)
+ if by_rows
+ y = unique(a, 'rows');
+ else
+ y = unique(a);
+ end
+ return
+ end
+
+
+ [a, b] = validsetargs ("union", a, b, varargin{:});
+
+
if (by_rows)
y = [a; b];
else
Comments?
- an unreported fix to union.m,
Juan Pablo Carbajal <=