import { ddMultDouble2 as ddMultD } from "double-double"; /** * Returns the polynomial `f(s·x)`, i.e. the coefficient of `xⁱ` scaled by `sⁱ`. * * @param p a polynomial with coefficients given densely as an array of double-double * precision floating point numbers from highest to lowest power, e.g. `[[0,5],[0,-3],[0,0]]` * represents the polynomial `5x^2 - 3x` * @param s the scale factor */ function ddScale( p: number[][], s: number): number[][] { const n = p.length - 1; const r = new Array(n + 1); r[n] = p[n]; let sPow = s; for (let i=1; i<=n; i++) { r[n - i] = ddMultD(sPow, p[n - i]); sPow *= s; } return r; } /** * ❗**MODIFIES**❗ the polynomial such that `p(x)` -> `p(s·x)`, * i.e. the coefficient of `xⁱ` scaled by `sⁱ`. * * @param p a polynomial with coefficients given densely as an array of * double-double precision floating point numbers from highest to lowest power, * e.g. `[[0,5],[0,-3],[0,0]]` represents the polynomial `5x^2 - 3x` * @param s the scale factor */ function inplaceDdScale( p: number[][], s: number): void { const n = p.length - 1; let sPow = s; for (let i=1; i<=n; i++) { p[n - i] = ddMultD(sPow, p[n - i]); sPow *= s; } } export { ddScale, inplaceDdScale }