bugGNU Octave - Bugs: bug #43717, rats LEN Matlab incompatibility -...

 
 

bug #43717: rats LEN Matlab incompatibility - default string length change

Submitter:  Andreas Weber <andy1978>
Submitted:  Thu 27 Nov 2014 08:27:40 PM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  WTF, Matlab?!?
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  9.1.0 Planned Release:  9.1.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 13 Oct 2023 07:08:36 PM UTC, comment #6: 

No complaints in a month. Closing as fixed.

Arun Giridhar <arungiridhar>
Group Member
Tue 12 Sep 2023 07:50:41 PM UTC, comment #5: 

patch refreshed for current default branch. Only change was pointing to the current NEWS file.  Otherwise applies clean.  Successfully built and passes a make check. 

pushed to default as http://hg.savannah.gnu.org/hgweb/octave/rev/7e8a3299b866

marking as ready for test.

Nicholas Jankowski <nrjank>
Group Member
Thu 02 Dec 2021 07:30:53 PM UTC, comment #4: 

patch with actual commit message attached :)

(file #52409)

Nicholas Jankowski <nrjank>
Group Member
Thu 02 Dec 2021 07:27:45 PM UTC, comment #3: 

following comment #2, the attached patch changes the default length from 9 to 13.  the change is fairly minor, and seems to be unrelated to any tests, but as I'm not set up to compile/test someone else should make sure it doesn't trigger anything unexpected.

if no issues and there's no intent to mirror matlab's odd length behavior, could probably push this tweak then close the report.

(file #52408)

Nicholas Jankowski <nrjank>
Group Member
Thu 06 Jun 2019 03:49:24 PM UTC, comment #2: 

The documentation for Matlab now makes this quite clear.  According to them, the construction of a rational approximation with rats() is done via the function rat and a tolerance.


[N,D] = rat(X,tol)
where tol is min(10^(-(strlen-1)/2)*norm(X(isfinite(X)),1),.1)


I agree with the original reporter that I wouldn't bother to fix this as Octave's solution seems better.

One thing I do notice is that Matlab seems to have changed the default length to 13 from 9.  Should Octave make that change?


Rik <rik5>
Group administrator
Tue 01 May 2018 08:35:11 PM UTC, comment #1: 

Still present. It seems to me that Matlab is trying to ensure that at least one space is included at the start and end of the string, so that the strings can always be safely concatenated end-to-end.

Mike Miller <mtmiller>
Group Member
Thu 27 Nov 2014 08:27:40 PM UTC, original submission:  

Octave tries to find an approximation which fits into LEN (second arg of rats) but Matlab seems to do some fancy stuff to calculate a tolerance from the input vector X and LEN and then call rat with this tolerance. The strings returned from Matlab are often less shorter than LEN even if a better approximation would be possible.

For example octave returns 22/7 for rats(pi, 4) whereas Matlab returns "  *", see http://octave.1599824.n4.nabble.com/Matlab-output-from-quot-rats-quot-wanted-tt4667406.html and the Matlab documentation under More About - Algorithms.

Personally I think Octave's behaviour is much better here but I want to document this here.

If someone want to investigate this further: Try a changeset after c490eac28bbb which fixed an overflow in rats (#43369).

Andreas Weber <andy1978>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #52409:  rats_defaultLength_bug43717v2.diff added by nrjank (2KiB - application/octet-stream)
file #52408:  rats_defaultLength_bug43717.diff added by nrjank (1KiB - application/octet-stream - patch to change default length from 9 to 13 and note change in docs)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arungiridhar (Posted a comment)
  • -email is unavailable- added by nrjank (Updated the item)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by andy1978 (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 15 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-10-13 arungiridhar StatusReady For Test Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 9.1.0
    2023-09-12 nrjank StatusPatch Submitted Ready For Test
        Planned ReleaseNone 9.1.0
        Summaryrats LEN Matlab incompatibility rats LEN Matlab incompatibility - default string length change
    2021-12-02 nrjank Attached File- Added rats_defaultLength_bug43717v2.diff, #52409
        StatusNeed Info Patch Submitted
    2021-12-02 nrjank Attached File- Added rats_defaultLength_bug43717.diff, #52408
    2019-06-06 mtmiller Carbon-CopyRemoved 80942 -
    2019-06-06 rik5 StatusNone Need Info
    2018-05-01 mtmiller Severity3 - Normal 2 - Minor
        Release3.8.2 dev
    2015-01-01 andy1978 Item GroupMatlab Compatibility WTF, Matlab?!?
    2014-12-31 rik5 Priority5 - Normal 3 - Low

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code