]> gitweb.factorcode.org Git - factor.git/commitdiff
math.matrices: adding van-der-monde matrix.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 30 Jul 2012 23:15:21 +0000 (16:15 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 30 Jul 2012 23:15:21 +0000 (16:15 -0700)
basis/math/matrices/matrices-tests.factor
basis/math/matrices/matrices.factor

index 8d918cb74d9f1b7d6f2e77773f571a727f0022f9..e5bf009333d1a6844673247a56cc98b2a1d3d305 100644 (file)
@@ -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 } }
index 857f4905c7f68b98c23471b8ce37b9fcc9af4dea..6c8ffa018f14c6254d9cbd138564ee3655a049cd 100644 (file)
@@ -31,6 +31,9 @@ IN: math.matrices
 : box-matrix ( r -- matrix )
     2 * 1 + dup '[ _ 1 <array> ] 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