Feature: Add function to initialize mp_int from unsigned long

This patch adds the mp_int_init_from_uvalue function to initialize an
mp_int from an unsigned long int. The patch also includes new tests
for initializing from both unsigned and signed long ints.

This function is needed for GMP compatiability.
Feature: Add functions to return references to numer/denom

This commit adds two new functions to the rational number api:

  mp_rat_numer_ref()
  mp_rat_denom_ref()

These functions return a pointer to the underlying mp_int value used
by the rational number. It is the callers responsibility to not
modify the values in a way that invalidates any invariants needed by
the rational number implementation.

This function is needed for GMP compatiability.
Feature: Add function to assign mp_int from unsigned long

This patch adds the mp_int_set_uvalue function to assign an
mp_int from an unsigned long int. The patch also includes new tests
for assigning from both unsigned and signed long ints.

This function is needed for GMP compatiability.
Feature: Add function to assign mp_rat from two unsigned longs

This patch adds the mp_rat_set_uvalue function to assign an
mp_rat from two unsigned long ints. Internally it calls the
mp_int_set_uvalue function on the numerator and denomenator.

This function is needed for GMP compatiability.
BugFix: Change int to mp_small in api for mp_rat_set_value

This commit changes the function signature for mp_rat_set_value to
take an mp_small instead of an int. This change makes the function
consistent with the rest of the api which uses the mp_small typedef.
Note that mp_small is defined to be a long, so there should be no
change in functionality with this commit.
BugFix: Rewrite division function for unsigned integers

The previous division function was giving incorrect results for some
inputs. Rewrote the s_udiv function based on Knuth's algorithm.
BugFix: Fix off-by-one error in computing number of digits needed

There was a problem in the function used to compute how many digits
are needed to hold a number we are reading as a string. The function
produced incorrect results for integers with  29, 106, and 135
digits (probably more, but these are the cases I hit).
Add gmp compatibilty layer for imath

This commit adds a gmp compatibility layer for imath. The goal of
the compatibility layer is to provide the same interface and
functionality as gmp for a limited set of functions. The major
differences between the gmp api and the imath api that are addressed
by the compatiabilty layer are:

  1. gmp passes the output paramter as the first parmater
     imath passes the output parameter as the last paramter.

  2. gmp supports multiple rounding modes for division
     imath supports only the trucate rounding mode for division

  3. gmp support many operations that take an unsigned or a signed long
     imath supports only operations that take a signed long

In addition to these main differences, the compatibility layer also
fixes minor differences in behavior between imath and gmp functions
for certin inputs.

This commit also provides wrappers for import/export functions that
match the format provided by gmp. These functions can be used to
convert between gmp and imath integers.

A list of the 49 gmp rational and integer functions provided by this
compatibility layer are listed below.

Rational functions:
  mpq_clear
  mpq_cmp
  mpq_den_ref
  mpq_get_str
  mpq_init
  mpq_mul
  mpq_num_ref
  mpq_set
  mpq_set_ui
  mpq_sgn

Integer functions:
  mpz_abs
  mpz_add
  mpz_add_ui
  mpz_addmul
  mpz_cdiv_q
  mpz_clear
  mpz_cmp
  mpz_cmp_si
  mpz_cmpabs
  mpz_divexact
  mpz_divexact_ui
  mpz_divisible_p
  mpz_export
  mpz_fdiv_q
  mpz_fdiv_q_ui
  mpz_fdiv_r
  mpz_gcd
  mpz_get_si
  mpz_get_str
  mpz_get_ui
  mpz_import
  mpz_init
  mpz_lcm
  mpz_mul
  mpz_mul_2exp
  mpz_mul_ui
  mpz_neg
  mpz_pow_ui
  mpz_set
  mpz_set_si
  mpz_set_str
  mpz_set_ui
  mpz_sgn
  mpz_sizeinbase
  mpz_sub
  mpz_sub_ui
  mpz_submul
  mpz_swap
  mpz_tdiv_q
Force building imath with USE_LONG_LONG defined

