GSOC Proposal for BIGINT - Long Mail

I had a look around in the Boost Sandbox and I found a BigInt implementation done by zeux during GSoC 07. I had a look at the code and I wanted to know its deficiencies. I'm interested in proposing some improvements in bigint and new bigdecimal implementation that is building on this code. There are 2 questions that I wanted to ask the list before moving further on this track: 1. Is there sufficient interest for a BigDecimal proposal on the lines of the Java implementation of BigDecimal (or has there been some prior work that can be used as a foundation?) 2. What are the deficiencies of bigint that have prevented its inclusion into the Boost distribution so as to address the same as part of my GSoC proposal. I did some homework and contrasted the bigint api in Boost and Java and found some interesting things that could be done. Boost.bigint was written by zeux and he used GMP bigint's features writing the Boost.bigint code around it. I think I could learn and analyse more after having a look at GMP bigint. After all, I think Boost.bigint should be more exhaustive. -------------------------------------------------------------------------------------------------------------------------------------------------------------- Feature Boost bigint Java BigInt -------------------------------------------------------------------------------------------------------------------------------------------------------------- Constructors from | int | byte[] #byte array with 2's complement representation of the BigInt. | unsigned int | int bitlen, int certainity #random BigInt with given bit length | int64_t | | uint64_t | | char *, int base | String | string& str, int base | String, radix -------------------------------------------------------------------------------------------------------------------------------------------------------------- *Conversion from string of digits to bigint is present. However conversion from/to byte-array(2's complement notation) to/from bigint isn't. Also the generation of a random arbitrary precision bigint should be done. int bitCount() #return the no of bits in 2's complement of the bigint; int bitLength() #no of bits excluding the sign bit double doubleValue() #casting bigint to double must be done. #even casts to int, uint and int64_t, char * must be done.* -------------------------------------------------------------------------------------------------------------------------------------------------------------- Arithmetic Operators += In Java, add, subtract, multiply, etc., | -= | *= | /= | %= | |= | &= | ^= #xor | <<= | >>= | ++ #postfix & prefix | -- #postfix & prefix -------------------------------------------------------------------------------------------------------------------------------------------------------------- Unary Operators + - BigInteger[] negate() ~ BigInteger[] not() ! #is zero < int compareTo(BigInteger val) <= BigInteger max,min(BigInteger val) > >= == != -------------------------------------------------------------------------------------------------------------------------------------------------------------- *These are some bit manipulators BigInteger clearBit(int n) #not in Boost.bigint #even setBit & toggleBit could be done, with a feature of changing the precision of the bigint. BigInteger[] testBit(int n) #also bit testers l* -------------------------------------------------------------------------------------------------------------------------------------------------------------- Binary Operators + BigInteger add(BigInteger val) - * BigInteger multiply(BigInteger val) {bigint lhs, int rhs} {int lhs, bigint rhs} / BigInteger divide(BigInteger val) % BigInteger mod(BigInteger val) , BigInteger modPower(BigInteger val) | BigInteger or(BigInteger val) & BigInteger and(BigInteger val) ^ BigInteger andNot(BigInteger val) << BigInteger shiftLeft(int n) >> BigInteger shiftRight(int n) -------------------------------------------------------------------------------------------------------------------------------------------------------------- Math function overloads abs(bigint_base) BigInteger abs(int exponent) pow(bigint_base, uint64_t) BigInteger pow(int exponent) div(bigint_base lhs, bigint_base rhs, bigint_base& remainder) BigInteger[] divideAndRemainder(BigInteger val) sqrt(bigint_base) ----------No Java version for BigInterger------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------- *BigInteger gcd(BigInteger val) #GCD would be one of the most important requirements for bigint #Also the Java function of bool ProbablyPrime() is very interesting and would be challenging to implement.* -------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Problem is a phenomenon indicating lack of thought. Swagat Konchada

On 24 March 2010 19:20, swagat konchada <swagatata@gmail.com> wrote:
1. Is there sufficient interest for a BigDecimal proposal on the lines of the Java implementation of BigDecimal (or has there been some prior work that can be used as a foundation?)
I think proposing a BigDecimal is premature until a BigInteger has made it into Boost. Keep the scope small for now; we don't know exactly what's needed just yet.
2. What are the deficiencies of bigint that have prevented its inclusion into the Boost distribution so as to address the same as part of my GSoC proposal.
Licensing is one issue; IIRC there is a significant portion for whom any license other than a Boost-like one is unacceptable, thus making a GMP-based, and thus LGPLed, BigInt insufficient. On the other hand, optimizing all the algorithms involved is a huge task, and probably not something the single-implementor/sponsor/maintainer model generally used by Boost is good at. As such, a Boost-only library would probably not have the performance demanded by a substantial portion of its users. So as I've said before, I think a Boost project should be mostly an expression-template system that provides a nice interface on top of an externally-provided set of numeric operations.

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of swagat konchada Sent: Wednesday, March 24, 2010 11:21 PM To: boost@lists.boost.org; Andrew Sutton Subject: [boost] GSOC Proposal for BIGINT - Long Mail
I had a look around in the Boost Sandbox and I found a BigInt implementation done by zeux during GSoC 07. I had a look at the code and I wanted to know its deficiencies. I'm interested
in proposing some improvements in bigint and new bigdecimal implementation that is building on this code. There are 2 questions that I wanted to ask the list before moving further on this track:
1. Is there sufficient interest for a BigDecimal proposal on the lines of the Java implementation of BigDecimal (or has there been some prior work that can be used as a foundation?) 2. What are the deficiencies of bigint that have prevented its inclusion into the Boost distribution so as to address the same as part of my GSoC proposal.
I did some homework and contrasted the bigint api in Boost and Java and found some interesting things that could be done. Boost.bigint was written by zeux and he used GMP bigint's features writing the Boost.bigint code around it. I think I could learn and analyse more after having a look at GMP bigint.
After all, I think Boost.bigint should be more exhaustive.
On the contrary, I think it should be limited to what you have suggested - but not decimal - that's more worms that you can chew! You should aim to finish test and document only the basics - and then add operators if time permits. Don't even think about GCD? But it is vital that what you produce should fit into the 'numeric_adaptor' scheme mentioned by Barend Gehrels. But be Boosts_Own_Version of Big int. It should be correct first rather than fast (anyone who wants speed will plug in the GMP version, if the licence allows). You should also study (and use as comparison for testing) Victor Shoup's NTL http://www.shoup.net/ntl/doc/tour.html (used in the Boost.Math package and http://www.ttmath.org/faq. See also Kevin Sopp's Boost sandbox version of mp_math - this works on GCC and but not on MSVC and might, with the authors agreement, provide a starting point. Good luck. Paul --- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow@hetp.u-net.com
participants (3)
-
Paul A. Bristow
-
Scott McMurray
-
swagat konchada