[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with sum (...)
From: |
Ben Abbott |
Subject: |
Re: problem with sum (...) |
Date: |
Sun, 4 Nov 2007 22:08:03 -0500 |
On Nov 4, 2007, at 8:50 PM, Ben Abbott wrote:
On Nov 4, 2007, at 1:00 PM, Søren Hauberg wrote:
Ben Abbott skrev:
In any event, you've done quite a bit more work on this than I. I
had added some additional tests to my version that produced
failures in the original. They pass in yours.
Are these tests part of the current set of tests? If not, then
please send them so they can be part of the test suite.
I've managed to break your efforts :-(
The problem is with these lines ...
a = cellstr(num2str(a))
S = cellstr(num2str(S))
The support for "rows" only works in the event that num2str()
returns the same number of characters for each member of 'a' and 'S'
Søren,
Not a pretty solution, but this code below corrects the error. I'll
defer to you on whether it should be included or if more work is needed.
----------------------------
## We currently handle the 'rows' argument in a fairly ugly way.
## The numbers are converted to strings and then to a cell array
of strings.
## We need this dirty hack because we can only compare cell arrays
when
## they contain strings (using 'strcmp').
if (nargin == 3)
if (strcmp (rows_opt, "rows") && ismatrix (a) && ismatrix (S) &&
columns (a) == columns (S))
# a = cellstr(num2str(a))
# S = cellstr(num2str(S))
rS = rows (S);
ra = rows (a);
index = zeros (ra,1);
for r = 1:ra
tmp = ones (rS,1) * a(r,:);
f = find (all (tmp' == S'), 1);
if ! isempty (f)
index(r) = f;
end
end
c = logical (index);
return
else
error ("ismember: with 'rows' both sets must be matrices with
an equal number of columns");
endif
endif
----------------------------
Thoughts?
Ben
- problem with sum (...), Ben Abbott, 2007/11/03
- proposed patch for ismember.m, Ben Abbott, 2007/11/06
- proposed patch for ismember.m, John W. Eaton, 2007/11/07
- Re: proposed patch for ismember.m, Ben Abbott, 2007/11/07
- Re: proposed patch for ismember.m, John W. Eaton, 2007/11/07
- Re: proposed patch for ismember.m, Ben Abbott, 2007/11/07
- Re: proposed patch for ismember.m, John W. Eaton, 2007/11/07
- Re: proposed patch for ismember.m, Ben Abbott, 2007/11/08
Re: problem with sum (...), David Bateman, 2007/11/05