From maintainers-request at octave dot org Tue Nov 16 13:31:10 2004 Subject: Re: int octave_value::numel (void) const; From: David Bateman To: maintainers at octave dot org Date: Tue, 16 Nov 2004 20:30:52 +0100 > I had assumed that numel would always be equivalent to > > prod (size ()) Its not true for the sparse class, in fact see what happens for a= speye(1e6); whos a *** local user variables: Prot Name Size Bytes Class ==== ==== ==== ===== ===== rwd a 1000000x1000000 0 sparse Total is 3567587328 elements using 0 bytes or with the new sparse class gives *** local user variables: Prot Name Size Bytes Class ==== ==== ==== ===== ===== rwd a 1000000x1000000 16000004 sparse matrix Total is 3567587328 elements using 16000004 bytes Which is clearly wrong due to an overflow in the the integer calculation prod(size(a))... Which is probably why matlab chose to only count the non-zero elements in numel... > > but if it is not, then it is fine with me to change the definition of > numel so that it can be defined differently in derived classses. Ok, I'll submit a patch then.. Cheers David -- David Bateman David dot Bateman at motorola dot com Motorola CRM +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary