[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #44193] whos "elements" count wrong for user-d
From: |
Dan Sebald |
Subject: |
[Octave-bug-tracker] [bug #44193] whos "elements" count wrong for user-defined class, capacity problem? |
Date: |
Sun, 18 Dec 2016 22:52:21 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0 |
Follow-up Comment #9, bug #44193 (project octave):
I lost track of this bug...
I no longer see a "elements += val.capacity ();" in variables.cc. Perhaps a
change was made there to fix bug #43096 but didn't get to checking this one.
Anyway, the line of code that computes number of elements and displays is now
for (const auto& syminfo : lst)
{
syminfo.display_line (os, params);
octave_value val = syminfo.varval;
elements += val.numel ();
bytes += val.byte_size ();
}
It appears here that after extracting the A class files to a subdirectory and
generating x, y, z according to comment #5, numel(x) produces a proper result.
The code that does this is (from data.cc):
if (nargin == 1)
retval = args(0).numel ();
else if (nargin > 1)
{
// Don't use numel (const octave_value_list&) here as that corresponds
to
// an overloaded call, not to builtin!
retval = dims_to_numel (args(0).dims (), args.slice (1, nargin-1));
}
It seems to me that now both routes use the octave_value::numel() route. So
why does one produce a correct result and not the other? The answer might be
in the symbol_record::varval() routine, which is:
octave_value varval (context_id context = xdefault_context) const
{
if (is_global ())
return symbol_table::global_varval (name);
else if (is_persistent ())
return symbol_table::persistent_varval (name);
else
{
if (context == xdefault_context)
context = active_context ();
if (context < value_stack.size ())
return value_stack[context];
else
return octave_value ();
}
}
That is, whereas the numel() function definition uses the octave_value
"arg(0)" directly, this symbold_record::varval() routine might be returning
something other than the symbol's octave_value depending on active_context().
Just a theory. I'll experiment after compiling finishes.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?44193>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/