new mpz_fac_ui code

David Newman david.newman@jesus.ox.ac.uk
Sun, 15 Jun 2003 11:18:34 +0100 (BST)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--27463816-1920821747-1055672314=:24428
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hi,

Here's some factorial code which uses the factorization of n! and repeated
squaring. It runs about twice as fast as the original code for large enough n.
Unfortunately, 'large enough' is about 15000 on my Athlon 1.2G so a bit of
threshold handling is needed.

Could someone give me a hand with making it less machine-dependent? 
(e.g. the nextprime function and subroutines assume unsigned long is 
32-bit). 

Thanks,
Dave Newman

--27463816-1920821747-1055672314=:24428
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="fac_new.c"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.44.0306151118340.24428@sheba.jesus.ox.ac.uk>
Content-Description: 
Content-Disposition: attachment; filename="fac_new.c"

I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8dGltZS5oPg0KI2luY2x1
ZGUgPGdtcC5oPg0KDQojaW5jbHVkZSAiZ21wLWltcGwuaCINCiNpbmNsdWRl
ICJsb25nbG9uZy5oIg0KI2luY2x1ZGUgIm1fc3Vicy5oIg0KDQp2b2lkIGZh
Y19uZXcgKCk7DQp1bnNpZ25lZCBsb25nIG5leHRwcmltZSAoKTsNCg0KdW5z
aWduZWQgc2hvcnQgcHJpbWVzW10gPQ0Kew0KICAzLDUsNywxMSwxMywxNywx
OSwyMywyOSwzMSwzNyw0MSw0Myw0Nyw1Myw1OSw2MSw2Nyw3MSw3Myw3OSw4
Myw4OSw5NywNCiAgMTAxLDEwMywxMDcsMTA5LDExMywxMjcsMTMxLDEzNywx
MzksMTQ5LDE1MSwxNTcsMTYzLDE2NywxNzMsMTc5LDE4MSwNCiAgMTkxLDE5
MywxOTcsMTk5LDIxMSwyMjMsMjI3LDIyOSwyMzMsMjM5LDI0MSwyNTEs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2xlIG5vbi16ZXJvIGxpbWIgKi8N
CiNkZWZpbmUgTVBaX0lOSVRfU0VUXzFfTlooeixuKSAgICAgICAgICAgICAg
ICAgIFwNCiAgZG8geyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgIFwNCiAgICBtcHpfcHRyICBfX2l6ID0gKHopOyAgICAgICAg
ICAgICAgICAgICAgICAgIFwNCiAgICBBTExPQyhfX2l6KSA9IDE7ICAgICAg
ICAgICAgICAgICAgICAgICAgICAgIFwNCiAgICBQVFIoX19peikgPSBfX0dN
UF9BTExPQ0FURV9GVU5DX0xJTUJTICgxKTsgIFwNCiAgICBNUFpfU0VUXzFf
TlogKF9faXosIG4pOyAgICAgICAgICAgICAgICAgICAgIFwNCiAgfSB3aGls
ZSAoMCkNCg0KLyogZm9yIHNyYz4wIGFuZCBuPjAgKi8NCiNkZWZpbmUgTVBa
X01VTF8xX1BPUyhkc3Qsc3JjLG4pICAgICAgICAgICAgICAgICAgICAgICAg
XA0KICBkbyB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICBcDQogICAgbXB6X3B0ciAgICBfX2RzdCA9IChkc3Qp
OyAgICAgICAgICAgICAgICAgICAgICAgICAgIFwNCiAgICBtcHpfc3JjcHRy
IF9fc3JjID0gKHNyYyk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgXA0K
ICAgIG1wX3NpemVfdCAgX19zaXplID0gU0laKF9fc3JjKTsgICAgICAgICAg
ICAgICAgICAgICBcDQogICAgbXBfcHRyICAgICBfX2RzdF9wOyAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgIFwNCiAgICBtcF9saW1iX3QgIF9f
YzsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXA0KICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICBcDQogICAgQVNTRVJUIChfX3NpemUgPiAwKTsgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgIFwNCiAgICBBU1NFUlQgKChuKSAhPSAw
KTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXA0KICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICBcDQogICAgTVBaX1JFQUxMT0MgKF9fZHN0LCBfX3NpemUrMSk7ICAg
ICAgICAgICAgICAgICAgICAgIFwNCiAgICBfX2RzdF9wID0gUFRSKF9fZHN0
KTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXA0KICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICBcDQogICAgX19jID0gbXBuX211bF8xIChfX2RzdF9wLCBQVFIoX19zcmMp
LCBfX3NpemUsIG4pOyAgIFwNCiAgICBfX2RzdF9wW19fc2l6ZV0gPSBfX2M7
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXA0KICAgIFNJWihfX2Rz
dCkgPSBfX3NpemUgKyAoX19jICE9IDApOyAgICAgICAgICAgICAgICAgICBc
DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgIFwNCiAgfSB3aGlsZSAoMCkNCg0KDQp2b2lkIGZhY19u
ZXcgKG1wel9wdHIgcmVzdWx0LCB1bnNpZ25lZCBsb25nIG4pDQp7DQogIC8q
IFdyaXRlIG4hID0gcFsxXV5yWzFdICogcFsyXV5yWzJdICogLi4uICogcFt0
XV5yW3RdLCB3aGVyZSB0aGUgcFtpXSBhcmUNCiAgICAgcHJpbWVzIChzdHJp
Y3RseSBpbmNyZWFzaW5nKSBhbmQgdGhlIHJbaV0gYXJlIHRoZWlyIGV4cG9u
ZW50cyAoZGVjcmVhc2luZykuDQoNCiAgICAgTm93IG11bHRpcGx5IHRvZ2V0
aGVyIGFsbCB0aGUgcHJpbWVzIHdpdGggdGhlIHNhbWUgZXhwb25lbnQgdXNp
b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=:24428
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="m_subs.h"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.44.0306151118341.24428@sheba.jesus.ox.ac.uk>
Content-Description: 
Content-Disposition: attachment; filename="m_subs.h"

