octave-maintainers
[Top][All Lists]
Advanced

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

Re: [Pkg-octave-devel] Bug#706376: Bug#706376: Bug#706376: octave: spars


From: David Bateman
Subject: Re: [Pkg-octave-devel] Bug#706376: Bug#706376: Bug#706376: octave: sparse matrix n*2^16
Date: Sat, 15 Jun 2013 17:00:14 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

On 05/06/2013 04:24 PM, Jordi Gutiérrez Hermoso wrote:
> On 4 May 2013 20:50, Ed Meyer <address@hidden> wrote:
>> I think I see why numel() is getting called from trace(). isempty()
>> is called which calls is_empty() which should be virtual. Were it to
>> call the sparse version of is_empty() there would be no problem
>> because it tests the row & column dimensions instead of calling
>> numel(). So shouldn't is_empty() be virtual?
> Sure, this patches this hole. What about linear indexing, how will you
> patch that one?
>
> - Jordi G. H.
>
That a bit of a specious argument. "Because we can't solve problem B we
shouldn't solve problem A". Taking this argument to the absurd this
shouldn't work either

n = 2^16;
s = sparse (1:n,1:n,1);
t = s * s;

as t will have more elements than can be indexed with octave_idx_type.
Clear it works. So essentially you're saying that sparse matrices with
32-bit indexing and numel larger than 2^31 are useless!!

A lot of attention was made in the sparse implementation to not rely
either on linear indexing or the value of numel to avoid this issue. I'd
think that any function or operator that relies on either for sparse
matrices, or at least when it doesn't have to, is buggy.

Ed is right the is_empty method of the octave_base_value class should be
specialized for sparse matrices as in the attached changeset as it has
no need to rely on numel. Then any function that relies on isempty
should now work for sparse matrices.

David

Attachment: patch.is_empty
Description: Text document


reply via email to

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