bugGNU Octave - Bugs: bug #41894, mod output ML incompatible

 
 

bug #41894: mod output ML incompatible

Submitter:  Juan Pablo Carbajal <juanpi>
Submitted:  Tue 18 Mar 2014 10:41:14 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  juanpi Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 12 Nov 2015 03:03:19 PM UTC, comment #2: 

I also see this fixed now. Closing as such.

Also, ML is a programming language https://en.wikipedia.org/wiki/ML_%28programming_language%29 and not short of Matlab.

Carnë Draug <carandraug>
Group Member
Thu 12 Nov 2015 07:01:59 AM UTC, comment #1: 


Checking with 4.0.0 on Windows:


>> 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')
ans =

     1    81   161


Avinoam Kalma <avinoam>
Group Member
Tue 18 Mar 2014 10:41:14 AM UTC, original submission:  

In the mailing list we have a report about MOD. The matlab implementation indeed corrects the result when roundoff error 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')

octave
1   241   401

Matlab r2008b
1    81   161


Reading the help of mod in matlab it says that the result of MOD
is x - n.*Y with n = floor(x./Y). 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;
  endif
endfunction


We could issue a warning as well.

This bug is related to bug #32924

Juan Pablo Carbajal <juanpi>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by juanpi (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-12 carandraug StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code