--
You received this message because you are subscribed to the Google Groups "Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-dev/E30EA0E9-DC7F-498C-9F67-42554EBB757E%40gmail.com.
Hi John,
A couple of questions:
Although that’s how I ended up here, my actual problem came when I thought “oh, I could just add this to my local copy of the number-theory package, and test whether my implementation is faster or slower than modular-expt.”
I don’t understand why you need to “add this to … local copy of the number-theory package”? If you want to compare your version with the math
package’s version, you can do something like:
#lang racket
(require math/number-theory)
(define (my-modular-expt a n) ...)
(time (my-modular-expt ...)) ; test your version
(time (modular-expt ...)) ; test the `math` package's version
In fact, by modifying the math
package, you will no longer have the math
package’s version to compare to!
Slightly off-topic: do you find that the math
package’s version is too slow? Why did you try to implement your own version in the first place?
Best,
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-dev/CAL3TdONM%3DGm_t%3DO_X%3D%3DOcR1oj94yTXnSJ8zp3hU3OQ-qsFN2BA%40mail.gmail.com.
On Feb 17, 2021, at 3:20 PM, Sorawee Porncharoenwase <sorawe...@gmail.com> wrote:Hi John,
A couple of questions:
Although that’s how I ended up here, my actual problem came when I thought “oh, I could just add this to my local copy of the number-theory package, and test whether my implementation is faster or slower than modular-expt.”
I don’t understand why you need to “add this to … local copy of the number-theory package”? If you want to compare your version with the
math
package’s version, you can do something like
#lang racket (require math/number-theory) (define (my-modular-expt a n) ...) (time (my-modular-expt ...)) ; test your version (time (modular-expt ...)) ; test the `math` package's version
In fact, by modifying the
math
package, you will no longer have themath
package’s version to compare to!Slightly off-topic: do you find that the
math
package’s version is too slow?
Why did you try to implement your own version in the first place?
Hi Sorawee,On Feb 17, 2021, at 3:20 PM, Sorawee Porncharoenwase <sorawe...@gmail.com> wrote:
Why did you try to implement your own version in the first place?
Just as a learning exercise…I didn’t see any obvious performance difference, but I guess if I compare the two implementations, I would say:1. modular-expt uses infix operators (which looked strange to me in Racket context FWIW but is clearly just my personal taste).
2. modular-expt uses the ‘loop’ syntax (taking an extra dependency that seems not needed for a bitwise shift to get equivalent performance).