comparison libinterp/corefcn/data.cc @ 32045:f18da620ab4d stable

Fix floating point exception when Sparse array reshaped to 0x0 (bug #64080) * Sparse.cc (reshape): Test for empty matrix (number of rows or columns equal to 0) and immediately return constructed, but unfilled, empty sparse matrix. * data.cc (Freshape): Add BIST test for bug #64080.
author Rik <rik@octave.org>
date Thu, 20 Apr 2023 18:58:57 -0700
parents 073cc98750c6
children 39700c1ea93e
comparison
equal deleted inserted replaced
32033:1824e0ee4088 32045:f18da620ab4d
5979 %!assert (size (reshape (ones (4, 4, "single"), 2, 8)), [2, 8]) 5979 %!assert (size (reshape (ones (4, 4, "single"), 2, 8)), [2, 8])
5980 %!assert (size (reshape (ones (4, 4, "single"), 8, 2)), [8, 2]) 5980 %!assert (size (reshape (ones (4, 4, "single"), 8, 2)), [8, 2])
5981 %!assert (size (reshape (ones (15, 4, "single"), 1, 60)), [1, 60]) 5981 %!assert (size (reshape (ones (15, 4, "single"), 1, 60)), [1, 60])
5982 %!assert (size (reshape (ones (15, 4, "single"), 60, 1)), [60, 1]) 5982 %!assert (size (reshape (ones (15, 4, "single"), 60, 1)), [60, 1])
5983 5983
5984 %!assert <*64080> (size (reshape (sparse (0, 1), 0, 0)), [0, 0])
5985
5984 %!test 5986 %!test
5985 %! s.a = 1; 5987 %! s.a = 1;
5986 %! fail ("reshape (s, 2, 3)", "can't reshape 1x1 array to 2x3 array"); 5988 %! fail ("reshape (s, 2, 3)", "can't reshape 1x1 array to 2x3 array");
5987 5989
5988 %!error reshape () 5990 %!error reshape ()