new polyval

cvs
Slava Pestov 2005-12-08 00:43:29 +00:00
parent 60a5f535e9
commit c5888330d6
2 changed files with 7 additions and 4 deletions

View File

@ -112,7 +112,6 @@ IN: math-contrib
#! Polynomial derivative.
dup empty? [ [ length ] keep v* 1 swap tail ] unless ;
: polyval ( x p -- n )
#! evaluate polynomial in a straightforward way
ptrim dup length 1 swap <range> [ pick swap ^ ] map 1 rot cut swapd v. swap pop + nip ;
: polyval ( x p -- p[x] )
#! Evaluate a polynomial.
[ powers ] keep v. ;

View File

@ -26,6 +26,10 @@ USING: errors kernel sequences math sequences-internals namespaces arrays ;
-rot (^mod)
] if ; foldable
: powers ( x n -- { 1 x x^2 x^3 ... } )
#! Output sequence has n elements.
1 swap [ drop [ dupd * ] keep ] map 2nip ;
: ** ( u v -- u*v' ) conjugate * ; inline
: c. ( v v -- x )