From e83da8c3d26f939cd081e5aca154b00bba00082a Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Mon, 30 Jul 2012 16:15:21 -0700 Subject: [PATCH] math.matrices: adding van-der-monde matrix. --- basis/math/matrices/matrices-tests.factor | 11 ++++++++++- basis/math/matrices/matrices.factor | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) 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