0

I'm using GMPXX wrapper of GMP and it is not fast enough. Is it possible to find some comparison of rational number libraries' speed?

During my calculation a very big rational number will appear with 10^100 denominator and same size numerator.

Do you know something faster than GMP?

Robᵩ
  • 163,533
  • 20
  • 239
  • 308
petRUShka
  • 9,812
  • 12
  • 61
  • 95

2 Answers2

5

Do you know something faster than GMP?

It appears the Haskell folks faced a similar problem as yours. Here are their notes:

Robᵩ
  • 163,533
  • 20
  • 239
  • 308
-5

A rational is a float/double, the problem with that is basically the base 2 ( used by computers ) vs base 10 ( used by humans in the classic math calculus ), in the end getting a good representation of a generic rational number is a good challenge, considering a value with a magnitude of 10^100 this becomes an extremely good challenge.

I think that you should pause for a minute and think about this because a float generated by 10^100/10^100 can be really gigantic and doing this with a computer is something for a really advanced lab in my opinion, you can't expect a library to solve this kind of problems with efficiency and most importantly with accuracy with a magnitude this big.

further reading

Community
  • 1
  • 1
axis
  • 874
  • 2
  • 7
  • 13
  • 3
    I fear that you have missed the OP's point. He isn't using `float` or `double`. In fact, he isn't using floating-point representation at all. He is using a library called GMP which can store arbitrarily large numbers (beyond 32-bit or 64-bit). Yes, doing the math in software instead of in hardware **is** slower, and he is asking who publishes the fastest such software. – Robᵩ Oct 04 '12 at 19:04
  • @Robᵩ I'm supposed to suggest assembly or a random optimized assembly instruction set ? For what i know the problem base 2 vs base 10 still remains; store a number that i large or small but this problem is still there. – axis Oct 04 '12 at 19:07
  • 2
    @axis, rational numbers are represented as two integers, a numerator and a denominator. If the denominator is a power of 10 then you can precisely represent any decimal number you want. The base2/base10 problem doesn't occur with integers. – Mark Ransom Oct 04 '12 at 19:25
  • @MarkRansom ok, and what are you doing with this numbers ? just using random portion of memory for sport ? If you are going to use a rational it will be a float or worst. – axis Oct 04 '12 at 19:30