-
Notifications
You must be signed in to change notification settings - Fork 112
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
Mixing different cpp_int_backend #278
Comments
There's a couple of bugs, a big hole in our testing, and some documentation errors here... leave it with me. |
See #279. |
Thanks, that seems to help a bit. I assume it is just the first step, I am still getting 3 allocations for the testcase. I guess another important step would be to relax |
3 allocations in the test case is as low as it will ever get IMO: as there are 3 independent variables each with their own unique value (or am I missing something)? The move occurs when the result of Note you can also perform mixed arithmetic via:
Which calculates |
Only 3, because U has a large enough minBits that it does not require an allocation. That's actually the whole point of using U here. Yes, |
Ah yes I see. That's really hard to do in the general case for arbitrary complex expressions. The number of pairs of types for which it can be applied is really quite small as well as they need to be of equivalent precision (or actually that the precision of the result is <= precision of the arguments) otherwise the semantic change. There is also a more prosaic problem: I would need roughly twice as much code for the expression template unpacking in order to handle this. If I can write a suitably smart traits class (introspects to verify that a mixed precision operation is possible), and we restrict this to trivial expressions then something might be possible though. |
I was hoping that something simple like replacing the My motivation is that I would like to use 2 integer types, cpp_int by default, and U (as defined above, or something similar) for temporaries. I would introduce a |
The following program
causes 3 allocations. 2 are normal, for a and b. However, when evaluating c,
a*b
is first evaluated in type T (with an allocation) and then copied to type U, instead of being directly computed in an object of type U. If I naively edit boost to make it calldo_assign(true_)
, and extendsetup_karatsuba
andmultiply_karatsuba
to allow mixed types, it seems to work as expected. It would be useful to be able to mix those types without paying such a penalty.The text was updated successfully, but these errors were encountered: