Code Monkey home page Code Monkey logo

cprng's People

Contributors

vigna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cprng's Issues

Failed to build on: Apple clang version 15.0.0 (clang-1500.1.0.2.5), NTL 11.5.1; easy patch

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.