[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
objects, subrefs and numel
From: |
CdeMills |
Subject: |
objects, subrefs and numel |
Date: |
Thu, 19 Feb 2015 07:37:21 -0800 (PST) |
Hello,
Octave 3.8 doc states that:
Built-in Function: numel (A, IDX1, IDX2, ...)
This method is also called when an object appears as lvalue with
cs-list indexing, i.e., 'object{...}' or 'object(...).field'.
I recently implement the multi-argument form of numel for dataframes
objects:
switch nargin
case 1
%# use the internal structure fields to get the total number of
element
resu = prod (df._cnt);
otherwise
%# do the subsreferencing and call numel on the resulting
sub-dataframe
S.type = '()';
S.subs = varargin;
resu = numel (subsref (df, S));
This means that constructions as df{} results in TWO calls to subrefs:
- one in the context of numel(), generating an object from df(...)
- one proper, evaluating df{...}
Both calls to subrefs results in objects of the same size. But the
construction is quite complex. Would it be possible to change the logic as
1) do the sub-referencing
2) call the single-argument form of numel() on the returned object ?
This would avoid this double operation, as the object returned from the
first call is just inspected and throw away.
Regards
Pascal
--
View this message in context:
http://octave.1599824.n4.nabble.com/objects-subrefs-and-numel-tp4668682.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- objects, subrefs and numel,
CdeMills <=