help-octave
[Top][All Lists]
Advanced

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

Re: numel(foo{:}) - feature or bug ?


From: Sergei Steshenko
Subject: Re: numel(foo{:}) - feature or bug ?
Date: Fri, 5 Aug 2011 23:03:57 -0700 (PDT)


--- On Fri, 8/5/11, Marco atzeri <address@hidden> wrote:

> From: Marco atzeri <address@hidden>
> Subject: Re: numel(foo{:}) - feature or bug ?
> To: address@hidden
> Date: Friday, August 5, 2011, 10:06 AM
> On 8/5/2011 6:37 PM, Sergei Steshenko
> wrote:
> >> 
> > 
> > Oh, if somebody wants (pseudo)scientific terminology,
> then here it is:
> > 
> > Why does adding an element causes non-monotonicity in
> numel(foo2d{:}) ?
> > 
> > Thanks,
> >    Sergei.
> 
> 
> Sergei,
> could you please cool down and trim a bit all your e-mails
> ?
> It is not polite to report every time the full story of
> your
> previous mails, and make following you very hard.
> 
> At least 2 persons already tried to explain you that
> fooo2d
> and foo2d{:}) are not the same thing.
> 
> You can disagree on how numel works on matlab and octave,
> but or you
> provide a compelling reason for the change and you provide
> also a
> patch for the change, or I doubt numel will be modified.
> 
> by the way on GNU Octave, version 3.4.2
> 
> > foo
> foo =
> {
>   [1,1] = a
>   [2,1] = aa
>   [1,2] = b
>   [2,2] = [](0x0)
> }
> 
> > foo(:)
> ans =
> {
>   [1,1] = a
>   [2,1] = aa
>   [3,1] = b
>   [4,1] = [](0x0)
> }
> 
> > foo{:}
> ans = a
> ans = aa
> ans = b
> ans = [](0x0)
> 
> Please note the complete different answer !
> 
> > numel(foo)
> ans =  4
> 
> > numel(foo(:))
> ans =  4
> 
> > numel(foo{:})
> ans = 0
> 
> 
> > size(foo)
> ans =
> 
>    2   2
> 
> > size(foo(:))
> ans =
> 
>    4   1
> 
> > size(foo{:})
> error: Invalid call to size.  Correct usage is:
> 
> 
> I supect you are thinking as foo(:) and foo{:} as
> equivalent
> but they are not.
> 
> Regards
> Marco
> 
> 
> 
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
> 

So, how does your example answer my question:

"
Why does adding an element causes non-monotonicity in numel(foo2d{:}) ?
"

?

Or, my point in more detail. We can have a hierarchical data structure of
some kind, and we can have some functions which return number of elements
in the structure.

The functions my not traverse the whole structure, so adding elements at
some levels may not show up in the functions outputs.

But why _adding_ an element at some level causes a function's output
to _drop_ from 2 to 0 rather that to at least stay 2. And according to
what's printed on the screen there are 3 non-empty elements and 1 empty
one.

Thanks,
  Sergei.




reply via email to

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