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

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

[Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices lea


From: Jordi Gutiérrez Hermoso
Subject: [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes
Date: Fri, 15 Jun 2012 21:12:10 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20110109 Tundracanine/3.6.13

Follow-up Comment #9, bug #36656 (project octave):

I think I have a fix:


--- a/liboctave/Sparse.cc
+++ b/liboctave/Sparse.cc
@@ -1239,14 +1239,17 @@
       else if (idx_j.is_cont_range (nc, lb, ub))
         {
           const Sparse<T> tmp = *this;
-          octave_idx_type lbi = tmp.cidx(lb), ubi = tmp.cidx(ub), new_nz = nz
-
+          octave_idx_type lbi = tmp.cidx(lb), ubi = tmp.cidx(ub),
+            new_nz = nz - (ubi - lbi);
+
           *this = Sparse<T> (nr, nc - (ub - lb), new_nz);
           copy_or_memcpy (lbi, tmp.data (), data ());
           copy_or_memcpy (lbi, tmp.ridx (), ridx ());
           copy_or_memcpy (nz - ubi, tmp.data () + ubi, xdata () + lbi);
           copy_or_memcpy (nz - ubi, tmp.ridx () + ubi, xridx () + lbi);
           copy_or_memcpy (lb, tmp.cidx () + 1, cidx () + 1);
-          mx_inline_sub (nc - ub, xcidx () + 1, tmp.cidx () + ub + 1, ubi -
lbi
+          mx_inline_sub (nc - ub, xcidx () + lb + 1,
+                         tmp.cidx () + ub + 1, ubi - lbi);
         }
       else
         *this = index (idx_i, idx_j.complement (nc));


The column index was getting set wrong in cases such as these:


x = sparse(magic(5)); x(:,2:4) = [];


but it looks like while hunting for this bug, we found a host of associated
things to patch elsewhere. How should we handle all of this? Some for stable,
some for devel?

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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