Mercurial > jwe > octave
changeset 19134:38c54d45d05f
kron.cc: codesprint: add more kron tests
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Sun, 21 Sep 2014 15:10:02 -0400 |
parents | 95c804dcc76c |
children | dc51f26f0db5 |
files | libinterp/corefcn/kron.cc |
diffstat | 1 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/kron.cc Sun Sep 21 21:01:52 2014 +0200 +++ b/libinterp/corefcn/kron.cc Sun Sep 21 15:10:02 2014 -0400 @@ -287,13 +287,26 @@ %! x = ones (2); %! assert (kron (x, x), ones (4)); -%!shared x, y, z +%!shared x, y, z, p1, p2, d1, d2 %! x = [1, 2]; %! y = [-1, -2]; %! z = [1, 2, 3, 4; 1, 2, 3, 4; 1, 2, 3, 4]; +%! p1 = eye (3)([2, 3, 1], :); ## Permutation matrix +%! p2 = [0 1 0; 0 0 1; 1 0 0]; ## Non-permutation equivalent +%! d1 = diag ([1 2 3]); ## Diag type matrix +%! d2 = [1 0 0; 0 2 0; 0 0 3]; ## Non-diag equivalent %!assert (kron (1:4, ones (3, 1)), z) +%!assert (kron (single (1:4), ones (3, 1)), single (z)) +%!assert (kron (sparse (1:4), ones (3, 1)), sparse (z)) +%!assert (kron (complex (1:4), ones (3, 1)), z) +%!assert (kron (complex (single(1:4)), ones (3, 1)), single(z)) %!assert (kron (x, y, z), kron (kron (x, y), z)) %!assert (kron (x, y, z), kron (x, kron (y, z))) +%!assert (kron (p1, p1), kron (p2, p2)) +%!assert (kron (p1, p2), kron (p2, p1)) +%!assert (kron (d1, d1), kron (d2, d2)) +%!assert (kron (d1, d2), kron (d2, d1)) + %!assert (kron (diag ([1, 2]), diag ([3, 4])), diag ([3, 4, 6, 8]))