! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: arrays combinators fry kernel macros make math math.bits
-math.order math.vectors sequences splitting vectors ;
+USING: arrays combinators kernel make math math.bits
+math.vectors sequences vectors ;
IN: math.polynomials
<PRIVATE
: p* ( p q -- r )
2unempty pextend-conv
- [ drop length [ iota ] keep ]
+ [ drop length [ <iota> ] keep ]
[ nip <reversed> ]
[ drop ] 2tri
- '[ _ _ <slice> _ v* sum ] map reverse! ;
+ '[ _ _ <slice> _ vdot ] map reverse! ;
: p-sq ( p -- p^2 ) dup p* ; inline
[ V{ 0 } clone V{ 1 } clone ] 2dip swap (pgcd) [ >array ] bi@ ;
: pdiff ( p -- p' )
- dup length iota v* rest ;
+ dup length <iota> v* rest ;
: polyval ( x p -- p[x] )
! Horner scheme