bugGNU Octave - Bugs: bug #29906, cumsum gives wrong results if...

 
 

bug #29906: cumsum gives wrong results if matrix is of type logical

Submitted by:  Jarno Pelkonen <jylppy>
Submitted on:  Tue 18 May 2010 04:10:31 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: Jaroslav Hajek <highegg>
Originator Name: Jarno PelkonenOpen/Closed: Closed
Release: devOperating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 19 May 2010 02:25:27 PM UTC, comment #2:

I love bugs that can be fixed by changing a single character :)
http://hg.savannah.gnu.org/hgweb/octave/rev/9852264314d1

thanks for the report

Jaroslav Hajek <highegg>In charge of this item.
Tue 18 May 2010 06:36:45 PM UTC, comment #1:

The problem is with matrices with type logical and is only apparent when the summation dimension is not equal to 1.

This was confirmed using a recent hg tip on a Linux system. 3-dimensional logical matrices summed over the 3rd dimension also were incorrect indicating that it is really any dimension other than 1 which leads to errors.

A simpler example to replicate the problem is:
a = logical ( [ 0 0 1 ; 0 1 1 ; 1 1 1 ] )
cumsum(a,2)

Rik <rik5>
Project Administrator
Tue 18 May 2010 04:10:31 PM UTC, original submission:

Hi,

'cumsum' function seems to give strange results IF the matrix resembles a binary (0/1) matrix AND the cumsum is done to second (2) dimension. It seems to be that cumsum decides to sue binary logic only to second dimension.

octave-3.2.4.exe:31> C = rand(10,12) > 0.4
C =

1 1 0 0 1 1 1 0 1 1 1 0
0 1 0 1 1 1 1 1 1 0 0 0
0 0 1 1 1 0 1 1 0 1 1 0
1 1 0 0 0 1 0 1 1 1 0 1
0 1 0 1 0 1 1 1 0 1 1 0
1 1 1 0 0 0 0 0 1 1 1 0
0 0 1 1 1 1 0 0 1 1 1 1
0 1 1 1 1 0 0 1 0 1 0 1
1 0 1 0 0 1 1 1 0 1 0 1
1 0 1 1 1 1 0 0 1 0 1 1

octave-3.2.4.exe:32> cumsum(C)
ans =

1 1 0 0 1 1 1 0 1 1 1 0
1 2 0 1 2 2 2 1 2 1 1 0
1 2 1 2 3 2 3 2 2 2 2 0
2 3 1 2 3 3 3 3 3 3 2 1
2 4 1 3 3 4 4 4 3 4 3 1
3 5 2 3 3 4 4 4 4 5 4 1
3 5 3 4 4 5 4 4 5 6 5 2
3 6 4 5 5 5 4 5 5 7 5 3
4 6 5 5 5 6 5 6 5 8 5 4
5 6 6 6 6 7 5 6 6 8 6 5

octave-3.2.4.exe:33> cumsum(C,2)
ans =

1 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0

This can be "fixed" if the "binary matrix" is transformed to matrix containing doubles.

octave-3.2.4.exe:34> cumsum(double(C),2)
ans =

1 2 2 2 3 4 5 5 6 7 8 8
0 1 1 2 3 4 5 6 7 7 7 7
0 0 1 2 3 3 4 5 5 6 7 7
1 2 2 2 2 3 3 4 5 6 6 7
0 1 1 2 2 3 4 5 5 6 7 7
1 2 3 3 3 3 3 3 4 5 6 6
0 0 1 2 3 4 4 4 5 6 7 8
0 1 2 3 4 4 4 5 5 6 6 7
1 1 2 2 2 3 4 5 5 6 6 7
1 1 2 3 4 5 5 5 6 6 7 8

octave-3.2.4.exe:35>

Operating system Win 7, 32-bit, all patches installed 5/19/2010. I have rebooted the computer and restarted Octave and this bug is reproducible.

And yes. This might be a feature;-)

Jarno Pelkonen <jylppy>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    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 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 19 May 2010 02:25:27 PM UTChigheggStatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Wed 19 May 2010 01:35:38 PM UTChigheggAssigned toNone=>highegg
      Release3.2.4=>dev
    Tue 18 May 2010 06:36:45 PM UTCrik5StatusNone=>Confirmed
      Summarycumsum gives wrong results if matrix looks like binary matrix=>cumsum gives wrong results if matrix is of type logical
    Tue 18 May 2010 04:10:31 PM UTCjylppyCarbon-Copy-=>Added jylppy

    Back to the top


    Powered by Savane 3.1-cleanup1