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

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

[Octave-bug-tracker] [bug #29906] cumsum gives wrong results if matrix l


From: Jarno Pelkonen
Subject: [Octave-bug-tracker] [bug #29906] cumsum gives wrong results if matrix looks like binary matrix
Date: Tue, 18 May 2010 16:10:31 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3

URL:
  <http://savannah.gnu.org/bugs/?29906>

                 Summary: cumsum gives wrong results if matrix looks like
binary matrix
                 Project: GNU Octave
            Submitted by: jylppy
            Submitted on: Tue 18 May 2010 04:10:31 PM GMT
                Category: None
                Severity: 3 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Jarno Pelkonen
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.2.4
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

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;-)




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?29906>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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