octave-maintainers
[Top][All Lists]
Advanced

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

int octave_value::numel (void) const;


From: John W. Eaton
Subject: int octave_value::numel (void) const;
Date: Tue, 16 Nov 2004 12:46:23 -0500

On 15-Nov-2004, David Bateman <address@hidden> wrote:

| Is there any reason not to change the definition of numel is ov.h to
| be a virtual function like
| 
|   virtual int numel (void) const
|     { return rep->numel (); }
| 
| and then add to ov-base.h 
| 
|    int numel (void) const { return dims ().numel (); }
| 
| The reason is that the code in symtab.cc for whos uses the numel
| function, which with the current code is based solely on the dimension
| vector. However the numel for a sparse matrix should be the non-zero
| elements only, and so the current behaviour is wrong. Making the above
| change allows numel to be overloaded, with a sparse matrix specific
| version.
| 
| The only problem I see is that oct-map.h includes its own version of 
| numel. Issues might arise for the is_empty, and the value of numel
| returned in whos for structures, though I'm not sure this is a problem
| even in that case.

I had assumed that numel would always be equivalent to

  prod (size ())

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.

jwe



reply via email to

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