Mercurial > hg > octave-nkf
diff liboctave/Array.cc @ 11241:80e01d79cf80
special case for concatenation of empty matrices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Nov 2010 14:53:26 -0500 |
parents | b79924abf776 |
children | 0090bb47d0b5 |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2535,6 +2535,48 @@ else if (n == 0) return Array<T> (); + // Special case: + // + // cat (dim, [], ..., [], A) + // + // with dim > 2, A not 0x0, and at least three arguments to + // concatenate results in A. Note that this check must be performed + // here because for full-on braindead Matlab compatibility, we need + // the above to succeed, but things like + // + // cat (3, cat (3, [], []), A) + // cat (3, zeros (0, 0, 2), A) + // + // to fail. See also bug report #31615. + + if (n > 2 && dim > 1) + { + dim_vector dv = array_list[n-1].dims (); + + if (! dv.zero_by_zero ()) + { + bool all_but_last_are_zero_by_zero = true; + + if (all_but_last_are_zero_by_zero) + { + for (octave_idx_type i = 0; i < n-1; i++) + { + dim_vector dv = array_list[i].dims (); + + if (! dv.zero_by_zero ()) + { + all_but_last_are_zero_by_zero = false; + break; + } + } + } + + if (all_but_last_are_zero_by_zero) + return array_list[n-1]; + } + } + + dim_vector dv = array_list[0].dims (); for (octave_idx_type i = 1; i < n; i++)