c3RhdGljIGlubGluZSB1bnNpZ25lZCBsb25nIG1fbXVsICh1bnNpZ25lZCBs
b25nIHgsIHVuc2lnbmVkIGxvbmcgeSwNCiAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgdW5zaWduZWQgbG9uZyBtKQ0KLy8geHkgbW9kIG0N
CnsNCiAgdW5zaWduZWQgbG9uZyB6Ow0KICBfX2FzbV9fICgibXVsbCAlJWVj
eFxuIg0KICAgICAgICAgICAiZGl2bCAlJWVieCIgOiAiPWQiICh6KSA6ICJh
IiAoeCksICJjIiAoeSksICJiIiAobSkgOiAiY2MiKTsNCiAgcmV0dXJuIHo7
DQp9DQoNCg0Kc3RhdGljIGlubGluZSB1bnNpZ25lZCBsb25nIG1fc3FyICh1
bnNpZ25lZCBsb25nIHgsIHVuc2lnbmVkIGxvbmcgbSkNCi8vIHheMiBtb2Qg
bQ0Kew0KICB1bnNpZ25lZCBsb25nIHo7DQogIF9fYXNtX18gKCJtdWxsICUl
ZWF4XG4iDQogICAgICAgICAgICJkaXZsICUlZWN4IiA6ICI9ZCIgKHopIDog
ICJhIiAoeCksICJjIiAobSkgOiAiY2MiKTsNCiAgcmV0dXJuIHo7DQp9DQoN
Cg0KdW5zaWduZWQgbG9uZyBtX3BvdyAodW5zaWduZWQgbG9uZyB4LCB1bnNp
Z25lZCBsb25nIGEsDQogICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBs
b25nIG0pDQovLyB4XmEgbW9kIG0NCnsNCiAgdW5zaWduZWQgbG9uZyBwYXJ0
aWFsOw0KDQogIGZvciAocGFydGlhbCA9IDE7OykNCiAgew0KICAgIGlmIChh
ICYgMSkgcGFydGlhbCA9IG1fbXVsICh4LCBwYXJ0aWF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