Octave and Freemat
Ben Abbott
bpabbott at mac.com
Wed Mar 5 07:51:33 CST 2008
Of course you are correct. It was too early in the morning for me to
be doing any "real" work ... I inadvertently neglected to pull the
changes from John before testing them :-(
On Mar 5, 2008, at 8:30 AM, Bateman David-ADB014 wrote:
> There is no error with the code I sent. You get a warning of a
> divide by zero and a 0-by-0 matrix is returned correctly with
> roots(0). matalbR2007b returns a 0-by-1 empty matrix, but that is
> the only difference..
>
> D.
>
>
> -----Original Message-----
>
> Regarding this part,
>
> > + if (isempty (v))
> > + f = v;
> > + else
> > + f = find (v ./ max (abs (v)));
> > + endif
> > + m = numel (f);
>
> It appears an error will result if v = 0. Which should return [].
> Perhaps something like that below?
>
> f = find (v);
> if (any (f))
> v = v ./ max (abs (v));
> f = find (v);
> endif
> m = numel (f);
>
> The first test below tests this concern, and the second tests for a
> "special" features of Matlab's implementation, which apparently is
> consistent with the above since the check for Inf is done prior to
> "v ./ max (abs (v))".
>
> %!assert(isempty (roots (0)));
>
> %!assert(roots([realmin, realmax, realmax]), -1)
>
> Ben
More information about the Octave-maintainers
mailing list