[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices lea
From: |
David Bateman |
Subject: |
[Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes |
Date: |
Thu, 14 Jun 2012 22:42:45 +0000 |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0 |
Follow-up Comment #6, bug #36656 (project octave):
Jordi,
Deep or not I think I understand the code. Yes my comment was a throw away
that I wrote rapidly and I misread cidx as ridx. So taking your comment as a
challenge, here is my analysis of the situation
In Sparse<T>::delete_elements when idx_j is a colon then the creation of both
tmpl and tmpu will first call index(idx_i,idx_j) before first falling back to
index(idx_i) as nc==1 and j is a colon. This calls the code
Sparse<T> (idx_dims(0), idx_dims(1), nz ? data(0) : T ());
to create the index vector. As idx_i (as for all index vectors) is a column
vector, then the index that is returned to create tmpu and tmpl in
delete_elements is also a column vector and we were expecting it to be a row
vector.
The basic problem is that when nr=nc==1 then index(idx_j) can't know the shape
of the desired return vector and so guessing its a column vector is
reasonable. Whereas index(idx_i,idx_j) knows what shape it should be. The fix
is in index(idx_i,idx_j) to transpose retval if nc=nr==1 and j is a colon.
I still think its a good idea to make the change I suggested previously in any
case to avoid issues if the vectors data and ridx are not defined. So my
proposed fix if
diff --git a/liboctave/Sparse.cc b/liboctave/Sparse.cc
--- a/liboctave/Sparse.cc
+++ b/liboctave/Sparse.cc
@@ -1583,6 +1583,10 @@
{
// It's actually vector indexing. The 1D index is specialized for
that.
retval = index (idx_i);
+ // If nr == 1 then the vector indexing will return a column vector!!
+ if (nr == 1)
+ retval.transpose ();
+
}
else if (idx_i.is_scalar ())
{
diff --git a/liboctave/Sparse.h b/liboctave/Sparse.h
--- a/liboctave/Sparse.h
+++ b/liboctave/Sparse.h
@@ -81,14 +81,7 @@
c[i] = 0;
}
- SparseRep (octave_idx_type nr, octave_idx_type nc) : d (0), r (0), c (new
octave_idx_type [nc+1]), nzmx (0),
- nrows (nr), ncols (nc), count (1)
- {
- for (octave_idx_type i = 0; i < nc + 1; i++)
- c[i] = 0;
- }
-
- SparseRep (octave_idx_type nr, octave_idx_type nc, octave_idx_type nz) :
d (new T [nz]),
+ SparseRep (octave_idx_type nr, octave_idx_type nc, octave_idx_type nz=0)
: d (new T [nz]),
r (new octave_idx_type [nz]), c (new octave_idx_type [nc+1]), nzmx
(nz), nrows (nr),
ncols (nc), count (1)
{
D.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?36656>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to seg fault sometimes, anonymous, 2012/06/14
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, Jordi Gutiérrez Hermoso, 2012/06/14
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, Jordi Gutiérrez Hermoso, 2012/06/14
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, Jordi Gutiérrez Hermoso, 2012/06/14
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, David Bateman, 2012/06/14
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, Jordi Gutiérrez Hermoso, 2012/06/14
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, Jordi Gutiérrez Hermoso, 2012/06/14
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes,
David Bateman <=
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, Jordi Gutiérrez Hermoso, 2012/06/15
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, John W. Eaton, 2012/06/15
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, Jordi Gutiérrez Hermoso, 2012/06/15
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, David Bateman, 2012/06/18
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, John W. Eaton, 2012/06/19
- [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, Jordi Gutiérrez Hermoso, 2012/06/21
- Re: [Octave-bug-tracker] [bug #36656] deleting rows from sparse matrices leads to failed assertion sometimes, Levente Torok, 2012/06/23