divMod package:numeric-prelude
\n (QC.NonZero m) -> let (q,r) = divMod n m in n == (q*m+r :: Integer)
\x y -> case (PolyCore.normalize x, PolyCore.normalize y) of (nx, ny) -> not (null (ratioPoly ny)) ==> mapSnd PolyCore.normalize (PolyCore.divMod nx ny) == mapPair (PolyCore.normalize, PolyCore.normalize) (PolyCore.divMod x y)
\x y -> not (isZero (ratioPoly y)) ==> let z = fst $ PolyCore.divMod (Poly.coeffs x) y in PolyCore.normalize z == z
\x y -> case PolyCore.normalize $ ratioPoly y of ny -> not (null ny) ==> List.length (snd $ PolyCore.divMod x y) < List.length ny
Allows division by zero. If the divisor is zero, then the dividend is
returned as remainder.
The modulus will always have one element less than the divisor. This
means that the modulus will be denormalized in some cases, e.g.
mod [2,1,1] [1,1,1] == [1,0] instead of [1].
divModLazy accesses the divisor in a lazy way. However this is only
relevant if the dividend is smaller than the divisor. For large
dividends the divisor will be accessed multiple times but since it is
already fully evaluated it could also be strict.
This function has a strict divisor and maintains the chunk structure
of the dividend at a smaller scale.