new polyval
parent
60a5f535e9
commit
c5888330d6
|
@ -112,7 +112,6 @@ IN: math-contrib
|
||||||
#! Polynomial derivative.
|
#! Polynomial derivative.
|
||||||
dup empty? [ [ length ] keep v* 1 swap tail ] unless ;
|
dup empty? [ [ length ] keep v* 1 swap tail ] unless ;
|
||||||
|
|
||||||
: polyval ( x p -- n )
|
: polyval ( x p -- p[x] )
|
||||||
#! evaluate polynomial in a straightforward way
|
#! Evaluate a polynomial.
|
||||||
ptrim dup length 1 swap <range> [ pick swap ^ ] map 1 rot cut swapd v. swap pop + nip ;
|
[ powers ] keep v. ;
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@ USING: errors kernel sequences math sequences-internals namespaces arrays ;
|
||||||
-rot (^mod)
|
-rot (^mod)
|
||||||
] if ; foldable
|
] 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
|
: ** ( u v -- u*v' ) conjugate * ; inline
|
||||||
|
|
||||||
: c. ( v v -- x )
|
: c. ( v v -- x )
|
||||||
|
|
Loading…
Reference in New Issue