# HG changeset patch # User A.R. Burgers # Date 1618950189 -7200 # Tue Apr 20 22:23:09 2021 +0200 # Node ID 6dcc03c9174af6ce4794f24e61e7cebe7c904d67 # Parent ef88f4c7a87194624b25588d7542fec7f667f4df speed-up pchip in case of mixed precision arguments * pchip.m: replace division by diagonal matrix with regular division and broadcast diff -r ef88f4c7a871 -r 6dcc03c9174a scripts/polynomial/pchip.m --- a/scripts/polynomial/pchip.m Tue Apr 20 22:05:35 2021 +0200 +++ b/scripts/polynomial/pchip.m Tue Apr 20 22:23:09 2021 +0200 @@ -115,14 +115,14 @@ d2 = d(:, 2:n); ## This is taken from SLATEC. - h = diag (h); + hr = 1.0 ./ h; - delta = diff (y, 1, 2) / h; - del1 = (d1 - delta) / h; - del2 = (d2 - delta) / h; + delta = diff (y, 1, 2) .* hr; + del1 = (d1 - delta) .* hr; + del2 = (d2 - delta) .* hr; c3 = del1 + del2; c2 = -c3 - del1; - c3 /= h; + c3 .*= hr; coeffs = cat (3, c3, c2, d1, f1); ret = mkpp (x, coeffs, szy(1:end-1));