Polynomial long division: Difference between revisions

Content added Content deleted
(Updated D entry)
(Updated D entry)
Line 687:
((0 . -123)) ; -123</lang>
=={{header|D}}==
<lang d>import std.stdio, std.range, std.algorithm, std.typecons, std.arrayconv;
 
Tuple!(double[], double[]) polyDiv(in double[] inN, in double[] inD)
Line 694:
static int trimAndDegree(T)(ref T[] poly) nothrow pure {
poly = poly.retro.find!q{ a != b }(0.0).retro;
return (cast(int)poly.length).signed - 1;
}
 
Line 721:
int trimAndDegree1(T)(ref T[] poly) nothrow pure {
poly.length -= poly.retro.countUntil!q{ a != 0 };
return (cast(int)poly.length).signed - 1;
}