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

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

[Octave-bug-tracker] [bug #42850] Reshape on sparse matrix leads to segf


From: Lachlan Andrew
Subject: [Octave-bug-tracker] [bug #42850] Reshape on sparse matrix leads to segfault
Date: Sat, 16 Jan 2016 03:31:04 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0

Follow-up Comment #7, bug #42850 (project octave):

Rik had the right idea with pulling the division by new_nr in sooner.  The
attached patch does that.  It keeps track of the quotient and remainder for 
i*old_nr  divided by new_nr.  Because much of this is done in the outer loop,
it should be even faster than using the cute floating point code on Wikipedia,
as well as being easier to understand (IMHO).

(Just to check my understanding, why was jj calculated as (tmp - ii) / nr? 
Isn't that equal to tmp/nr, since ii is by definition just the remainder?  If
not, don't trust my patch :)

I've tested it on 10000 reshapes, and the results appear to be the same as for
a full reshape.

This doesn't explain why David Spies was able to do the reshape without a
crash in the first place.  Perhaps it was just pointing to some relatively
safe wrong place initially.  I did print out the matrix just to make sure I
didn't get the broken pipe that he did.  

(file #36055)
    _______________________________________________________

Additional Item Attachment:

File name: bug_42850.cset                 Size:2 KB


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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