TerseMan challenge
Andres Valloud
sqrmax at cvtci.com.ar
Tue Jan 11 22:04:46 UTC 2000
Hi Travis.
> Multiply instead of using raisedTo: if you can (on my system, I can
> make it up to about 18 before using raisedTo: is actually faster
> than consecutive multiplies).
This is very interesting... does that mean that you could do muls à la
Egypt?... like...
k1 _ b. "b"
k2 _ b*b. "b^2"
k4 _ k2*k2. "b^4"
k8 _ k4*k4. "b^8"
k16 _ k8*k8. "b^16"
k32 _ k16*k16. "b^32"
k64 _ k32*k32. "b^64"
k128 _ k64*k64. "b^128, 13 muls so far"
result _ b*k2*k3*k4*k5*k6*k7*k8. "20 muls, b^255"
This is 20 multiplications, but the result is b^255... there's even a
faster way to mul a collection of numbers, and especially for
factorials, the result is impressive. There's a class attached to this
mail... what it does is to try to multiply numbers similar in size
instead of doing 3* 2^1000, which is very inefficient in terms of the
result obtained. Or, 64! * 65...
I have found this class incredibly useful for my number crunching.
Andres.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CollectionProduct.st
Type: application/x-unknown-content-type-st_auto_file
Size: 2631 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20000111/e9e31b90/CollectionProduct.bin
More information about the Squeak-dev
mailing list
|