flo-poly
Version:
A practical, root-focused JavaScript polynomial utility library.
23 lines (19 loc) • 519 B
text/typescript
/**
* Divides a polynomial by a constant in double precision.
*
* @param p a polynomial with coefficients given densely as an array of double
* floating point numbers from highest to lowest power, e.g. `[5,-3,0]`
* represents the polynomial `5x^2 - 3x`
* @param c a constant
*
* @doc
*/
function divideByConst(p: number[], c: number): number[] {
const d = p.length;
const r: number[] = [];
for (let i=0; i<d; i++) {
r.push(p[i] / c);
}
return r;
}
export { divideByConst }