WFOLCYCZVNRVCEWSDJR36BGSN6IKJ4CMISYCOWBLENMOP2JUTRIQC a * b| a == 1 = b| b == 1 = a| otherwise = sum $ dox <- twoPowers ay <- twoPowers blet cs = twoPowers $ x .&. yp = product $ fmap (\c -> bit (bit c) + bit (bit c - 1)) csd = bit $ x .^. ypure $ p * d
0 * _ = 0_ * 0 = 01*b = ba*1 = aa * b =let m = max (floorLog @Int (floorLog a)) (floorLog @Int (floorLog b)) -- D = 2^2^m is the largest Fermat 2-power less than or equal to both a and bsemiD = bit (bit m - 1) -- semimultiple of Da1 = a `shiftR` bit m -- a = a1D+a2a2 = a .^. (a1 `shiftL` bit m)b1 = b `shiftR` bit m -- b = b1D+b2b2 = b .^. (b1 `shiftL` bit m)in ((a1*b1 + a2*b1 + a1*b2) `shiftL` bit m) + a1*b1*semiD + a2*b2