Skip to content
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

Polynomial factorisation #175

Open
Bodigrim opened this issue Nov 5, 2019 · 14 comments
Open

Polynomial factorisation #175

Bodigrim opened this issue Nov 5, 2019 · 14 comments

Comments

@Bodigrim
Copy link
Owner

Bodigrim commented Nov 5, 2019

Some inspiration might be found in http://hackage.haskell.org/package/toysolver-0.6.0/docs/ToySolver-Data-Polynomial.html#t:Factor

@Bodigrim Bodigrim transferred this issue from Bodigrim/poly Nov 15, 2019
@MathiasBartl
Copy link

I was into cryptography, maybe I could do this, if CarlEdman wants to do Thue equations.

@Bodigrim
Copy link
Owner Author

Cool :)


Another possible source of inspiration is http://hackage.haskell.org/package/computational-algebra-0.5.0.0/docs/Algebra-Ring-Polynomial-Factorise.html
But I would like it to be implemented as instance UniqueFactorisation for Data.Poly.Poly.

@MathiasBartl
Copy link

So what do you want, that these packages don't already implement?

@Bodigrim
Copy link
Owner Author

Bodigrim commented Jun 26, 2020

A better API, I guess, and a better interaction with other packages. With all due respect, both toysolver and computational-algebra are pretty monstrous packages with tons of dependencies.

Looking at Algebra.Ring.Polynomial.Factorise I see:

factorQBigPrime :: MonadRandom m => Unipol Integer -> m (Integer, IntMap (Set (Unipol Integer)))
factorHensel    :: MonadRandom m => Unipol Integer -> m (Integer, IntMap (Set (Unipol Integer))) 

Not only I have no idea what is the practical difference between these functions, but return types also do not make any sense to me - does not look like a factorisation at all.

ToySolver.Data.Polynomial.Factor looks less intimidating, but its choice of data structures and dependencies means that performance is wanting. Map-based implementation for dense univariate polynomials is sub-par; primes coming from a lazy wheel sieve are cute, but slow; modular arithmetic can be implemented much faster, etc.

(The fierce critics above does not mean that I don't like these packages - quite contrary, these are fantastic ones and a pinnacle of engineering in many aspects. They just do not fit my particular purposes and requirements)


Ideally I would like to have several instances of form

instance UniqueFactorisation (Data.Poly.VPoly a)

for some suitable as. Implementing a ~ Integer would be a good start already ;)

I suggest using polynomials from poly, modular arithmetic from mod and primes from arithmoi itself.

@MathiasBartl
Copy link

That sounds like the best would be modifying an existing function.

@Bodigrim
Copy link
Owner Author

Ideally - yes, but I do not foresee this happening. IMO it is less work to add polynomial factorisation to arithmoi than inject all desired improvements into toysolver. Also it is unviable for arithmoi to depend on toysolver.

@MathiasBartl
Copy link

So Polynomials over the integers or over finite fields?

@Bodigrim
Copy link
Owner Author

Polynomials over integers, but AFAIR their factorisation would require factorisation of polynomials over Mod p as well.

@MathiasBartl
Copy link

So I could start with implementing Cantor-Zassenhaus.

@Bodigrim
Copy link
Owner Author

Bodigrim commented Jul 4, 2020

Yes, absolutely.

@MathiasBartl
Copy link

Most specifically I would need an GCD algorithm first.

@Bodigrim
Copy link
Owner Author

Bodigrim commented Jul 5, 2020

@MathiasBartl
Copy link

I assume that there is no real objection to using the Math.Polynomial package?
http://hackage.haskell.org/package/polynomial-0.7.3/docs/Math-Polynomial.html

@Bodigrim
Copy link
Owner Author

Bodigrim commented Jul 23, 2020

Except that Math.Polynomial does not compile against four last versions of GHC? ;)
Is something missing from poly, which I suggested above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants