[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: numel(foo{:}) - feature or bug ?
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: numel(foo{:}) - feature or bug ? |
Date: |
Fri, 5 Aug 2011 11:44:00 -0500 |
2011/8/5 Sergei Steshenko <address@hidden>:
> Sorry, Jordi, doesn't make sense to me.
>
> The same 2-d example in more detail:
>
> "
> octave:1> foo2d{1,1} = "a"
> foo2d =
> {
> [1,1] = a
> }
> octave:2> foo2d{:}
> ans = a
> octave:3> sizeof(foo2d)
> ans = 1
> octave:4> numel(foo2d{:})
> ans = 1
> octave:5> foo2d{1,2} = "aa"
> foo2d =
> {
> [1,1] = a
> [1,2] = aa
> }
> octave:6> size(foo2d)
> ans =
>
> 1 2
>
> octave:7> numel(foo2d{:})
> ans = 2
> octave:8> foo2d{2,1} = "b"
> foo2d =
> {
> [1,1] = a
> [2,1] = b
> [1,2] = aa
> [2,2] = [](0x0)
> }
> octave:9> size(foo2d)
> ans =
>
> 2 2
>
> octave:10> foo2d{:}
> ans = a
> ans = b
> ans = aa
> ans = [](0x0)
> octave:11> numel(foo2d{:})
As Ben explained, because foo2d{:} is of type cs-list (NOT CELL), this
is equivalent to
numel(foo2d{1}, foo2d{2}, foo2d{3}, foo2d{4})
i.e.
numel("a", "b", "aa", [])
i.e. the number of ways that "a" can be indexed with "b", with "aa",
and with [].
But since size([]) is zero, you can't index with it. So the call above
is zero.
I tried to explain this better with the following changeset, but if it
still doesn't make sense, let me know if there's a better way:
http://hg.savannah.gnu.org/hgweb/octave/rev/67a5acac8e1b
In order to accomplish what you want, you would have to recurse into
the nested cell structure with numel calls.
> I think 'octave' should have a 'enable_stupid_matlab_bugs' flag.
We have it for some things. It's called --braindead. You can see what
it does if you type "doc braindead".
- Jordi G. H.
- Re: numel(foo{:}) - feature or bug ?, (continued)
- Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/05
- Re: numel(foo{:}) - feature or bug ?, Jordi Gutiérrez Hermoso, 2011/08/05
- Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/05
- Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/05
- Re: numel(foo{:}) - feature or bug ?, Marco atzeri, 2011/08/05
- Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/06
- Re: numel(foo{:}) - feature or bug ?, Marco atzeri, 2011/08/06
- Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/06
- Re: numel(foo{:}) - feature or bug ?, Marco atzeri, 2011/08/06
- Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/06
- Re: numel(foo{:}) - feature or bug ?,
Jordi Gutiérrez Hermoso <=
- Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/05
- Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/05
- Re: numel(foo{:}) - feature or bug ?, fork, 2011/08/05
- Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/06