From bug-request at octave dot org Tue Jan 18 14:03:16 2005 Subject: Bug concatenation of NDArray's From: "John W. Eaton" To: David dot Bateman at motorola dot com Cc: bug at octave dot org Date: Tue, 18 Jan 2005 15:06:20 -0500 On 17-Jan-2005, David Bateman wrote: | There is a bug in the concatenation of NDArray's that can easily be seen | with the example | | A = cat(3,[1,2;3,4],[1,2;3,4]); | B = [A,A] | | That will seg-fault. The problem is in the function | | template Array& | Array::insert (const Array& a, const Array& ra_idx) | | where the calculation of the number of elements to skip between copied | blocks is incorrect. The problem only appears for concatenation of | NDArray's where the dimension along which they are concatentated is not | the last one. | | Attached there is a fix that should be applied to all branches. I applied this change. | However, the fix assumes that | only one element of ra_idx is non-zero and that only one element (the | same as non-zero ra_idx element) of dims() and a.dims() differs. This is | in fact the case everywhere that this function is currently. However, it | doesn't cover the general case of insertion of one arbitrary matrix into | another. Is this a problem? Yes, it seems that it could be. Even if this is incorrect usage, I think it should be detected so we can issue an error message instead of (potentially) crashing. 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 -------------------------------------------------------------