bugGNU Octave - Bugs: bug #65508, [octave forge] (mapping)...

 
 

bug #65508: [octave forge] (mapping) degrees2dm inaccuracy

Submitter:  None
Submitted:  Fri 22 Mar 2024 03:30:00 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  None Assigned to:  philipnienhuis
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * other
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 22 Mar 2024 08:46:14 PM UTC, comment #1: 

Thanks for this contribution.
I'll have a look, see also what I wrote in bug #65291.

Philip Nienhuis <philipnienhuis>
Group Member
Fri 22 Mar 2024 03:30:00 PM UTC, original submission:  

This is somewhat related to bug #65291 and I am the same "Anonymous" as has been posting there.

The degrees2dm function in the mapping package from https://sourceforge.net/p/octave/mapping/ci/default/tree/inst/degrees2dm.m has some accuracy issues.  For example, degrees2dm(realmax()) returns [realmax(), NaN] instead of [realmax(), 0], and degrees2dm (2e14 + 0.25) returns [2e14, 16] instead of [2e14, 15].

Attached is a version of degrees2dm.m with the following changes:

  • Documentation:
    • Specify that the minutes component will always have magnitude less than 60.
    • Adjust the first example to make everything exact and to demonstrate fractional minutes.
    • Remove the second example which was incorrect and is now redundant.
    • Correct a variable name mismatch in the last example.
    • Remove the negative sign (which does not seem to be displayed by default) from a zero in the result in the last example.
  • Implementation:
    • Reject non-real input.
    • Add special handling for char and logical input to improve performance and clarity.
    • Change the computation of the minutes to improve accuracy.  It should now always return the correctly rounded result (assuming fix(), subtraction, and multiplication are correctly rounded, which I expect is true).
      • Overflow for large inputs is avoided.
      • Minutes now depend only on the fractional part of the input.
      • Possible issues are avoided by not using the rem function.  Documentation for rem claims that "values within a few eps of an integer will be rounded to that integer before computation for compatibility with MATLAB", but I have failed to verify this.
    • Update the sign-flipping logic to account for the change to the computation of the minutes, and hopefully improve clarity.
    • Reject input types not explicitly handled.
      • This might be unreachable currently, but is intended to prevent applying the function to types where it hasn't been validated.  Not sure this is a good idea.
  • Tests:
    • Add tests which fail with the existing implementation.
    • Add tests which do not fail with the existing implementation, but do help demonstrate correctness.
  • Other:
    • Add `## Copyright (C) 2024 The Octave Project Developers` because I am offering this contribution anonymously.


Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #55880:  degrees2dm.m added by None (5KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

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
2024-03-22 philipnienhuis Assigned toNone philipnienhuis
2024-03-22 None Attached File- Added degrees2dm.m, #55880

Back to the top

Powered by Savane 3.13-02a9.
Corresponding source code