bugGNU Octave - Bugs: bug #32692, incorrect tick values when using...

 
 

bug #32692: incorrect tick values when using fltk, fix is suggested

Submitted by:  None
Submitted on:  Sun 06 Mar 2011 05:12:09 PM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Jim O'BrienOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.4.0
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 16 Mar 2011 05:52:04 AM UTC, comment #3:

Patch applied to development code in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/919cadf334f8). See http://www.gnu.org/software/octave/download.html for instructions on downloading and building from Mercurial sources in order to access this fix.

Rik <rik5>
Project Administrator
Thu 10 Mar 2011 10:43:18 PM UTC, comment #2:

Thanks, Marco, for looking at this. I am using an AMD V120 single core chip (laptop). I'm wondering if anyone else finds this sort of problem. I compiled with standard settings on configure, too.

Last night I looked at "C++" on wikipedia, and reference 30 links to the spoof of Bjarne Stroustrup's later thoughts on C++ (Jan 1 1998). A real hoot! But perhaps relates to some of the code in OCTAVE (???)

Again, thanks. --- Jim O'Brien

Anonymous
Thu 10 Mar 2011 01:53:57 PM UTC, comment #1:

Although I cannot reproduce the rounding error, I think that the suggested clean fix is a much smarter implementation for magform and I submit a patch for it.

Marco

(file #22877)

Marco Caliari <caliari>
Project Member
Sun 06 Mar 2011 05:12:09 PM UTC, original submission:

A rounding error in magform routine in graphics.cc causes bad tick values for axis.

To recreate problem: using fltk, and command image(rand(25,900)*40), the x axis is labelled with about 40 or 50 scrunched numbers. For rand(25, something_else), we may see good or bad results.

I traced to routine magform, which takes a number, say 25.12345, computes its log, say 1.345678..., takes the fractional part (.345678) and subtracts from the log, to get 1.000000, but might get 0.9999999. When followed by int cast, the exponent is 0 or 1.

Here is my kludgy fix, and then a clean fix suggested:

ORIGINAL CODE:
double l = std::log10 (std::abs (x));
double r = std::fmod (l, 1.);
a = std::pow (10.0, r);
b = static_cast<int> (l-r);
if (a < 1)
{
a *= 10;
b -= 1;
}

if (x < 0)
a = -a;
KLUDGY FIX:
double l = std::log10 (std::abs (x));
double r = std::fmod (l, 1.);
a = std::pow (10.0, r);
double k = l-r; // JOB fix rounding problem, March 6, 2011
if (k < 0.0)
b = (int) (k - 0.5);
else
b = (int) (k + 0.5);
if (a < 1)
{
a *= 10;
b -= 1;
}

if (x < 0)
a = -a;
CLEAN FIX: (I've not tested, but should work fine)
b = static_cast<int> ( gnulib::floor (std::log10 (std::abs (x) ) ) );
a = x / std::pow (10.0, b);
END OF FIX (this is very short and compact solution)

Oddly, I've not seen this bug previously reported, so it may have to do with the floating point implementation on my chipset, or the use of guard bits in the fp registers ?

This routine magform, is also called with backend gnuplot. The incorrect tick values are computed, but then the plot appears correct -- perhaps gnuplot redoes the scaling on its own.

I have this version of fltk: fltk-1.1.10-1.fc13.i686

This is my first bug submission, sorry if its format turns out poor.

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #22877:  graphics.cc.patch added by caliari (806B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by caliari (Updated the item)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 16 Mar 2011 05:52:04 AM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Thu 10 Mar 2011 01:53:57 PM UTCcaliariAttached File-=>Added graphics.cc.patch, #22877

    Back to the top


    Powered by Savane 3.1-cleanup1