aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aberth/aberth_kernel.fut4
1 files changed, 2 insertions, 2 deletions
diff --git a/aberth/aberth_kernel.fut b/aberth/aberth_kernel.fut
index 5d851f0..9d0c59e 100644
--- a/aberth/aberth_kernel.fut
+++ b/aberth/aberth_kernel.fut
@@ -29,8 +29,8 @@ let evaln_d (p: poly) (nterms: i32) (pt: f32): f32 =
let eval_d (p: poly) (pt: f32): f32 = evaln_d p (length p) pt
let derivative (p: poly): *poly =
- let res = map (\(i, v) -> f32.i32 i * v) (tail (zip (0..<PolyN) p)) ++ [0]
- in res :> poly
+ map2 (\i v -> f32.i32 (i32.bool (i != PolyN - 1) * (i + 1)) * v)
+ (0..<PolyN) (rotate 1 p)
-- Cauchy's bound: https://en.wikipedia.org/wiki/Geometrical_properties_of_polynomial_roots#Lagrange's_and_Cauchy's_bounds
let max_root_norm (p: poly): f32 =