Octave and Freemat

Bateman David-ADB014 David.Bateman at motorola.com
Wed Mar 5 07:30:39 CST 2008


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.cae.wisc.edu/pipermail/octave-maintainers/attachments/20080305/c3ab9e2d/attachment.html 


More information about the Octave-maintainers mailing list