This commit forces imath to be built with the -DUSE_LONG_LONG macro
defined. We explicitly define this value in the imath.h header
instead of relying on the value defined from the command line.

We force building this way so that the library is always built with
support for long long regardless of how it is compiled. This change
allows us to produce the same code for a library built using the
makefile and when imath is built when embedded in another project.
Add tests for gmp compatibility layer

The test suite includes a random data generator and scripts that
will run the test data through both imath and gmp and ensure that
the results match between the gmp and imath api implementations.
Improve mpz_get_str and mpq_get_str compatibility

This commit improves the gmp compatibility layer for the mpz_get_str
and mpq_get_str functions. There are two improvments:

  1. Use the same case as gmp when radix > 10
  2. Allow negative values for radix

Previously, imath would use uppercase for letters when creating a
string for a number in radix greater than 10. Now we use lowercase
for these letters to match gmp. We also support negative radix
values in the same way as gmp. A negative radix means to use
uppercase for any characters in the output string.

In addition to improved compatiability, we also updated the
gmp-compat-test suite to include tests for the mpz_get_str function.
Bug 8926: Use exact width int types for mp_digit and mp_word

This commit changes the data types used internally by imath to
implement large numbers. We now can use either the uint64_t or
uint32_t types for an mp_word.  The requirements for the mp_digit
and mp_word type is that mp_word is twice as large as an mp_digit.
The mp_digit type is used to store the individual digits of the
large integers.

By default we force the use of uint64_t for the mp_word type, but it
can be changed by modifying a #define in the imath.h header.

Note that we now have a dependency on the <stdint.h> header file. We
have also updated the makefile to build with -std=c99 flag because
the <stdint.h> header is part of the c99 standard.

The use of fixed width int types in <stdint.h> perhaps makes the
library less portable, but it increases the stability across
platforms because all versions will use the same size integers.

This change was motiviated by a build failure in suse linux that
occured because we were missing a #define for the max long long int
value ULLONG_MAX.
Add support for mpq calls in gmp-compat-test

This commit adds support for testing mpq calls to the gmp
compatibility test suite. The support for testing the rational
number (mpq) apis is as follows:

  * Update gmpapi to add an mpq_t c type
  * Update data generator to generate mpq_t values
  * Update test runner to pass mpq_t params as strings
  * Update c test generator to parse mpq_t params from strings
  * Update c test generator to call functions with mpq prefix
  * Update c test generator to return mpq_t values as strings

These changes allow us to add mpq api calls to the test suite.
Improve support for char* arguments in gmp-compat-test

This commit improves the support for passing string arguments in the
gmp compatiability tests. Previously we always assumed that char*
arguments would be null pointers. Now we allow char* arguments to
actually be passed as string values. To pass a null pointer use the
string NULL.

The improved string support will help in directly testing the
mpz_set_str and mpq_set_str functions.
Add mpq_set_str to gmp compatibility layer

In addition to the implementation of the mpq_set_str function we
added a test to the gmp compatibility test suite for this function.
Add the mp_rat_reduce function to imath api

This commit adds a wrapper for the s_rat_reduce function and makes
the wrapper an externally visibile part of the imath api.

This function is needed for GMP compatibility.
Add the mpq_canonicalize function to gmp compatibility layer

In addition to exposing this function through the gmp layer, we also
add a test to the gmp compatibility test suite.
Add calls to mpq_canonicalize in gmp-compat test suite

All of the arithmetic functions require the rational numbers be in
canonical form. For the gmp compatibility tests, we add calls to
mpq_canonicalize after parsing the test inputs from strings.
Add gmp compat tests for remaining mpq functions

This commit adds tests to the gmp compatiability test suite for the
remaining untests mpq functions. We now have tests for the following
functions:

  mpq_cmp
  mpq_mul
  mpq_set
  mpq_set_ui
  mpq_sgn
  mpq_get_str
Add make check target to run all unit tests

The make check target will run both the imath unit tests and the gmp
compatibility unit tests.