bugGNU Octave - Bugs: bug #33966, object precedence with...

 
 

bug #33966: object precedence with concatenating

Submitted by:  Ben Abbott <bpabbott>
Submitted on:  Sun 07 Aug 2011 09:52:51 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Ben AbbottOpen/Closed: Closed
Release: devOperating System: Mac OS

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 15 Sep 2011 09:35:06 PM UTC, comment #2:

I checked in the following changeset which seems to make concatenation much more compatible with Matlab. Using your tests as a starting point, I created a more complete set of tests for all combinations of built-in classes.

http://hg.savannah.gnu.org/hgweb/octave/rev/d803d2702a39

Since all the tests are passing now, I'm closing this report. Reopen this report or start a new one if you see some new problem.

John W. Eaton <jwe>
Project Administrator
Mon 08 Aug 2011 12:25:09 AM UTC, comment #1:

I've prepared a changeset to test Octave and placed in the patch tracker.

https://savannah.gnu.org/patch/index.php?7592

Ben Abbott <bpabbott>
Project Member
Sun 07 Aug 2011 09:52:51 PM UTC, original submission:

On the help list a question came up on object precedence with concatenating objects. Found very little information in either Octave's or Mathworks' documentation, so I did some experimenting at the command line and found that ML and Octave give different results.

I've identified seven groups of objects in ML. Objects within groups have equal precedence. Group (1/logical) has the lowest pecedence and group (7/function_handle) has the highest precedence.

(1) logical
(2) double
(3) single
(4) uint8, uint16, uint32, uint64, int8, int16, int32, int64
(5) char
(6) struct, cell
(7) function_handle

Arrays of function handles are not allowed. Thus, they may be ignored with regards to precedence when concatenating objects.

If a cell is concatenated with other objects, of lower precedence, they are each converted to cells. For example, the command below is valid ML syntax and produces a cell array.

a = [{}, logical(1), double(1), single(1), uint32(1), 'a', struct('foo','bar')]

ML gives the indicated results for the concatentations below

class ([true, double(1)]) = "double"
class ([double(1), single(1)]) = "single"
class ([single(1), uint32(1)]) = "uint32"
class ([uint32(1), 'a']) = "char"
class (['a', cell(1)]) = "cell"
class ([cell(1), struct('foo','bar')]) = "cell"

When concatenating objects of equal precedence, Octave and ML return an object whos class consistent with that of the fist object.

Octave is also consistent with ML when concatenating numeric and character classes.

Concatenating matrices with cell arrays gives an error in Octave. For example, using a trival character scalar ...

a = 'a';
[a, cell(1)]
error: invalid concatenation of cell array with matrix

[cell(1), a]
error: concatenation operator not implemented for `cell' by `scalar' operations

Structures and cells have equal precedence, and the example below should produce a cell object.

[cell(1), struct('foo','bar')]
error: concatenation operator not implemented for `cell' by `scalar struct' operations

But the one below should (and does) give an error.

>> [struct('foo','bar'), cell(1)]

error: concatenation operator not implemented for `struct' by `cell' operations

Ben Abbott <bpabbott>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by bpabbott (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 15 Sep 2011 09:35:06 PM UTCjweStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1