[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #33966] object precedence with concatenating
From: |
Ben Abbott |
Subject: |
[Octave-bug-tracker] [bug #33966] object precedence with concatenating |
Date: |
Sun, 07 Aug 2011 21:52:53 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30 |
URL:
<http://savannah.gnu.org/bugs/?33966>
Summary: object precedence with concatenating
Project: GNU Octave
Submitted by: bpabbott
Submitted on: Sun 07 Aug 2011 05:52:51 PM EDT
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: None
Assigned to: None
Originator Name: Ben Abbott
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Mac OS
_______________________________________________________
Details:
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
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?33966>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #33966] object precedence with concatenating,
Ben Abbott <=