The actual time to calculate p2num and montgKeys are both O(log P). What I'm looking is a constant time lookup. On Nov 7, 2011 1:51 PM, "Yucheng Zhang" <yczhan...@gmail.com> wrote:
> On Mon, Nov 7, 2011 at 9:29 AM, Bin Jin <bjin1...@gmail.com> wrote: > > Hi > > This method is what I'm looking for. it's a nice general solution, but it > > doesn't solve my problem here. > > I'm using ghc 7.0.3, I tried to cache p2num and montgKeys in the way you > > showed. It seems that ghc doesn't memorize p2num and reject to compile > new > > montgKeys. > > I think caching values with dynamic types is complicated in ghc's runtime > > environment. Anyone knows the details? > > Adding memorization directly to 'montgKeys' or 'p2num' should be possible, > if you write your own version of MemoTrie dealing with dynamic types. > > However, this memorization requires an O(log P) lookup in the trie. > This lookup process will require the whole type structure of P to be > examined, which is of size O(log P). > > > > Yucheng Zhang >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe