new polyval
parent
60a5f535e9
commit
c5888330d6
|
@ -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. ;
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in New Issue