Sqrt with precision guarantee for GMP#121
Conversation
|
Speaking of consistent implementations between CLN and GMP: there is also NumberMpq.cpp and NumberCIRA which also have sqrt implementations. @sjunges Do you know why there are multiple implementations? |
|
Ready for review. |
|
Hmm, are their big changes that require a re-review? Hard to see from the history :-) |
|
Sorry, rebase was a bit easier than merging after the formatting touched all files. It should suffice to look at the current state of the files, the main thing to check is whether the constant factor I added to achieve the precision is actually correct. There is a proof and I also added random tests which did not find any issues. I will remove the random tests before merging because they significantly increase the testing time. |
Added functions
sqrt_precisionto compute sqrt with given precision.For CLN, the use of
rationalizeshould already ensure the precision.For GMP, we scale both numerator and denominator to achieve the precision.
Fixes stormchecker/storm#873