Re: [racket] FW: q about code for partitions

2014-07-17 Thread Jos Koot
27;Jens Axel Søgaard'; 'Vincent St-Amour'; 'Eric Dobson'; > 'Racket Users List' > Subject: RE: [racket] FW: q about code for partitions > > Your example exposed two different bugs in `future`. I've pushed > repairs. > > Thanks! > >

Re: [racket] FW: q about code for partitions

2014-07-17 Thread Matthew Flatt
sage- > > From: Matthew Flatt [mailto:mfl...@cs.utah.edu] > > Sent: jueves, 17 de julio de 2014 13:48 > > To: Jos Koot > > Cc: 'Jens Axel Søgaard'; 'Vincent St-Amour'; 'Eric Dobson'; > > 'Racket Users List' > > Subj

Re: [racket] FW: q about code for partitions

2014-07-17 Thread Jos Koot
incent St-Amour'; 'Eric Dobson'; > 'Racket Users List' > Subject: RE: [racket] FW: q about code for partitions > > I'll work on this. Thanks! > > At Thu, 17 Jul 2014 13:41:28 +0200, "Jos Koot" wrote: > > Strange: I do not get a segfault

Re: [racket] FW: q about code for partitions

2014-07-17 Thread Matthew Flatt
; > [mailto:jensaxelsoega...@gmail.com] On Behalf Of Jens Axel Søgaard > > Sent: jueves, 17 de julio de 2014 13:12 > > To: Jos Koot > > Cc: Vincent St-Amour; Eric Dobson; Matthew Flatt; Racket Users List > > Subject: Re: [racket] FW: q about code for partitions

Re: [racket] FW: q about code for partitions

2014-07-17 Thread Jos Koot
t > Cc: Vincent St-Amour; Eric Dobson; Matthew Flatt; Racket Users List > Subject: Re: [racket] FW: q about code for partitions > > What you describe seems more like a bug in partitions than a > documentation bug. > Do you have a small example that provoke a segfault? > >

Re: [racket] FW: q about code for partitions

2014-07-17 Thread Jos Koot
os Koot > >> wrote: > >> > > Great work, Jens. I am glad my approach as been adopted > >> (and much improved > >> > > without deviating from the original idea of simpler > >> recurrence). When can we > >> > > expect i

Re: [racket] FW: q about code for partitions

2014-07-17 Thread Jens Axel Søgaard
Message- >> From: Vincent St-Amour [mailto:stamo...@ccs.neu.edu] >> Sent: domingo, 29 de junio de 2014 22:52 >> To: Eric Dobson >> Cc: Jos Koot; Matthew Flatt; Jens Axel Søgaard; Racket Users List >> Subject: Re: [racket] FW: q about code for partitions >> &g

Re: [racket] FW: q about code for partitions

2014-07-17 Thread Jos Koot
Jos > -Original Message- > From: Vincent St-Amour [mailto:stamo...@ccs.neu.edu] > Sent: domingo, 29 de junio de 2014 22:52 > To: Eric Dobson > Cc: Jos Koot; Matthew Flatt; Jens Axel Søgaard; Racket Users List > Subject: Re: [racket] FW: q about code for partitions > >

Re: [racket] FW: q about code for partitions

2014-06-29 Thread Vincent St-Amour
Thanks, Jos > > > >> -Original Message- > >> From: jensaxelsoega...@gmail.com > >> [mailto:jensaxelsoega...@gmail.com] On Behalf Of Jens Axel Søgaard > >> Sent: domingo, 29 de junio de 2014 12:48 > >> To: Matthew Flatt > >> Cc: Jos Koot; Racket

Re: [racket] FW: q about code for partitions

2014-06-29 Thread Eric Dobson
: domingo, 29 de junio de 2014 12:48 >> To: Matthew Flatt >> Cc: Jos Koot; Racket Users List >> Subject: Re: [racket] FW: q about code for partitions >> >> I have made a new vector version using zero? instead of exact-zero?. >> >> To give users a chance t

Re: [racket] FW: q about code for partitions

2014-06-29 Thread Jos Koot
axelsoega...@gmail.com] On Behalf Of Jens Axel Søgaard > Sent: domingo, 29 de junio de 2014 12:48 > To: Matthew Flatt > Cc: Jos Koot; Racket Users List > Subject: Re: [racket] FW: q about code for partitions > > I have made a new vector version using zero? instead of exact-zero?. >

Re: [racket] FW: q about code for partitions

2014-06-29 Thread Vincent St-Amour
Given that partitions2.rkt is written in TR, it shouldn't have to go through a contract boundary to use `exact-zero?` (which is also written in TR). The contract profiler does not observe any time spent in contracts, which supports that hypothesis. How did you discover that `exact-zero?` was wrapp

Re: [racket] FW: q about code for partitions

2014-06-29 Thread Robby Findler
This seems like a good test case for Vincent's tools. They may have been able to tell us that the time was spent contract checking. Robby On Sun, Jun 29, 2014 at 5:48 AM, Jens Axel Søgaard wrote: > I have made a new vector version using zero? instead of exact-zero?. > > To give users a chance t

Re: [racket] FW: q about code for partitions

2014-06-29 Thread Jens Axel Søgaard
I have made a new vector version using zero? instead of exact-zero?. To give users a chance to remove the cache after doing partitions calculations, I have added set-partitions-cache. Code: https://github.com/soegaard/racket/blob/patch-14/pkgs/math-pkgs/math-lib/math/private/number-theory/

Re: [racket] FW: q about code for partitions

2014-06-29 Thread Jens Axel Søgaard
2014-06-29 8:47 GMT+02:00 Matthew Flatt : > It looks like "partitions2.rkt" ends up calling a contract-wrapped > variant of `exact-zero?`. That explains why Eric saw an improvement, when the used #f instead of 0 as the not-cached-yet value. /Jens Axel Racket Users list: h

Re: [racket] FW: q about code for partitions

2014-06-29 Thread Jos Koot
t > Subject: Re: [racket] FW: q about code for partitions > > It looks like "partitions2.rkt" ends up calling a contract-wrapped > variant of `exact-zero?`. If I change `ref!` to > > (define (ref! n thnk) >(let ([v (vector-ref cache n)]) >

Re: [racket] FW: q about code for partitions

2014-06-28 Thread Matthew Flatt
It looks like "partitions2.rkt" ends up calling a contract-wrapped variant of `exact-zero?`. If I change `ref!` to (define (ref! n thnk) (let ([v (vector-ref cache n)]) (if (zero? v) (let ([new-v (thnk)]) (vector-set! cache n new-v) new-v) v))) the

Re: [racket] FW: q about code for partitions

2014-06-28 Thread Jens Axel Søgaard
and fast (in that order). Therefore >> complicating the code much for a slight gain of speed may be the wrong thing >> to do. MHO >> >> Jos >> >> >>> -Original Message- >>> From: jensaxelsoega...@gmail.com >>> [mailto:jensaxelsoega...

Re: [racket] FW: q about code for partitions

2014-06-28 Thread Eric Dobson
> to do. MHO > > Jos > > >> -Original Message- >> From: jensaxelsoega...@gmail.com >> [mailto:jensaxelsoega...@gmail.com] On Behalf Of Jens Axel Søgaard >> Sent: sábado, 28 de junio de 2014 16:51 >> To: Neil Toronto >> Cc: Jos Koot; Racket Use

Re: [racket] FW: q about code for partitions

2014-06-28 Thread Jos Koot
> -Original Message- > From: jensaxelsoega...@gmail.com > [mailto:jensaxelsoega...@gmail.com] On Behalf Of Jens Axel Søgaard > Sent: sábado, 28 de junio de 2014 16:51 > To: Neil Toronto > Cc: Jos Koot; Racket Users List > Subject: Re: [racket] FW: q about code for partitions

Re: [racket] FW: q about code for partitions

2014-06-28 Thread Jens Axel Søgaard
rry I can't help you on this. Maybe experts of the team can shed light? >> >> Best wishes, Jos >> >> >> >>> -Original Message- >>> From: jensaxelsoega...@gmail.com >>> [mailto:jensaxelsoega...@gmail.com] On Behalf Of Jens Axel Søgaard >

Re: [racket] FW: q about code for partitions

2014-06-28 Thread Neil Toronto
m >> [mailto:jensaxelsoega...@gmail.com] On Behalf Of Jens Axel Søgaard >> Sent: sábado, 28 de junio de 2014 12:07 >> To: Jos Koot >> Cc: Neil Toronto; Racket Users List >> Subject: Re: [racket] FW: q about code for partitions >> >> Hi, >> >> I h

Re: [racket] FW: q about code for partitions

2014-06-28 Thread Jos Koot
nio de 2014 12:07 > To: Jos Koot > Cc: Neil Toronto; Racket Users List > Subject: Re: [racket] FW: q about code for partitions > > Hi, > > I have converted your code to Typed Racket and made two versions. > The first version use a hash as cache and the second version > us

Re: [racket] FW: q about code for partitions

2014-06-28 Thread Jens Axel Søgaard
Hi, I have converted your code to Typed Racket and made two versions. The first version use a hash as cache and the second version us a vector. Timings show that the vector version is 1.5 to 2 times slower than the hash version. I don't understand this. Is there anything that can be done to impr

[racket] FW: q about code for partitions

2014-06-28 Thread Jos Koot
Sorry, forgot to post the following to the users list. Hi, count partitions, much faster and exact. You may want to put the hash or part of it within function p such as to avoid spllling much memory. Jos #lang racket (require math/number-theory) (define p-hash (make-hash '((0 . 1 (define (