bugGNU Octave - Bugs: bug #53083, fixed_point_format: incorrect...

 
 

bug #53083: fixed_point_format: incorrect alignment

Submitter:  nicodemus <nicmus>
Submitted:  Wed 07 Feb 2018 08:56:57 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 21 Sep 2019 04:38:07 AM UTC, comment #8: 

I checked in a change that prints true zeros as "0" without the decimal point and further digits.  As an example of the new behavior,


octave:1> fixed_point_format (true)
octave:2> x = [-1e-11;0;1e11]
x =

  1.0e+11 *

  -0.00000
         0
   1.00000


Marking as fixed and closing report.

Rik <rik5>
Group administrator
Fri 23 Mar 2018 04:38:23 PM UTC, comment #7: 

I'm reopening this as a feature request because I think it would be useful to display exact zero values as 0 instead of 0.00000, especially in the fixed-point format.

Note that only exact zero values are displayed as 0 instead of 0.00000 and doing this gives a visual clue that the values displayed as 0.00000 are not actually zero, but are so much different from the other values that none of the significant digits are shown.

With Octave's default format this is not as much of a problem because the format will automatically switch to an E format when the range of magnitudes becomes too large to display significant digits of the largest and smallest values without using exponents.

John W. Eaton <jwe>
Group administrator
Wed 07 Mar 2018 05:23:50 PM UTC, comment #6: 

You might file a new feature request about this.  It isn't related to fixed_point_format.  Rather, Octave looks through the numbers of the matrix and determines the best printf format that works with all of them.  If they are all integers then Octave won't print a decimal point.  For example,


octave:2> x = full (diag (1:3))
x =

   1   0   0
   0   2   0
   0   0   3


But when one of the numbers is a floating point, it uses a common format that correctly displays floating point and integers.  For example,


octave:3> x(1) = pi
x =

   3.14159   0.00000   0.00000
   0.00000   2.00000   0.00000
   0.00000   0.00000   3.00000


I don't think this will be changed, but you could file a Feature Request for it.

Another possibility, for only seeing the non-zero entries, is to convert the full matrix to a true sparse matrix.  For example,


octave:4> x = sparse (x)
x =

Compressed Column Sparse (rows = 3, cols = 3, nnz = 3 [33%])

  (1, 1) ->  3.1416
  (2, 2) ->  2
  (3, 3) ->  3



Rik <rik5>
Group administrator
Wed 07 Mar 2018 01:56:39 PM UTC, comment #5: 

sorry forgot to put code environment


Example compare


   -0.2310         0         0   -0.1010
   -0.5470   -0.6522         0         0
   -0.6340         0   -0.1111         0
         0         0         0   -0.2343


with


   -0.2310    0.0000    0.0000   -0.1010
   -0.5470   -0.6522    0.0000    0.0000
   -0.6340    0.0000   -0.1111    0.0000
    0.0000    0.0000    0.0000   -0.2343


nicodemus <nicmus>
Wed 07 Mar 2018 01:53:31 PM UTC, comment #4: 

Hi, a slight difference in display between current version of MATLAB and Octave with fixed_point_format is how 0 is printed.

MATLAB prints simply 0
Octave prints 0.0000

In case of sparse matrices I find MATLAB output easier to read.

Example compare

   -0.2310         0         0   -0.1010
   -0.5470   -0.6522         0         0
   -0.6340         0   -0.1111         0
         0         0         0   -0.2343

with

   -0.2310    0.0000    0.0000   -0.1010
   -0.5470   -0.6522    0.0000    0.0000
   -0.6340    0.0000   -0.1111    0.0000
    0.0000    0.0000    0.0000   -0.2343

nicodemus <nicmus>
Sun 11 Feb 2018 06:28:11 PM UTC, comment #3: 

I fixed the alignment of negative number in fixed point format on the development branch in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/5be92b26ef8f).  This will be a part of the 3.4.0 release.

Rik <rik5>
Group administrator
Fri 09 Feb 2018 06:41:26 PM UTC, comment #2: 

This behavior has never been truly correct.  I just checked with prior versions of Octave back to 3.0.5 which is in the 2007 timeframe, and they all get this wrong.

Rik <rik5>
Group administrator
Wed 07 Feb 2018 04:18:08 PM UTC, comment #1: 

Confirmed.

A simpler example for testing is


fixed_point_format (true)
x = [-1e-11;0;1e11]
x =

   1.0e+11 *

  -0.00000
  0.00000
  1.00000



Rik <rik5>
Group administrator
Wed 07 Feb 2018 08:56:57 AM UTC, original submission:  

Hello I noticed some problem in displaying matrices after using the fixed_point_format option. In particular when some element is negative then the minus causes some incorrect align.

Example:



@>> eye(4) + 1e-10*(rand(4)*2 -1)
ans =

   1.0000e+00  -8.2241e-11  -5.5211e-12   6.7249e-11
  -4.8330e-11   1.0000e+00  -6.9058e-11   5.6222e-11
  -8.7173e-11  -6.1014e-11   1.0000e+00   8.6248e-11
   6.6938e-11  -1.9031e-11   1.4162e-11   1.0000e+00

@>> fixed_point_format (1)
@>> ans
ans =

  1.00000  -0.00000  -0.00000  0.00000
  -0.00000  1.00000  -0.00000  0.00000
  -0.00000  -0.00000  1.00000  0.00000
  0.00000  -0.00000  0.00000  1.00000

@>>


Regards.

nicodemus <nicmus>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by nicmus (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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-09-21 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2018-03-23 jwe Item GroupNone Feature Request
        StatusFixed None
        Open/ClosedClosed Open
        Release4.2.1 dev
    2018-02-11 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2018-02-07 rik5 StatusNone Confirmed
        Summaryfixed_point_format: incorrect align fixed_point_format: incorrect alignment

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code