Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive precision multiplying mpz_int and mpfr_float #103

Closed
vbeffara opened this issue Dec 20, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@vbeffara
Copy link

commented Dec 20, 2018

Trying boost 1.69 on previously working code (with clang 7 on OSX), I ended up with the following weird behavior.

#include <boost/multiprecision/gmp.hpp>
#include <boost/multiprecision/mpfr.hpp>
#include <iostream>

using boost::multiprecision::mpfr_float;
using boost::multiprecision::mpz_int;

int main() {
    mpfr_float::default_precision(100);
    std::cerr << mpfr_float{mpz_int{1} * mpfr_float{1}}.precision() << "\n";
    std::cerr << mpfr_float{mpfr_float{mpz_int{1}} * mpfr_float{1}}.precision() << "\n";
}

The second output line says 100 which is what I expected; the first one says 646392383 and takes about 2 seconds, which is surprising.

This likely has to do with the "big update to better support variable precision types so that the precision of the result is always the largest of all the arguments" plus the fact that mpz_int would be understood as having infinite precision, but in that case it is not the intuitive behavior.

jzmaddock added a commit that referenced this issue Jan 24, 2019

Update precision detection to account for infinite-precision-integers.
Optimize precision comparison code to call the precision functions less often.
See: #103
@jzmaddock

This comment has been minimized.

Copy link
Collaborator

commented Mar 4, 2019

Fixed and merged to master.

@jzmaddock jzmaddock closed this Mar 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.