math.matrices: adding van-der-monde matrix.

db4
John Benediktsson 2012-07-30 16:15:21 -07:00
parent aed6825b4a
commit 088dfa4861
2 changed files with 13 additions and 1 deletions

View 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 } }

View 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