octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #42627] rem() treats inaccuracy differently fr


From: Olaf Till
Subject: [Octave-bug-tracker] [bug #42627] rem() treats inaccuracy differently from Matlab
Date: Thu, 26 Jun 2014 18:21:25 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20140610 Firefox/24.0 Iceweasel/24.6.0

URL:
  <http://savannah.gnu.org/bugs/?42627>

                 Summary: rem() treats inaccuracy differently from Matlab
                 Project: GNU Octave
            Submitted by: i7tiol
            Submitted on: Thu 26 Jun 2014 06:21:25 PM GMT
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Olaf Till
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

As reported in this thread

http://lists.gnu.org/archive/html/help-octave/2014-06/msg00349.html


octave:1> rem(0.94,0.01)
ans =  0.0100000


while in Matlab the result is reported to be zero.

In function xrem() in liboctave/numeric/lo-mappers.h (tip of
default branch), for

xrem (x, y) and q defined as q := x / y,

there is a case distinction for abs(x) <= 1 or > 1. For abs(x) > 1, q is
adjusted to an integer if its calculated deviation from an integer is less
than roughly the accuracy (epsilon * q) with which q is represented (by a
double in this case), which seems ok. But for abs(x) <= 1, the assumed
accuracy of q seems to be just epsilon, not epsilon * q. A test showed me that
if the case
abs(x) <= 1 were not treated special, the result would be zero (eps was
2.22044604925031e-16, abs(q-94) was greater than eps (1.42108547152020e-14,
this is the special treatment of abs(x) <= 1), and abs(q-94)/94 was less than
eps (1.51179305480872e-16, this is without the special treatment)).

The special treatment of abs(x) <= 1 is done the same way also for xmod.

I don't see the reason for this special treatment. It was introduced with this
changeset:

changeset:   11209:94d9d412a2a0
user:        John W. Eaton <address@hidden>
date:        Tue Nov 09 00:57:49 2010 -0500
summary:     improve Matlab compatibility of rem and mod

when the code was still in lo-mappers.cc, not lo-mappers.h. If Matlab
compatibility was the reason, than according to the current user report the
reason does not apply anymore.





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?42627>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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