vigna / cprng Goto Github PK
View Code? Open in Web Editor NEWData and code associated with the paper "Computationally easy, spectrally good multipliers for congruential pseudorandom number generators"
Data and code associated with the paper "Computationally easy, spectrally good multipliers for congruential pseudorandom number generators"
I'm trying to run mspec
on the infamous RANDU number for fun and kicks, but it's just not cooperating. All of the commands in comp.sh throw the same error, so I will just post one:
g++ -std=c++17 -O3 -march=native spect.cpp -o spect -lntl
Here g++ is an alias to clang++. Anyways, it does the following:
out.txt
g++ --version
gives:
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Reading the error shows that there's some indecision between uint64_t
and unsigned long
. While on x64 mac both long
and long long
are 64 bits, the typedef goes to unsigned long long
. Because NTL only gives conv in unsigned long
, the compiler just won't take it.
I, uh, just threw unsigned long
explicitly into the template arguments in common.cpp
. Then it just worked:
template <> ZZ NTL_NAMESPACE::conv<>(const uint128_t& x) {
return conv<ZZ, unsigned long>(uint64_t(x >> 64)) << 64 | conv<ZZ, unsigned long>((uint64_t&)x);
}
template <> uint128_t NTL_NAMESPACE::conv<>(const ZZ& x) {
return uint128_t(conv<unsigned long>(x >> 64 & conv<ZZ>(0xFFFFFFFFFFFFFFFF))) << 64 | conv<unsigned long>(x & conv<ZZ>(0xFFFFFFFFFFFFFFFF));
}
template <> string hex<>(uint64_t a) {
return hex(conv<ZZ, unsigned long>(a));
}
Now I'm happy. I don't know, should I complain to the guys at NTL?
Alright, there is one more issue in search.cpp
, line 149. Again, specify the type as:
a = ((((conv<ZZ>(0) + next()) << 192) + ((conv<ZZ>(0) + next()) << 128) + ((conv<ZZ>(0) + next()) << 64) + conv<ZZ, unsigned long>(next())) & multiplier_mask) | multiplier_surround_bits;
and it works.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.