Mercurial > octave-libgccjit
comparison libinterp/corefcn/dot.cc @ 18636:60562e5c8bfb stable
Correctly validate arguments to dot function (bug #42061).
* dot.cc (Fdot): Check that lengths of vector arguments are the same.
Add input validations tests.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 06 Apr 2014 14:56:45 -0700 |
parents | 175b392e91fe |
children | 78fac67300e8 |
comparison
equal
deleted
inserted
replaced
18633:5fe907167520 | 18636:60562e5c8bfb |
---|---|
140 // Change to column vectors. | 140 // Change to column vectors. |
141 dimx = dimx.redim (1); | 141 dimx = dimx.redim (1); |
142 argx = argx.reshape (dimx); | 142 argx = argx.reshape (dimx); |
143 dimy = dimy.redim (1); | 143 dimy = dimy.redim (1); |
144 argy = argy.reshape (dimy); | 144 argy = argy.reshape (dimy); |
145 match = ! error_state; | 145 match = ! error_state && (dimx == dimy); |
146 } | 146 } |
147 | 147 |
148 if (match) | 148 if (match) |
149 { | 149 { |
150 int dim; | 150 int dim; |
260 %! y = int8 ([5 6; 7 8]); | 260 %! y = int8 ([5 6; 7 8]); |
261 %! assert (dot (x, y), [26 44]); | 261 %! assert (dot (x, y), [26 44]); |
262 %! assert (dot (x, y, 2), [17; 53]); | 262 %! assert (dot (x, y, 2), [17; 53]); |
263 %! assert (dot (x, y, 3), [5 12; 21 32]); | 263 %! assert (dot (x, y, 3), [5 12; 21 32]); |
264 | 264 |
265 %% Test input validation | |
266 %!error dot () | |
267 %!error dot (1) | |
268 %!error dot (1,2,3,4) | |
269 %!error <X and Y must be numeric> dot ({1,2}, [3,4]) | |
270 %!error <X and Y must be numeric> dot ([1,2], {3,4}) | |
271 %!error <sizes of X and Y must match> dot ([1 2], [1 2 3]) | |
272 %!error <sizes of X and Y must match> dot ([1 2]', [1 2 3]') | |
273 %!error <sizes of X and Y must match> dot (ones (2,2), ones (2,3)) | |
274 %!error <DIM must be a valid dimension> dot ([1 2], [1 2], 0) | |
265 */ | 275 */ |
266 | 276 |
267 DEFUN (blkmm, args, , | 277 DEFUN (blkmm, args, , |
268 "-*- texinfo -*-\n\ | 278 "-*- texinfo -*-\n\ |
269 @deftypefn {Built-in Function} {} blkmm (@var{A}, @var{B})\n\ | 279 @deftypefn {Built-in Function} {} blkmm (@var{A}, @var{B})\n\ |