From 2f1fa30265e98cbde4f1f5344b85c04f07f80379 Mon Sep 17 00:00:00 2001
From: Tom Smeding <tom.smeding@gmail.com>
Date: Tue, 30 Jun 2020 11:17:37 +0200
Subject: aberth: Less :>

---
 aberth/aberth_kernel.fut | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'aberth')

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 =
-- 
cgit v1.2.3-70-g09d2