octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave and Freemat


From: Ben Abbott
Subject: Re: Octave and Freemat
Date: Wed, 5 Mar 2008 08:51:33 -0500

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]