[Top][All Lists]

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

[Octave-bug-tracker] [bug #32924] lcm does not warn when losing precisio

From: Juan Pablo Carbajal
Subject: [Octave-bug-tracker] [bug #32924] lcm does not warn when losing precision
Date: Fri, 28 Feb 2014 09:21:04 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36

Follow-up Comment #19, bug #32924 (project octave):

In the mailing list we have a report about mod. The matlab implementation
indeed corrects the result when roundoff generates an answer different than
expected. Example follows

Gamma = 1.62e7;
duration = 10/Gamma;
dt = 0.0025/Gamma;
t   = 0:dt:duration;
y = mod (t, 0.2/Gamma);
find (y==0,3,'first')

1   241   401

Matlab r2008b
1    81   161

Reading the help of mod in matlab it says
MOD(x,y) is x - n.*y where n = floor(x./y) if y ~= 0.  If y is not an
    integer and the quotient x./y is within roundoff error of an integer,
    then n is that integer.

So indeed matlab is giving a result considering roundoff error, I assume they
do something like

function m = mod_ml(x,y)
  if fix(y) != y 
   err      = abs (x./y - round(x./y)) < sqrt (eps); 
   m       = mod (x,y); 
   m(err) = 0;

We could issue a warning as well. Shall I open a new bug(matlab
incompatibility) for mod?


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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