struct2cell malfunctioning

View: New views
3 Messages — Rating Filter:   Alert me  

struct2cell malfunctioning

by Klaus Betzler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

# octave-3.0.1 windows version

# malfunction of struct2cell

# struct2cell repeats a one-dimensional structure 'length' times

# example: get a one-dimensional structure
pc = physical_constant ();
sizeof (pc)                     # ans =  22308

# make a cell array of it
pc_ca = struct2cell (pc);
sizeof (pc_ca)                  # ans =  6848556
sizeof (pc) * length (pc)       # ans =  6848556

# Best regards, Klaus
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: struct2cell malfunctioning

by David Bateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Klaus Betzler wrote:

> # octave-3.0.1 windows version
>
> # malfunction of struct2cell
>
> # struct2cell repeats a one-dimensional structure 'length' times
>
> # example: get a one-dimensional structure
> pc = physical_constant ();
> sizeof (pc)                     # ans =  22308
>
> # make a cell array of it
> pc_ca = struct2cell (pc);
> sizeof (pc_ca)                  # ans =  6848556
> sizeof (pc) * length (pc)       # ans =  6848556
>
> # Best regards, Klaus
> _______________________________________________
> Bug-octave mailing list
> Bug-octave@...
> https://www.cae.wisc.edu/mailman/listinfo/bug-octave
>  
Ok, I can confirm that this is a bug. Simpler test code is

%!test
%!  s(1).field1 = 1; s(1).field2 = 2; s(2).field1 = 3; s(2).field2 = 4;
%!  c{1,1,1} = 1; c{2,1,1} = 2; c{1,1,2} = 3; c(2,1,2) = 4;
%! assert (struct2cell(s), c);

I'll check and see if I can find a fix.

D.

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: struct2cell malfunctioning

by David Bateman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

David Bateman wrote:

> Klaus Betzler wrote:
>  
>> # octave-3.0.1 windows version
>>
>> # malfunction of struct2cell
>>
>> # struct2cell repeats a one-dimensional structure 'length' times
>>
>> # example: get a one-dimensional structure
>> pc = physical_constant ();
>> sizeof (pc)                     # ans =  22308
>>
>> # make a cell array of it
>> pc_ca = struct2cell (pc);
>> sizeof (pc_ca)                  # ans =  6848556
>> sizeof (pc) * length (pc)       # ans =  6848556
>>
>> # Best regards, Klaus
>> _______________________________________________
>> Bug-octave mailing list
>> Bug-octave@...
>> https://www.cae.wisc.edu/mailman/listinfo/bug-octave
>>  
>>    
> Ok, I can confirm that this is a bug. Simpler test code is
>
> %!test
> %!  s(1).field1 = 1; s(1).field2 = 2; s(2).field1 = 3; s(2).field2 = 4;
> %!  c{1,1,1} = 1; c{2,1,1} = 2; c{1,1,2} = 3; c(2,1,2) = 4;
> %! assert (struct2cell(s), c);
>
> I'll check and see if I can find a fix.
>
> D.
>  
In fact its already fixed in the repository for both 3.0.x and 3.1.x. Check

http://velveeta.che.wisc.edu/cgi-bin/hgwebdir.cgi/octave/rev/af562a3999cb

This will be in the next release

D.

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave