help-octave
[Top][All Lists]
Advanced

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

Re: foo_cs = foo{:} - feature or bug ? (octave-3.4.2); also, sizeof(foo{


From: Sergei Steshenko
Subject: Re: foo_cs = foo{:} - feature or bug ? (octave-3.4.2); also, sizeof(foo{:})
Date: Mon, 8 Aug 2011 10:32:52 -0700 (PDT)

--- On Mon, 8/8/11, marco atzeri <address@hidden> wrote:

From: marco atzeri <address@hidden>
Subject: Re: foo_cs = foo{:} - feature or bug ? (octave-3.4.2); also, 
sizeof(foo{:})
To: "Sergei Steshenko" <address@hidden>
Cc: "address@hidden" <address@hidden>
Date: Monday, August 8, 2011, 5:15 AM



On Monday, August 8, 2011, Sergei Steshenko <address@hidden> wrote:
> Hello,
>
> here is a screen session:
>
> "
>
>

> octave:1> foo{1,1} = "a"
> foo =
> {
>  [1,1] = a
> }
> octave:2> foo{1,2} = "b"
> foo =
> {
>  [1,1] = a
>  [1,2] = b
> }
> octave:3> foo{2,1} = [1 2]

> foo =
> {
>  [1,1] = a
>  [2,1] =
>
>     1   2
>
>  [1,2] = b
>  [2,2] = [](0x0)
> }
> octave:4> foo_cs = foo{:}
> foo_cs = a
> octave:5> sizeof(foo{:})

> error: Invalid call to sizeof.  Correct usage is:
>
>  -- Built-in Function:  sizeof (VAL)
>
>
> Additional help for built-in functions and operators is
> available in the on-line version of the manual.  Use the command

> `doc <topic>' to search the manual index.
>
> Help and information about Octave is also available on the WWW
> at http://www.octave.org and via the address@hidden

> mailing list.
> octave:5> sizeof(foo_cs)
> ans =  1
> octave:6> sizeof(1 + 2)
> ans =  8
> octave:7> sizeof(foo)
> ans =  18
> octave:8>
> ".
>

> Questions:
>
> 1) why is it so that 'foo_cs' shows just one element (and its 'sizeof' is
> indeer 1 - see above) :
As John tried to explain two times
Foo{:} is not an objet, but comma separated list of objects.

size(foo{:}) is like size(foo{1},foo{2}, ...,foo(end))
that is wrong.
To have the size of an object try
size([foo{:}])

> "
> octave:4> foo_cs = foo{:}
> foo_cs = a
> "

> ?
>
> 2) why "sizeof(foo{:})" refuses to work while "sizeof(1 + 2)" and
> "sizeof(foo)" work ? I think "foo{:}" occupies some bytes in memory, so
> 'sizeof' taking it as its argument should make sense.

>
> Thanks,
>  Sergei.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave


And I am trying to tell the following:

in

"
octave:4> foo_cs = foo{:}
foo_cs = a
"

one can see, that that "not object" is somehow converted into 'foo_cs',
using whatever implicit rules.


Likewise, in

"
octave:6> sizeof(1 + 2)
ans =  8
"

the "1 + 2", which is an _expression_, is first converted (apparently) into
a _single_ double value, and the size of that double value is (apparently)
displayed.

So, the inconsistency, as I see it, is:

arithmetic expressions are _by_ _default_ converted into a _single_
memory location holding their value, and that memory location size in
bytes is dispalyed;

_opposed_ _to_ _that_

comma separated list is _not_ converted when 'sizeof' is called, but
some _deafault_ conversion is called in case of

"
octave:4> foo_cs = foo{:}
foo_cs = a
".

I.e. why for arithmetic expressions in case of "sizeof(1 + 2)" I see
something like:

invisible_result = 1 + 2; sizeof(invisible_result)

, but for comma-separated list in case of "sizeof(foo{:})" I do _not_ see

invisible_result = foo{:}; sizeof(invisible_result)

?

Thanks,
  Sergei.


reply via email to

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