From aad94d711b1dbe502014af2627b8669b5eac947d Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 24 May 2012 09:02:47 -0700 Subject: [PATCH] math.matrices: Add another test to make sure we calculate kron correctly. --- basis/math/matrices/matrices-tests.factor | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/basis/math/matrices/matrices-tests.factor b/basis/math/matrices/matrices-tests.factor index 7703d2e524..8d918cb74d 100644 --- a/basis/math/matrices/matrices-tests.factor +++ b/basis/math/matrices/matrices-tests.factor @@ -239,3 +239,31 @@ IN: math.matrices.tests { 1 -1 -1 1 -1 1 1 -1 } } } [ { { 1 1 } { 1 -1 } } dup dup kron swap kron ] unit-test + + +! kron is not generally commutative, make sure we have the right order +{ + { + { 1 2 3 4 5 1 2 3 4 5 } + { 6 7 8 9 10 6 7 8 9 10 } + { 1 2 3 4 5 -1 -2 -3 -4 -5 } + { 6 7 8 9 10 -6 -7 -8 -9 -10 } + } +} +[ + { { 1 1 } { 1 -1 } } + { { 1 2 3 4 5 } { 6 7 8 9 10 } } kron +] unit-test + +{ + { + { 1 1 2 2 3 3 4 4 5 5 } + { 1 -1 2 -2 3 -3 4 -4 5 -5 } + { 6 6 7 7 8 8 9 9 10 10 } + { 6 -6 7 -7 8 -8 9 -9 10 -10 } + } +} +[ + { { 1 1 } { 1 -1 } } + { { 1 2 3 4 5 } { 6 7 8 9 10 } } swap kron +] unit-test