From maintainers-request at octave dot org Wed Nov 10 08:03:35 2004 Subject: RE: integer concatenation (was: Octave 2.1.61 available for ftp) From: "Hall, Benjamin" To: "'John W. Eaton'" , "'octave maintainers mailing list'" Date: Wed, 10 Nov 2004 08:55:53 -0500 Here's what R14 does >> a = [int8(1), int16(2)]; Warning: Concatenation with dominant (left-most) integer class may overflow other operands on conversion to return class. >> b = [int16(1), int8(2)]; Warning: Concatenation with dominant (left-most) integer class may overflow other operands on conversion to return class. >> c = [int8(1), 2]; >> d = [1, int8(2)]; >> whos Name Size Bytes Class a 1x2 2 int8 array ans 1x2 2 int8 array b 1x2 4 int16 array c 1x2 2 int8 array d 1x2 2 int8 array Grand total is 10 elements using 12 bytes and, of course, it does the intN / complex concatenations >> e = [1 int8(3+2i)]; >> f = [3+2i, int8(4)]; >> whos e f Name Size Bytes Class e 1x2 4 int8 array (complex) f 1x2 4 int8 array (complex) Grand total is 4 elements using 8 bytes -----Original Message----- From: John W. Eaton [mailto:jwe at bevo dot che dot wisc dot edu] Sent: Tuesday, November 09, 2004 10:24 PM To: octave maintainers mailing list Subject: integer concatenation (was: Octave 2.1.61 available for ftp) On 9-Nov-2004, I wrote: | On 5-Nov-2004, I wrote: | | | * Things like [int32(1), int16(1)] will fail. Concatenation | | operations like this should return an object of the smaller type | | (int16 in this case). | | This is not yet fixed, though it seems it should not be too hard to | add. I will try to take a look at it, but perhaps David could say | whether it will require more than adding some concat functions. I've implemented this feature. While doing that, I found that the return type is not the smaller of the two types, but it is the type of the first argument in the pair. This means that [int8(1), int16(2)] returns an int8 object, but [int16(1), int8(2)] returns an int16 object. The exception (you knew there had to be one, right?) is that if you concatenate a double object and an intN object, the the result is always the intN type. This means that [int8(1), 2] and [1, int8(2)] both return int8 objects. Will someone please verify that this is still the way that Matlab R14 behaves? I didn't bother trying to define complex/intN concatenation because we don't have complex intN objects. I see no compelling reason to add them, but someone will probably eventually complain that Octave is completely useless because it does not have that feature. My changes for concat are checked in. Are there any other important bugs that need to be fixed before making a 2.1.62 snapshot? jwe