Mercurial > hg > octave-avbm
changeset 10141:e409546ac0a8
add bsxfun tests
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 20 Jan 2010 09:32:02 +0100 |
parents | 36ea14c8992d |
children | 829e69ec3110 |
files | src/ChangeLog src/DLD-FUNCTIONS/bsxfun.cc |
diffstat | 2 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2010-01-20 Jaroslav Hajek <highegg@gmail.com> + + * DLD-FUNCTIONS/bsxfun.cc: New tests. + 2010-01-20 David Bateman <dbateman@free.fr> * graphics.h.in (string_array_property): New property.
--- a/src/DLD-FUNCTIONS/bsxfun.cc +++ b/src/DLD-FUNCTIONS/bsxfun.cc @@ -742,4 +742,26 @@ %% The below is a very hard case to treat %!assert(bsxfun (f, ones([4, 1, 4, 1]), ones([1, 4, 1, 4])), zeros([4, 4, 4, 4])); +%!shared a, b, aa, bb +%! a = randn (3, 1, 3); +%! aa = a(:, ones (1, 3), :, ones (1, 3)); +%! b = randn (1, 3, 3, 3); +%! bb = b(ones (1, 3), :, :, :); +%!assert (bsxfun (@plus, a, b), aa + bb); +%!assert (bsxfun (@minus, a, b), aa - bb); +%!assert (bsxfun (@times, a, b), aa .* bb); +%!assert (bsxfun (@rdivide, a, b), aa ./ bb); +%!assert (bsxfun (@ldivide, a, b), aa .\ bb); +%!assert (bsxfun (@power, a, b), aa .^ bb); +%!assert (bsxfun (@power, abs (a), b), abs (aa) .^ bb); +%!assert (bsxfun (@eq, round (a), round (b)), round (aa) == round (bb)); +%!assert (bsxfun (@ne, round (a), round (b)), round (aa) != round (bb)); +%!assert (bsxfun (@lt, a, b), aa < bb); +%!assert (bsxfun (@le, a, b), aa <= bb); +%!assert (bsxfun (@gt, a, b), aa > bb); +%!assert (bsxfun (@ge, a, b), aa >= bb); +%!assert (bsxfun (@min, a, b), min (aa, bb)); +%!assert (bsxfun (@max, a, b), max (aa, bb)); +%!assert (bsxfun (@and, a > 0, b > 0), (aa > 0) & (bb > 0)); +%!assert (bsxfun (@or, a > 0, b > 0), (aa > 0) | (bb > 0)); */