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

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

[Octave-bug-tracker] [bug #65508] [octave forge] (mapping) degrees2dm in


From: anonymous
Subject: [Octave-bug-tracker] [bug #65508] [octave forge] (mapping) degrees2dm inaccuracy
Date: Fri, 22 Mar 2024 11:30:00 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?65508>

                 Summary: [octave forge] (mapping) degrees2dm inaccuracy
                   Group: GNU Octave
               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: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: other
         Discussion Lock: Any
        Operating System: Any
           Fixed Release: None
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Fri 22 Mar 2024 03:30:00 PM UTC By: Anonymous
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.
                * Signs (including of zeros) should match MATLAB R2023b.  See
https://savannah.gnu.org/bugs/?65291#comment13 for source of MATLAB behavior.
        * 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.







    _______________________________________________________
File Attachments:


-------------------------------------------------------
Name: degrees2dm.m  Size: 5KiB
<http://savannah.gnu.org/bugs/download.php?file_id=55880>

    AGPL NOTICE

These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://git.savannah.nongnu.org/cgit/administration/savane.git/snapshot/savane-0ba62ed3a038e8b50b65b09fae7f127f4f071c33.tar.gz

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65508>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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