From bug-request at octave dot org Thu Nov 3 03:04:56 2005 Subject: Re: [,] promoted to full From: David Bateman To: "John W. Eaton" Cc: bug at octave dot org Date: Thu, 03 Nov 2005 10:00:59 +0100 John W. Eaton wrote: >On 3-Nov-2005, David Bateman wrote: > >| It seems that the changes to pt-mat.cc to speed up same type matrix >| concatenation have resulted in sparse matrix concatenation being >| promoted to a full matrix. For example >| >| a = speye(5) >| b = [a,a] >| whos a b >| >| However the problem doesn't seem to be specific to sparse matrices >| >| a = eye(10,'uint8') >| b=[a,a] >| whos a b >| >| also shows the same issue. I can think of several ways of handling this. >| >| 1) We can keep the special case code and deal with all of the possible >| types, which will be messy >| 2) We can alter the tests for all_real_p and all_complex_p to check for >| type_name() rather than use is_real_type and is_complex_type. The other >| cases will just fall through to the generic code in that case >| 3) tree_matrix::rvalue include a test that checks that all of the >| type_names of the objects to concatenate are compatible... >| >| Whats your call John? Do you want to deal with it? Or do you want a patch? > >I can fix it, but maybe not for a day or two. I think I would prefer >something like option 1, but please go ahead and write a patch if you >would like to make a quick change for option 2 that will at least make >things work properly again (and still be fast if we are concatenating >all double, all complex, or all char objects. > >BTW, here is something to try in Matlab: > > x{1} = int8 (32); > x{2} = int16 (32); > x{3} = int32 (32); > x{4} = int64 (32); > x{5} = uint8 (32); > x{6} = uint16 (32); > x{7} = uint32 (32); > x{8} = uint64 (32); > x{9} = single (32); > x{10} = double (32); > x{11} = char (32); > > for i = 1:11 > for j = 1:11 > r{i,j} = [x{i}, x{j}]; > end > end > > fprintf (' '); > for i = 1:11 > fprintf ('%7s', class (x{i})); > end > fprintf ('\n'); > > for i = 1:11 > fprintf ('%7s :', class (x{i})); > for j = 1:11 > fprintf ('%7s', class (r{i,j})); > end > fprintf ('\n'); > end > >I see > > int8 int16 int32 int64 uint8 uint16 uint32 uint64 single double char > int8 : int8 int8 int8 int8 int8 int8 int8 int8 int8 int8 char > int16 : int16 int16 int16 int16 int16 int16 int16 int16 int16 int16 char > int32 : int32 int32 int32 int32 int32 int32 int32 int32 int32 int32 char > int64 : int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 char > uint8 : uint8 uint8 uint8 uint8 uint8 uint8 uint8 uint8 uint8 uint8 char > uint16 : uint16 uint16 uint16 uint16 uint16 uint16 uint16 uint16 uint16 uint16 char > uint32 : uint32 uint32 uint32 uint32 uint32 uint32 uint32 uint32 uint32 uint32 char > uint64 : uint64 uint64 uint64 uint64 uint64 uint64 uint64 uint64 uint64 uint64 uint64 > single : int8 int16 int32 int64 uint8 uint16 uint32 uint64 single single char > double : int8 int16 int32 int64 uint8 uint16 uint32 uint64 single double char > char : char char char char char char char uint64 char char char > >Does it make any sense at all that uint64 behaves differently than >other types when concatenated with a char object? Is that documented >somewhere? Also note that when concatenating two integer objects, the >result type is the left object in the concatenation, but if it is >double and single, it is the smaller of the two types. Ugh. Did our >previous code behave this way? > >Thanks, > >jwe > > > >------------------------------------------------------------- >Octave is freely available under the terms of the GNU GPL. > >Octave's home on the web: http://www.octave.org >How to fund new projects: http://www.octave.org/funding.html >Subscription information: http://www.octave.org/archive.html >------------------------------------------------------------- > > > Easy enough to either ifdef out the accelerated code or get a revision 1.63 of pt-mat.cc from the CVS. The changes are isolated to this file so no worries there. However in both cases the old code gave. error: octave_base_value::convert_to_str_internal (): wrong type argument `int8 matrix' warning: implicit conversion from int8 matrix to error: evaluating assignment expression near line 14, column 15 error: evaluating for command near line 13, column 5 error: evaluating for command near line 12, column 3 on the concatenation. It seems there was no int/char concatenation function written previously. Disabling the 11-th case to get rid of this error for now, I get int8 int16 int32 int64 uint8 uint16 uint32 uint64 double double int8 : int8 int8 int8 int8 int8 int8 int8 int8 int8 int8 int16 : int16 int16 int16 int16 int16 int16 int16 int16 int16 int16 int32 : int32 int32 int32 int32 int32 int32 int32 int32 int32 int32 int64 : int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 uint8 : uint8 uint8 uint8 uint8 uint8 uint8 uint8 uint8 uint8 uint8 uint16 : uint16 uint16 uint16 uint16 uint16 uint16 uint16 uint16 uint16 uint16 uint32 : uint32 uint32 uint32 uint32 uint32 uint32 uint32 uint32 uint32 uint32 uint64 : uint64 uint64 uint64 uint64 uint64 uint64 uint64 uint64 uint64 uint64 double : int8 int16 int32 int64 uint8 uint16 uint32 uint64 double double double : int8 int16 int32 int64 uint8 uint16 uint32 uint64 double double As we don't have the single type, I think we can say the old code worked pretty much in the same manner as matlab. As for the differnce with uint64/char in matlab I say this is a bug on their part and we aren't obliged to copy it. I'm not pressed to get a solution and so am happy enough to wait for you to propose a solution. We should probably introduce a int/char concatenation at the same time. Looking at your table from matlab this might as well be done by replacing the all_strings_p with any_strings_p. Regards David -- David Bateman David dot Bateman at motorola dot com Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------