[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sparse matrices and real() function
From: |
Rik |
Subject: |
Sparse matrices and real() function |
Date: |
Fri, 18 Oct 2013 09:31:39 -0700 |
10/18/13
All,
I just tracked down a segfault in Octave to incorrect behavior of real()
for sparse matrices.
Check out the following:
debug> x = sparse (2i)
x = Compressed Column Sparse (rows = 1, cols = 1, nnz = 1 [100%])
(1, 1) -> 0 + 2i
debug> typeinfo (x)
ans = sparse complex matrix
debug> xr = real (x)
xr = Compressed Column Sparse (rows = 1, cols = 1, nnz = 1 [100%])
(1, 1) -> 0
debug> typeinfo (xr)
ans = sparse matrix
debug> nnz (xr)
ans = 1
The problem is that the internal format seems to have become corrupted
after the call to real which changed a non-zero entry to a zero entry.
nnz() should return 0 after the call to real(). I get the right result if
I force reconstruction of the sparse matrix with
xr2 = sparse (full (xr))
For the time being, I put in just that sort of change in assert.m to stop
the segfault and allow the test suite to run. But someone with more Sparse
matrix experience should address this.
--Rik
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Sparse matrices and real() function,
Rik <=