I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » New Module Ideas »

number theory algorithms

lucian\′s Photo
24 Sep 05, 3:24PM
number theory algorithms
I agree that most calculations should be done using multiprecision arithmetic. I have written four components to provide basic operations: addition, subtraction and multiplication. They are located in the [b:3ac9e4e71b]Maths::Arithmetic[/b:3ac9e4e71b] category, and are called: [i:3ac9e4e71b]Add, Subtract, Multiply[/i:3ac9e4e71b] and [i:3ac9e4e71b]Karatsuba[/i:3ac9e4e71b]. The last one is a good algorithm for multiplying integers, having time-complexity less than ordinary school multiplication. Please view these components for more documentation.

The way I have implemented the functions was to handle positive integers, with digits belonging to an arbitrary numerical base from 2 to 10. The integers themselves are stored as [b:3ac9e4e71b]std::string[/b:3ac9e4e71b] objects to provide better accessibility in initialising them or displaying their values. I am fully aware there may be more optimized methods of storing such integers, perhaps even using a certain compression method.

I agree it would be good to have a set of multiprecision number theory algorithms that would form the base of all other numerical components on Code Cogs. This would have the advantage of providing an arbitrary number of precision digits in the evaluation of several mathematical functions, at the cost of execution speed. In my opinion it would be possible to create two overloaded versions of each numerical component, one using the ordinary [b:3ac9e4e71b]double[/b:3ac9e4e71b] type implemented with C, and the second using multiprecision arithmetic provided by the set of number theory algorithms. I would be interested in your opinion on this matter.
Currently you need to be logged in to leave a message.