arbitrary-precision

Is there an arbitrary precision floating point library for C/C++ which allows arbitrary precision exponents?

浪尽此生 提交于 2019-12-06 19:14:19
问题 I'm looking for an arbitrary precision floating point library for C/C++ (plain C is preferred). I need arbitrary precision exponents. GMP and MPFR use fixed size exponents, so they are ineligible (I have some ideas for workarounds, but I prefer an out-of-the-box solution). It would be an nice feature if the exponent precision can be adjusted automatically to prevent infinity-values. If you know for sure that such an library does not exist, please say so. 回答1: There is nothing as mainstream as

Boost Geometry and exact point types

我与影子孤独终老i 提交于 2019-12-06 07:13:52
问题 I am currently working on a project which deals with geometric problems. Since this project will be used commercially I cannot use libraries like CGAL. I am currently using boost::geometry with inexact types but I encountered numeric issues. I tried to simply use an exact point type from boost::multiprecision but it doesn't compile when I call boost::geometry functions. I found this page which shows how to use a numeric_adaptor to use boost::geometry with exact number types. However, it seems

Find exact solutions to Linear Program

此生再无相见时 提交于 2019-12-06 03:54:24
I need to find an exact real solution to a linear program (where all inputs are integers). It is important that the solver also outputs the solutions as rational numbers, ideally without doing any intermediate steps with floating point numbers. GLPK can do exact arithmetic, but cannot display the solutions as rational numbers (i.e. I get 0.3333 for 1/3). I could probably attempt to guess which number is meant by that, but that seems very fragile. I was unable to find an LP solver that can do this kind of thing. Is there one? Performance is not a huge issue; my problems are very small. (I did

Ordering operation to maximize double precision

核能气质少年 提交于 2019-12-06 03:48:43
I'm working on some tool that gets to compute numbers that can get close to 1e-25 in the worst cases, and compare them together, in Java. I'm obviously using double precision. I have read in another answer that I shouldn't expect more than 1e-15 to 1e-17 precision, and this other question deals with getting better precision when ordering operations in a "better" order. Which double precision operations are more keen to loose precision along the way? Should I try to work with number as big as possible or as small as possible? Do divisions first before multiplications? I'd rather not use the

Restore a number from several its remainders (chinese remainder theorem)

你离开我真会死。 提交于 2019-12-06 03:32:24
问题 I have a long integer number, but it is stored not in decimal form, but as set of remainders. So, I have not the N number, but set of such remainders: r_1 = N % 2147483743 r_2 = N % 2147483713 r_3 = N % 2147483693 r_4 = N % 2147483659 r_5 = N % 2147483647 r_6 = N % 2147483629 I know, that N is less than multiplication of these primes, so chinese remainder theorem does work here ( http://en.wikipedia.org/wiki/Chinese_remainder_theorem ). How can I restore N in decimal, if I have this 6

Big Integer addition, I know the theory… still rusty in practice

社会主义新天地 提交于 2019-12-06 03:05:19
so, I'm trying to build a simple big integer class, I've read some pages on the internet and all that, but I'm stuck. I know the theory and I know that I need a carry but all examples I've seen, they focuded more in chars and in base 10 and well, I'm using a different approach to make it a bit more faster. I would appreciate some help with the plus assignment operator, the rest of it I'll try to figure it out by myself. #include <iostream> #include <string> #include <vector> using std::cout; using std::endl; class big_integer { using box = std::vector<int unsigned>; box data {0}; box split(std

Speed up x64 assembler ADD loop

时光毁灭记忆、已成空白 提交于 2019-12-05 15:44:21
问题 I'm working on arithmetic for multiplication of very long integers (some 100,000 decimal digits). As part of my library I to add two long numbers. Profiling shows that my code runs up to 25% of it's time in the add() and sub() routines, so it's important they are as fast as possible. But I don't see much potential, yet. Maybe you can give me some help, advice, insight or ideas. I'll test them and get back to you. So far my add routine does some setup and then uses a 8-times unrolled loop: mov

How to work on big integers that don't fit into any of language's data structures

喜欢而已 提交于 2019-12-05 12:24:54
问题 I'm trying to solve a programming contest's preliminary problems and for 2 of the problems I have to calculate and print some very big integers(like 100!, 2^100). I also need a fast way to calculate powers of this big integers. Can you advice me some algorithms or data structures for this?(btw, I read C Interfaces and Implementations 'arbitrary precision arithmetic' section but it doesn't help for pow()) EDIT: I think exponentiation by squaring method and bit-shifting will work for power but

Is there an arbitrary precision floating point library for C/C++ which allows arbitrary precision exponents?

吃可爱长大的小学妹 提交于 2019-12-05 00:43:05
I'm looking for an arbitrary precision floating point library for C/C++ (plain C is preferred). I need arbitrary precision exponents. GMP and MPFR use fixed size exponents, so they are ineligible (I have some ideas for workarounds, but I prefer an out-of-the-box solution). It would be an nice feature if the exponent precision can be adjusted automatically to prevent infinity-values. If you know for sure that such an library does not exist, please say so. There is nothing as mainstream as GMP/MPFR as far as I know. But Fredrik Johansson's arb contains a module called fmpr that provides floating

Boost Geometry and exact point types

北城余情 提交于 2019-12-04 11:56:33
I am currently working on a project which deals with geometric problems. Since this project will be used commercially I cannot use libraries like CGAL. I am currently using boost::geometry with inexact types but I encountered numeric issues. I tried to simply use an exact point type from boost::multiprecision but it doesn't compile when I call boost::geometry functions. I found this page which shows how to use a numeric_adaptor to use boost::geometry with exact number types. However, it seems outdated and I wasn't able to make it work. Can boost::geometry be used with exact number types ? How