[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: numel(foo{:}) - feature or bug ?
From: |
Ben Abbott |
Subject: |
Re: numel(foo{:}) - feature or bug ? |
Date: |
Sat, 06 Aug 2011 09:44:24 -0400 |
On Aug 6, 2011, at 2:38 AM, Sergei Steshenko wrote:
> Thanks for the update.
>
> I rechecked the thread, and if I am not mistaken, in my case it is:
>
> "
> octave:5> foo{4} = [1 2 3 4; 5 6 7 8; 9 10 11 12]
> foo =
> {
> [1,1] = a
> [1,2] = ab
> [1,3] = abc
> [1,4] =
>
> 1 2 3 4
> 5 6 7 8
> 9 10 11 12
>
> }
> octave:6> numel(foo{:})
> ans = 72
> ",
>
> while in your case it is:
>
> "
> octave.exe:6> numel(foo{:})
> ans = 96 ## Hmmm.....
> ".
>
> I.e. for the same input data we have different results (72 <-> 96).
>
> Again, if I'm not mistaken in all these observations, could you please
> reopen the http://savannah.gnu.org/bugs/?33954 bug ?
>
> Thanks,
> Sergei.
You are comparing two different cases. Phil obtained 96 with different inputs.
You used ...
foo = {"a", "ab", "abc", [1:4;5:8;9:12]};
And Phil used ...
foo = {"a", "ab", "abc", rand(4)};
In each case, numel is returning ...
fun = @(x) prod (size (x));
prod (cellfun (fun, foo(2:end))
In you case 2 * 3 * 12 = 72
In Phil's example 2 * 3 * 16 = 96
>From my reading of the discussion, I'm skeptical that everyone understands
>that foo{:} is a cs-list, or maybe don't understand cs-lists? Consider the
>short example below ...
clear a
foo = {"a", "ab", "abc", [1:4;5:8;9:12]};
a(1).args = foo{1};
a(2).args = foo{2};
a(3).args = foo{3}
a(4).args = char(foo{4});
numel (a.args)
ans = 72
numel (foo{:})
ans = 72
numel (foo{1}, foo{2}, foo{3}, foo{4})
ans = 72
Both foo{:} and a.args produce cs-lists (I added the char() function to avoid a
syntax error).
Ben
- numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/05
- Re: numel(foo{:}) - feature or bug ?, Martin.Hepperle, 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 ?, PhilipNienhuis, 2011/08/05
- Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/06
- Re: numel(foo{:}) - feature or bug ?,
Ben Abbott <=
- Re: numel(foo{:}) - feature or bug ?, John W. Eaton, 2011/08/06
- Re: numel(foo{:}) - feature or bug ?, Ben Abbott, 2011/08/06
- Re: numel(foo{:}) - feature or bug ?, Jordi GutiƩrrez Hermoso, 2011/08/06
- Re: numel(foo{:}) - feature or bug ?, Ben Abbott, 2011/08/06
- Re: numel(foo{:}) - feature or bug ?, Marco atzeri, 2011/08/07
- Re: numel(foo{:}) - feature or bug ?, John W. Eaton, 2011/08/07
- Re: numel(foo{:}) - feature or bug ?, Marco atzeri, 2011/08/07
Re: numel(foo{:}) - feature or bug ?, Sergei Steshenko, 2011/08/05
Re: numel(foo{:}) - feature or bug ?, Ben Abbott, 2011/08/05