[Haskell-cafe] How to use randomized algorithm within the implementation of pure data structures?

Travis Cardwell travis.cardwell at extellisys.com
Sun Nov 2 09:50:55 UTC 2014


Hi Ishii-san,

On 2014年11月02日 15:35, Hiromi ISHII wrote:
> I got it. But, in my case, fixing initial seed might cause
> inefficiency, so I can't take this way in this case.
> By the way, this approach seems works well for other cases which is
> not so quality sensitive.

Indeed: many algorithms merely require values from a uniform distribution,
not necessarily random numbers.  I was hopeful that Cantor-Zassenhaus
would be one of them.

Looking at your code [1], I see that you are exporting both
`equalDegreeSplitM`, which uses `uniform` from `Control.Monad.Random`, and
`equalDegreeFactorM`, which iteratively calls `equalDegreeSplitM`.  One of
the challenges of using a pure uniform stream is threading the state:
since both functions are exported, implementation details would leak anyway.

Great work, by the way! :)

Travis

[1]
https://github.com/konn/computational-algebra/blob/master/Algebra/Ring/Polynomial/Factorize.hs


More information about the Haskell-Cafe mailing list