New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prefactored binomial coefficients #152
Comments
Since
It could undoubtedly be made more efficient (in particular, by having |
Yep, I have a similar draft of data Prefactored a = Prefactored
{ prefValue :: a
, prefPrimeFactors :: Map (Prime a) Word
, prefPossiblyCompositeFactors :: Coprimes a Word
} |
After some deliberarion, now I think that the most profitable approach is just to define factorialFactors :: UniqueFactorisation a => Int -> [(Prime a, Word)]
binomialFactors :: UniqueFactorisation a => Int -> Int -> [(Prime a, Word)] |
There are applications, when it is desirable to represent binomial coefficients
binomial
via their factorisation. Binomials easily get huge, so it is vastly inefficient to compute them as numbers first andfactorise
afterwards.Define
Earlier approach, rejected now
There is a
Prefactored
data type, designed to keep information about factors under the hood by using a cleverNum
instance. For example,Unfortunately, computation of binomial coefficients involves not only multiplication, but also division (without remainder). And
Prefactored
is not an instance ofIntegral
(orEuclidean
).Is is possible to write a clever
Integral
instance forPrefactored
, such that could preserve information about factors, when remainder appears to be zero?The text was updated successfully, but these errors were encountered: