diff --git a/basis/math/matrices/matrices-tests.factor b/basis/math/matrices/matrices-tests.factor index 8d918cb74d..e5bf009333 100644 --- a/basis/math/matrices/matrices-tests.factor +++ b/basis/math/matrices/matrices-tests.factor @@ -23,6 +23,15 @@ IN: math.matrices.tests { 1 2 3 } diagonal-matrix ] unit-test +{ + { { 1 1 1 } + { 4 2 1 } + { 9 3 1 } + { 25 5 1 } } +} [ + { 1 2 3 5 } 3 van-der-monde-matrix +] unit-test + { { { 1 0 0 } @@ -130,7 +139,7 @@ IN: math.matrices.tests { { 1 0 0 } { 0 2 0 } { 0 0 3 } } - + { { 0 0 -4 } { 0 -5 0 } { -6 0 0 } } diff --git a/basis/math/matrices/matrices.factor b/basis/math/matrices/matrices.factor index 857f4905c7..6c8ffa018f 100644 --- a/basis/math/matrices/matrices.factor +++ b/basis/math/matrices/matrices.factor @@ -31,6 +31,9 @@ IN: math.matrices : box-matrix ( r -- matrix ) 2 * 1 + dup '[ _ 1 ] replicate ; +: van-der-monde-matrix ( u n -- matrix ) + iota [ v^n ] with map reverse flip ; + :: rotation-matrix3 ( axis theta -- matrix ) theta cos :> c theta sin :> s