Changed logic in the routine performing lexicographic comparison of vectors.

time-shift
Stéphane Adjemian (Charybdis) 2013-10-11 12:09:31 +02:00
parent be32e645af
commit 6fff2fe75b
1 changed files with 13 additions and 7 deletions

View File

@ -42,14 +42,20 @@ if ~ismember(func2str(f),{'lt', 'gt', 'le', 'ge'})
error('compare_vectors:: First input argument must be one of the following function handles: @lt, @gt, @le or @ge!')
end
if feval(f, A(1), B(1))
C = 1;
elseif isequal(A(1),B(1)) && length(A)>1
C = compare_vectors(f, A(2:end), B(2:end));
elseif isequal(A(1),B(1)) && isequal(length(A),1) && ismember(func2str(f),{'le', 'ge'})
C = 1;
if isequal(length(A),1)
if feval(f, A, B)
C = 1;
else
C = 0;
end
else
C = 0;
if feval(f, A(1), B(1))
C = 1;
elseif isequal(A(1),B(1))
C = compare_vectors(f, A(2:end), B(2:end));
else
C = 0;
end
end
%@test:1