#

A Tour of NTL: Summary of Changes

### 2016.01.30: Changes between NTL 9.6.3 and 9.6.4

- Streamlined some of the installation scripts, so now the "heurstic selection of compiler flags" and the "nonstandard feature testing" procedures are more structured so as to be easier to extend in the future -- it is beginning to act more like a sort of "autoconf".
- Fixed a couple of "buglets" in the header files.

### 2016.01.26: Changes between NTL 9.6.2 and 9.6.3

- Some changes to the installation procedure:
  - For the Unix distribution, `NTL_GMP_LIP` is now on by default, which means that by default, NTL will use GMP.
  - By default, the configuration script will attempt a "native'' build by passing `-march=native` as a compiler flag. Most modern compilers support this, but the configuration script will check to make sure.
  - The `NTL_PCLMUL` flag (which enables the use of Intel's PCLMUL instruction) is now automagically set by the Wizard script.
  - The build script automatically checks for availability of Intel `AVX` intrinsics, which may be used to better optimize certain code.
- A new modular composition implemention for `zz_pX`. This makes modular composition up to 3x faster, depending on several factors. See here for details.
- Improved performance for polynomial factoring over `zz_pX` using `CanZass`, using the improved modular composition routine (above) and better choice of baby step / giant step parameters. This leads to a 1.1x to 1.8x speedup, depending on several factors.
- Improved robustness of `quad_float` implementation: it should now work correctly on platforms that are too liberal in their use of FMA instructions.

### 2015.11.13: Changes between NTL 9.6.1 and 9.6.2

- More small tweaks and a new configuration variable:

      NTL_MAXIMIZE_SP_NBITS=off

      # Allows for 62-bit single-precision moduli on 64-bit platforms.
      # By default, such moduli are restricted to 60 bits, which
      # usually gives *slightly* better performance across a range of
      # of parameters.

### 2015.11.13: Changes between NTL 9.6.0 and 9.6.1

- Streamlined some awkard code in `g_lip_impl.h`.
- Made `QuickTest` a bit quicker.
- Fixed some documentation/packaging problems.

### 2015.11.10: Changes between NTL 9.5.0 and 9.6.0

- More performance tuning for `ZZ_pX` arithmetic.
- Added configuration variable `CXXAUTOFLAGS`, which is dynamically (and heuristically) set by the configuration script. This way, `CXXFLAGS` is not modified by the script.

### 2015.10.20: Changes between NTL 9.4.0 and 9.5.0

- Added a new thread boosting feature. With this feature, certain code within NTL will use available threads to speed up certain computations on a multicore machine. This feature is enabled by setting `NTL_THREAD_BOOST=on` during configuration. See BasicThreadPool.txt for more information.

  This feature is a work in progress. Currently, basic `ZZ_pX` arithmetic has been thread boosted. More code will be boosted later.

- A bit more perfomance tuning for `ZZ_pX` arithmetic, and better crossovers for `ZZX` multiplcation.

### 2015.9.22: Changes between NTL 9.3.0 and 9.4.0

- Performance tuning: `ZZ_pX` and `zz_pX` keep getting faster
- Upgrade to pseudo-random number generation: I replaced the underlying PRG with Chacha20 (replacing RC4) and the underlying key-derivation function with a function based on HMAC-SHA256 (replacing an MD5-based function). The new routines are faster and more secure.

  I also expanded the PRG interface a bit: see here for details.

- Bug fixes: fixed a (mostly dormant) bug in the `ZZFromBytes` routine (triggered only when `n==0`).
- Added documentation for classes `RRPush` and `RROutputPush`: see here for details.

### 2015.7.9: Changes between NTL 9.2.0 and 9.3.0

- Fixed a compilation error that arose with `NTL_LEGACY_SP_MULMOD=on`.
- Added a new call back routine `ErrorMsgCallback`. See tools.txt. This is mainly to help with NTL integration withing SAGE.

### 2015.5.23: Changes between NTL 9.1.1 and 9.2.0

- Completed the transition away from floating-point arithmetic for the implementation of single-precision modular arithmetic. The current implementation should allow 60-bit moduli on 64-bit platforms that support a 128-bit extended integer type (this is the case for current gcc, clang, and icc compilers).

  One can still revert to the "classical" (pre-9.0) implementation using double-precision arithmetic (which imposes a 50-bit limit), or to the "long double" implementation introduced in v9.0 (60-bit limit).

  Note that one must compile NTL with GMP to get any of these improvements. It would have perhaps been better to use GMP's `longlong.h` facility instead of relying on compiler support for extended integer types. However, at the moment, it is a bit inconvenient to use `longlong.h` as a freestanding header file. This might change in the future.

  For details, see here, including the comments entitled "Compatibility notes".

  Programming notes: `MulMod(a, b, n)` is equivalent to `mulmod_t ninv = PrepMulMod(n);` `MulMod(a, b, n, ninv)`. Compared to the older, floating-point implementation, the relative cost of computing `ninv` is higher in the new regime. In a loop where `n` is invariant, the compiler should "hoist" the computation of `ninv`, so it is only done once. However, it is usually better to precompute and store `ninv`, and use the second form of `MulMod`, with `ninv` passed as a parameter (NTL does this internally quite consistently). The performance of `MulMod(a, b, n, ninv)` is somewhat faster in the new implementation. Where possible, one should use `MulModPrecon`, which is faster still (useful in situations where both `n` and `b` are invariant).

- A number of general performance improvements.

### 2015.5.16: Changes between NTL 9.1.0 and 9.1.1

- Fixed a bug introduced in 9.1.0 that prevented conversions between `Vec<GF2>` and `Vec<T>`.

### 2015.5.2: Changes between NTL 9.0.2 and 9.1.0

- Added a new configuration switch to enable the `PCLMUL` instruction on x86 machines. This can speed up `GF2X` arithmetic significantly (by a factor of 4). This is enabled by configuring with `NTL_PCLMUL=on` (and the configuration script automatically checks if it actually works on your platform).

  Note that this is an alternative to building NTL against the `gf2x` library (the latter is currently not thread or exception safe).

- Performance improvements to `zz_pX` and `Vec<zz_p>`.

- Performance improvements to `ZZX`: implemented asymptotically fast CRT code for `HomMul` and more cache-friendly logic. This routine is used for polynomials whose degree is significantly larger than the bit-length of its coefficients. This should make NTL's `ZZX` multiplication faster across a broader range of parameters, and at least be within a (hopefully not-too-large) constant factor of optimal.

- Some internal cleaning on the small-prime FFT code. I've made David Harvey's lazy butterfly routine without precomputed tables more competitive with the large-table variant, so now that large tables are used for a smaller range of parameters (this should reduce the overall memory footprint).

- Laid the groundwork for some future changes; namely, to allow 60-bit modular arithmetic without relying on the esoteric x87 fmul instruction. This should be coming soon (probably v9.2).

### 2015.3.29: Changes between NTL 9.0.1 and 9.0.2

- Made a small change to single-precison `MulMod` that enables slightly better compiler optimizations (compiler can "hoist" the computation of `1/n` out of a loop, so the variant with extra `mulmod_t` arg becomes somewhat less essential).

### 2015.3.27: Changes between NTL 9.0.0 and 9.0.1

- Fixed a small bug that prevented compilation a certain platforms.

### 2015.3.27: Changes between NTL 8.1.2 and 9.0.0

- With much trepidation, I have introduced a (hopefully minor) backward incompatibility into NTL. The interface to the single-precision modular arithmetic routines has been modified slightly. This interface change allows for more flexible and more efficient implementation of these routines, which play a crucial role at many levels in NTL.

  Basically, these changes to the interface abstract away some implementation details that arguably should never been there in the first place. By coding to the new interface, NTL clients will be able to benefit from the current and future improvements.

  In particular, on 64-bit x86/GCC platforms, single precision moduli can now be up to 60 bits, rather than 50 bits. While some operations may in fact be a little slower, the most important ones (like `MulModPrecon`) should not be. Using larger moduli speeds up a number of things, like `ZZ_pX` arithmetic, as fewer primes need to be used in Chinese Remaindering steps. Other applications benefit from larger moduli as well.

  It is expected that most NTL clients will not be affected at all. Moreover, any code that needs to be updated will be detected by the compiler, and the updates should be simple and mechanical. There is also a configuration flag that will enable the legacy interface (although this is not recommended practice).

  For details, see here, including the comments entitled "Compatibility notes".

- Other changes:
  - Previous versions of NTL relied (at least by default) on some undefined behavior regarding integer arithemtic (namely, that in a few key code sequences, signed integer overflow just "wraps around"). All of this undefined behavior has been replaced by (much more desirable) implementation-defined behavior (namely, that conversion from unsigned to signed works as expected). As in the past, the `NTL_CLEAN_INT` can be used to avoid all of these issues (but with the new code, this should truly be academic). For details, look here.
  - By request, added a function `xdouble exp(const xdouble& x)`, which is equivalent to `xexp(to_double(x))`. For details, look here.

### 2015.1.31: Changes between NTL 8.1.1 and 8.1.2

- Corrected a bug that could affect the `log` function in a multi-threaded execution.

### 2015.1.30: Changes between NTL 8.1 and 8.1.1

- Corrected a syntax error in `SmartPtr.h`, which most compilers don't seem to complain about, but some do.

- Added `--tag=CXX` to the some lines in the `makefile` to keep `libtool` happy.

### 2015.1.9: Changes between NTL 8.0 and 8.1

- Corrected an oversight in the matrix template class. With this new version, one may safely copy and assign objects of type `Mat<ZZ_p>` and `Mat<GF2E>` out of context (i.e., under a different or undefined modulus). More generally, the copy constructor for `Mat<T>` now relies only on the copy constructor for `Vec<T>` and the assignment operator for `Mat<T>` relies only on the assignment operator and copy constructor for `Vec<T>`.

  The goal since v6.2 has been to allow all modular types (`ZZ_p`, etc.) and all types derived from them (vectors, polynomials, matrices, etc.) to be safely copy constructed and assigned out of context. Hopefully, this goal has now been reached.

### 2014.12.24: Changes between NTL 7.0.2 and 8.0

- Exceptions!

  This is another major milestone for NTL, and hence the big version number bump (this will be the last of these big bumps for a while).

  Prior to this version, error handling consisted of "abort with an error message". To enable exceptions in NTL, configure with `NTL_EXCEPTIONS=on`. You will also need a `C++11` compiler for this to work properly (and if you don't enable exceptions, any old `C++98` compiler will work, as always).

  With exceptions enabled, errors are reported by throwing an appropriate exception. Of course, this was the easy part. The hard part was making NTL's code exception safe, which (among other things) means that no resources (i.e., memory) are leaked when an exception is thrown. This required a very painful top-to-bottom scrub of the whole library.

  Despite major changes to the code base and many internal interfaces, the external (i.e., documented) interfaces remain completely unchanged.

  More details are available here.

- Improved performance of `ZZ_pX` arithmetic for both classic and GMP-based long integer packages.

- Made copy constructor and assignment operators for `fftRep` and `FFTRep` safe "out of context", which extends to the classes `zz_pXModulus` and `ZZ_pXModulus`.

- Made mechanism for establishing "unique ID's" (used for temporary file name generation and default pseudo-random number seeds) more robust.

### 2014.12.15: Changes between NTL 7.0.1 and 7.0.2

- Fixed bug introduced in v7.0 affecting `RR` and `quad_float` input routines, which would leave the `RR` precision variable in an incorrect state.

- Fixed a bug introduced in the v6.2 that affected the append routines for `ZZ_p` and `GF2E`, which would lead to incorrect memory allocation (which, if triggered, should just have led to an error message and abort, rather than incorrect results). This bug also affected the new `Vec` constructor introduced in v7.0 (and again, only for `ZZ_p` and `GF2E`).

### 2014.11.14: Changes between NTL 7.0.0 and 7.0.1

- Fixed critical bug in new bit-reverse-copy routine. Large degree polynomial multiplication code was buggy in v7.0. Now it's fixed and properly tested.

### 2014.11.8: Changes between NTL 6.2.1 and 7.0

- Thread safety!

  This is a major milestone for NTL (and hence a bump in the major version number). However, to actually use it, you will need a "bleeding edge" `C++` that supports `C++11` concurrency features. Most importantly, the `C++11` storage class `thread_local` needs to be fully and correctly implemented. Some compilers claim to support it, but are very buggy to the point of being useless. All I can say is, as of right now, I have been able to successfully build and test a multi-threaded NTL program using GCC 4.9.2 on a Red Hat Linux distribution. I don't think any pre-4.9.x version of GCC will work. And unfortunatly, I don't think any compiler (GCC or CLANG) on any current Mac will work, but I haven't been able to directly test this.

  As time goes on, I expect `C++` compilers will provide the necessary support. In the meantime, you can try it out and see if it works for you. Configure with the `NTL_THREADS` flag turned on and see what happens. The test program `ThreadTest` that runs as the last step of `make check` will let you know if it works. If not, you can try building GCC 4.9.2 yourself. It is actually not that hard!

  See the portability and implementation section for more information. In any case, if threads don't work for you, just don't use them. Everything still works as before using almost any compiler.

- I changed the stream input behavior to conform to wider `C++` practice (and with an eye towards am exception safe future). Previously, if an attempt to read an NTL object failed, the good old `Error` function was called, printing an error message, and aborting your program. Now, NTL just quietly sets the ``fail bit'' of the stream. The second example here illustrates this. Hopefully, this change will not cause too many problems, but if it does, configure NTL with the `NTL_LEGACY_INPUT_ERROR` flag on to get the old behavior back.

- To further simplify future development, I've dropped support for legacy `C++` standard header files. That is, NTL always uses `<iostream>` rather than `<iostream.h>`. This shouldn't be a problem for anyone by now, as these lagacy header files have been gone from standard `C++` since 1998. Also, by default, NTL components are still wrapped in the `NTL` namespace, but for backward compatibility, you can still put them in the global namespace by configuring NTL with the `NTL_LEGACY_NO_NAMESPACE` flag.

- Implemented a cache-friendy "bit reverse copy" routine for doing FFT's. This is the COBRA algorithm from Cater and Gatlin, "Towards an optimal bit-reversal permutation algorithm", FOCS 1998. This does seem to help a bit. Getting rid of "bit reverse copy" would be even better, but this would take more work and break a number of interfaces.

- Made some minor improvements to `ZZX` multiplication routines to get better locality of reference. Improvement is nominal.

- Fixed a small issue in the left-shift `ZZ` routine: it was allocating one word more than necessary in some cases.

- Added new `Vec` constructor, so

  T a; Vec<T> v(INIT_SIZE, n, a);

  is equivalent to

  T a; Vec<T> v; v.SetLength(n, a);

  In both cases, the copy constructor for `T` is used.

- I've added some more documentation about what I plan on doing with NTL in the future, as well as a "wish list" of what I hope others might contribute. See the roadmap section for more details.

### 2014.8.26: Changes between NTL 6.2 and 6.2.1

- Fixed syntax problem in `NTL/vector.h`

### 2014.8.21: Changes between NTL 6.1 and 6.2

- I added explicit constructors corresponding to promotions. For example:

  ZZ w = ZZ(1); // legal ZZ w(1); // legal ZZ w{1}; // legal in C++11 ZZ w = 1; // not legal

  Also added new names for the "monomial constructors", e.g., `ZZX(INIT_MONO, i, c)` is now preferred to `ZZX(i, c)`, although the old constructors are still there. There are also new constructors like `ZZX(INIT_MONO, i)` for making monic monomials.

- An subtle but important change is that now objects from classes that represent residue class rings with a dynamically installed modulus, i.e.,

         ZZ_p, zz_p, ZZ_pE, lzz_pE, GF2E,

  may now be used a bit more flexibly.

  It is critical that such objects created under one modulus are not used in any non-trivial way "out of context", i.e., under a different (or undefined) modulus. However, for ease-of-use, some operations may be safely performed out of context. These safe operations now include: the default and copy constructor, the destructor, and the assignment operator. In addition it is generally safe to read any object out of context (i.e., printing it out, or fetching its underlying representive using the rep() function). (In the past, it was generally unsafe to use the the default and copy constructors out of context, which also prevented vectors and polynomials of such objects from being copied out of context.)

  The implementations of `Vec<ZZ_p>` and `Vec<GF2E>` are still specialized to manage memory more efficiently than in the default implementation of `Vec<T>`. Contiguous elements in such an array are allocated in a contiguous region of memory. This reduces the number of calls to the memory allocator, and leads to greater locality of reference. A consequence of this implementation is that any calls to `SetLength` on such a vector will need to use information about the current modulus, and so such calls should only be done "in context". That said, it is still safe to construct a such a vector using the default or copy contructor, and to assign or append one to another "out of context".

- For the classes `ZZ_p`, `ZZ_pE`, `zz_pE`, and `GF2E`, added explicit "allocation" and "no allocation" contructors (invoked with `INIT_ALLOC` and `INIT_NO_ALLOC`) and special member function `allocate()`. This allows one to explicitly determine exactly when space for such objects is allocated. By default, no space is allocated (this is different from prior versions of NTL), except for `ZZ_p`'s that are a part of a `Vec<ZZ_p>` and `GF2E`'s that are a part of a `Vec<GF2E>`

- Added new classes `ZZ_pPush`, `ZZ_pEPush`, `zz_pPush`, `zz_pEPush`, `GF2EPush`. These allow one to conveniently backup and optionally install a new modulus in one step:

  { ZZ_pPush push(p); ... }

  will save the current modulus and install `p` as the new modulus; when the destructor for `push` is invoked, the old modulus will be re-installed.

- Made the one-arg constructors for all the various "context" classes (e.g., `ZZ_pContext`) explicit.

- As a general aid to generic programming, I've added a bunch of typedef's using consistent naming conventions to all of the main arithmetic classes. E.g., `ZZ_p::poly_type` is a typedef for `ZZ_pX`. There are a whole bunch of these. See the documentation for the individual classes for details.

- Got rid of a few esoteric compilation modes:
  - All files are now `C++` files, and should be compiled using a `C++` compiler. In older versions, some files could be compiled either as `C` or `C++`.
  - The flag `NTL_GMP_HACK` is no longer supported. GMP may still be used using the `NTL_GMP_LIP` flag, which is still highly recommended for high-performance applcations.
  - The flags `NTL_SINGLE_MUL` and `NTL_FAST_INT_MUL` are no longer recognized. These were really outdated and esoteric.

- I have started working towards making NTL thread safe. It is not as difficult as I thought it would be, but it is still a work in progress. So far I have identified all global variables, and either got rid of them, or tagged them as "thread local". So, although there are still some global variables, they will all eventually be "thread local". In particular, things like the current `ZZ_p` modulus will be a thread-local global variable.

  There are a few remaining trouble spots I've tagged: these mostly involve lazy initialization of tables; I have a plan for making this code thread safe using nearly lock-free coding techniques.

  I will hopefully get this done within the next 6-12 months. One thing that is slowing me down is the lack of availibility of `C++11` features that I need to do some of this, but it will come.

  The main reason for getting rid of the esoteric compilation modes mentioned above is to make it easier to do this thread-safety work.

### 2014.03.13: Changes between NTL 6.0 and 6.1

- Added support for "user defined" FFT primes for `zz_p`. See the functions

  static void zz_p::UserFFTInit(long p); zz_pContext::zz_pContext(INIT_USER_FFT_TYPE, long p);

  in the `lzz_p` module.

### 2013.02.15: Changes between NTL 5.5.2 and 6.0

- Replaced the old template-like macros for vectors, matrices, and pairs with true template classes: `Vec<T>`, `Mat<T>`, and `Pair<S,T>`.

  For backwards compatibilty, all the names that were used in previous versions (e.g., `vec_ZZ_p`, `mat_ZZ_p`) have been replaced with appropriate typedefs.

  For many years, I resisted the temptation of using templates, because compiler support was very inconsistent. But that no longer seems to be the case.

  This change, while rather sweeping, should create very few, if any, incompatibilities with existing software. The biggest issue would be for software that uses the old template-like macros: such macro invocations can simply be replaced with appropriate typedefs.

- Made the conversion interface more complete and uniform. Also, using template notation, one can and should now write `conv<ZZ>(a)` instead of `to_ZZ(a)` (for backward compatibility, all the old names `to_XXX` are still there, but many new conversions are not available under these old names).

  There are many new conversions provided. Moreover, whenever there is a conversion from a ring R to a ring S, there is a corresponding, coefficiet-wise conversion from the polynomial ring R[X] to the polynomial ring S[X].

  In addition, using the template mechanism, there are generic conversions for vectors and matrices. For example, if there is a conversion from `S` to `T`, then there is automatically a corresponding component-wise conversion from `Vec<S>` to `Vec<T>`.

- Introduced a more general mechanism for accessing `GF2`'s in packed structures via indexing (see the class `ref_GF2` in the `GF2` module).

- Employed ideas from David Harvey to make the single-precision FFT faster (about twice as fast in many cases). This speeds up many higher-level operations. See: Faster arithmetic for number-theoretic transforms. J. Symb. Comp. 60 (2014) 113-119.

- Fixed all known bugs.

### 2009.08.14: Changes between NTL 5.5.1 and 5.5.2

- New routines `MulAddTo` and `MulSubFrom` for computing `x += a*b` and `x -= a*b`, where `x` and `a` are `ZZ`'s and `b` is a `ZZ` or a `long`. In the case where `b` is a `long`, this may be much faster than writing `mul(t, a, b); add(x, x, t)`. See ZZ.txt for details. These new routines are used in a number of places in NTL to get faster algorithms (for example, the `LLL` routine).
- Fixed a relatively benign indexing bug in `GF2EX` discovered by Berend-Benjamin Tams using the `valgrind` tool.

### 2009.05.05: Changes between NTL 5.5 and 5.5.1

- If using GMP (via either `NTL_GMP_LIP` or `NTL_GMP_HACK`), then the new version (4.3.0) of GMP implements the `XGCD` functionality differently, so that the coefficients do not always agree with those returned by the classical extended Euclidean algorithm. This version of NTL corrects the coefficients, so that the "classical" coefficients are always produced, regardless of GMP's implementation. This version of NTL also works around a bug in GMP 4.3.0's `XGCD` code (although that bug should be fixed in GMP 4.3.1).
- The `configure` script has been slightly modified: there is a new configuration variable `DEF_PREFIX`, whose value can be used to set `PREFIX`, `GMP_PREFIX`, and `GF2X_PREFIX` in one stroke. Also, the (somewhat esoteric) `configure` variables `GMP_LIBDIR`, `GMP_INCDIR`, `GF2X_LIBDIR`, and `GF2X_INCDIR` have slightly different meanings now.

### 2009.04.08: Changes between NTL 5.4.2 and 5.5

- Added the ability to generate a shared library (with help from Tim Abbott). Details.
- Fixed some standardization issues (with help from Tim Abbot): default location of installed documentation files now conforms to standards; use of `EOF` now conforms to standards.
- Added a callback mechanism to NTL's error reporting function. See `ErrorCallback` in tools.txt.
- Added support for the `gf2x` library for speeding up arithmetic in `GF2X` (with help from Emmanuel Thomé). Details.
- In conjuction with the above, I also changed the `GF2X` so that it works better with very large polynomials: large blocks of memory are released, recursive HalfGCD algorithms are used for large polynomials.
- Fixed a bug in `void TraceMod(zz_p& x, const zz_pX& a, const zz_pXModulus& F)` (reported by Luca De Feo).
- Fixed a performance issue in various versions of `SetCoeff` (reported by Luca De Feo).
- Fixed the declaration of `mat_zz_p transpose(const mat_zz_p& a)` (reported by Benoit Lacelle).

### 2008.03.05: Changes between NTL 5.4.1 and 5.4.2

- Fixed a bug in the `sub(ZZ_pEX, ZZ_pE, ZZ_pEX)` and `sub(zz_pEX, zz_pE, zz_pEX)` routines (reported by Charanjit Jutla). Under certain circumstances, these could outout wrong answers.

### 2007.05.09: Changes between NTL 5.4 and 5.4.1

- Fixed rounding bug in `expm1` (reported by Paul Zimmermann).
- Fixed memory leak in several LLL routines (reported by Friedrich Bahr).
- Fixed infinite loop in several LLL routines (this only occurred on machines, like x86, with double rounding).
- Improved `GF2X` timing tests (suggested by Paul Zimmermann).

### 2005.03.24: Changes between NTL 5.3.2 and 5.4

- By default, NTL now compiles in ISO mode (using namespaces, etc.). You can always revert to traditional mode by unsetting the flag `NTL_STD_CXX` (either pass `NTL_STD_CXX=off` to the configure script, or manually edit the `config.h` file).

- Some bug fixes:
  - The `sqrt` and `log1p` routines for the `RR` class would produce incorrectly rounded results in certain circumstances (although this only affected the relative error of the result very marginally).
  - The `SqrRootPrec` routine for the `RR` class could not be called, because it was defined incorrectly.

  Thanks to Paul Zimmermann for finding (and fixing) these bugs! Paul has also validated NTL's `RR` class by cross-checking it with the MPFR library.

- Some performance enhancements:
  - Added a new `MulModPrecon` inline function for computing `(a * b) % n` for single precision numbers, when `b` and `n` are fixed for several computations. On some platforms this can be twice as fast or more than the old `MulMod2` routine. This indirectly affects a lot of computations that are done via homomorphic imaging (polynomial multiplication over `zz_p`, `ZZ_p`, and `ZZ`, matrix computations over `zz_p` and `ZZ`).
  - Rewrote the small prime FFT to take advantage of the new `MulModPrecon`, and to be more cache friendly.
  - Improved the performance of the `GF2X` multiplication routine. On some platforms, it can be twice as fast as the old one. Thanks (again) to Paul Zimmermann for suggesting some of these improvements and supplying some of the code.

- Miscellany:
  - Rewrote several of the installation scripts in Perl (the old shell scripts were getting too messy to maintain). However, the syntax for all of the command-line interfaces remains identical.

### 2004.05.21: Changes between NTL 5.3.1 and 5.3.2

- Some bug fixes.

- Re-wrote `SqrRootMod` to make it run faster.

### 2002.12.17: Changes between NTL 5.3 and 5.3.1

- Fixed a bug affecting the `BuildIrred` routines for `ZZ_pEX` and `zz_pEX`.

### 2002.07.05: Changes between NTL 5.2 and 5.3

- Minimized and isolated constructs that do not adhere to `C`/`C++` standards, and added flags `NTL_CLEAN_INT` and `NTL_CLEAN_PTR` which force stricter compliance with these standards [more details].

- Added functions `IsWhiteSpace`, `CharToIntVal`, and `IntValToChar` to the `tools` module [more details].

- Added methods `allocated`, `position1` to generic vector classes [more details].

- Added method `allocated` to the class `vec_GF2` [more details].

- Added conversion routines from unsigned int/long to int, long, float, and double [more details].

- Added routines `AddPrec`, `SubPrec`, etc., to the `RR` module, and declared the practice of directly assigning to the variable `RR::prec` obsolete [more details].

- Fixed a number of minor bugs.

### 2001.07.19: Changes between NTL 5.1a and 5.2

- Implemented Mark van Hoeij's new algorithm for factorining polynomials with rational coefficients. This new algorithm is much more efficient than the previous algorithm used by NTL, and is the default (one can switch back to the old algorithm with a run-time switch).

  [documentation]

  [performance measurements]

- Added routines `LLL_plus` that are just like the all-integer `LLL` routines, except that they return the exact values of the squared lengths of the Gramm-Schmidt basis vectors. This is useful in implementing van Hoeij's algorithm. [more details].

- Made a small change to `quad_float.c` to make it compile under gcc version 3.0 without errors. This is the one place in NTL where I resort to just a little assmebly code (but only on x86/Linux platforms), and wouldn't you know it, this is the one place where gcc 3.0 had problems.

- Made a small change to the procedure for generating a distribution, so that now all files in the "tar" file comprising the distribution come without any annoyingly excessive access control restrictions.

- Changes the version numbering scheme so that it is now closer to "standard practice". This is version "5.2". Any small bug fixes to this version will be named "5.2.1", "5.2.2", etc. Also, macros are now defined so that the numerical components of the version number are available to the programmer. [more details].

### 2001.06.08: Changes between NTL 5.0c and 5.1a

Some minor fixes and additions.

Completely backward compatible.

- Added a routine `LatticeSolve()` for finding integer solutions to linear systems of integer equations. [more details]

- Modified the stragey used by the `LLL()` and `image()` routines in the LLL package to deal with linear dependencies. The new strategy guarantees better worst-case bounds on the sizes of intermediate values. I'm not sure if it will have any serious practical impact, though.

- Added some "partial ISO modes" so that one can use some of the features of Standard `C++`, even if ones compiler does not yet support all of the features.

- Bug fix: routine `determnant()` in `mat_GF2.h` was not visible to the linker because of a typo in `mat_GF2.c`.

- Made a "smarter" script for selecting the `GetTime()` function. This fixes an installation problem on Cygwin/Windows 95 platforms. I hope it doesn't create more problems than it solves, though.

- Added some extra documentation for installation under Windows/MS Visual `C++`. [more details]

- Changed some names like `c_lip.c` to `c_lip_impl.h`. This should avoid some potential installation problems.

- Throw away first 256-bytes of arc4 streams to improve quality of the pseudo-random number generator. This may change the precise behavior of some programs.

- Other minor, internal modifications.

### 2001.02.19: Changes between NTL 5.0b and 5.0c

Fixed a naming problem in the Windows distribution. The Unix distribution is unaffected.

### 2001.02.19: Changes between NTL 5.0a and 5.0b

Fixed a typo in `vec_ulong.c` that causes a compile error on some platforms.

### 2001.02.19: Changes between NTL 4.3a and 5.0a

- I've now re-structured NTL so that one can use either 'traditional' LIP or GMP as the primary long integer package. Doing this introduced some (minor) backward incompatabilies in the programming interface, so there is also a 'third way' -- you can use GMP as a supplemental long integer package (as in NTL 4.3), getting many (but not all) of the performance benefits of GMP, while maintaining complete backward compatability with the traditional long integer package. This 'third way' is not highly recommended -- it is only intended as a backward compatabilty hack.

  Even if you do not use GMP, you should read about using NTL with GMP so that you can write code that works with either the traditional or GMP long integer packages.

- Added a `ZZ` to unsigned long conversion routine. [more details]
- Added new vector classes `vec_ulong` (vectors of unsigned longs) and `vec_vec_ulong`. [more details]
- Some minor bug fixes: under some unusual circumstances, a memory allocation error could be erroneously raised; I also added a patch that works around a bug in v3.0.1 of GMP.
- Some internal cleansing, minimizing the use of non-standard constructs.

### Changes between NTL 4.2a and 4.3a

This is backward compatible with previous versions.

- Improved the performance of `ZZ_pX` arithmetic when using GMP. The GMP version is also more space efficient (the pre-computed tables are much smaller). These improvements are most marked for very large `p` (several thousand bits).

  The only thing unsatisfactory about this state of affairs is that vis a vis the GMP version, the pure LIP code is asymptotically slower by more than a constant factor, and is is also less space efficient. Perhaps I'll get around to rectifying this imbalance someday. To do this, I need a sub-quadratic division with remainder routine for LIP. At any rate, the differences only become seriously noticible when `p` has more than a few thousand bits.

- Some other small adjustments here and there.

### Changes between NTL 4.1a and 4.2a

This is backward compatible with previous versions.

- Hacked the big integer code so that NTL uses GMP (the GNU Multi-Precision library). This is done in such a way as to get most of the benefits of GMP with a reasonable amount of effort, and while maintaining complete backward compatability and minimizing the risk of introducing bugs. Some arithmetic operations on some platforms may execute two to three times faster if using GMP. [more details]
- Simplified the installation procedure on Unix systems by providing a simple configuration script so that setting various configuration variables can be done without editing the `makefile` and `config.h` file. [more details]
- Added function `GenGermainPrime` to efficiently generate random Germain primes, i.e., primes p such that 2p+1 is also prime. [more details]
- Added a function `random` to generate random `quad_floats`. [more details]
- Added an `ifdef` in `tools.h` that allows one to suppress the declaration of `min` and `max` functions in NTL client programs; these were causing problems when writing 'Windows applications'.
- Implemented a faster algorithm for initializing the `ZZ_p` auxilliary data structures.
- Polished up a few other minor things in the code and documentation.

### Changes between NTL 4.0a and 4.1a

This is backward compatible with previous versions.

- Made some changes that should make NTL compile smoothly using any variation of the `C++` language between traditional and ISO Standard. These changes do not affect the documented NTL interface or the behaviour of NTL.
- Added a flag `NTL_STD_CXX` in the `config.h` file. Setting this flag causes all of NTL to be "wrapped" in namespace `NTL`, and that part of the standard library used by NTL is "wrapped" in namespace `std`. This should greatly help with the namespace pollution problem.

### Changes between NTL 3.9b and 4.0a

This is backward compatible with previous version.

- Attached the GNU General Public License to NTL.
- Fixed two bugs:
  - one in `ReconstructRational` which resulted in a crash on some inputs;
  - one in `exp(RR)` (and by implication in `pow(RR,RR)`), which led to wrong answers on 64-bit machines when computing `exp(x)` for `x > 2^53`.
- Increased some inconvenient limiting bounds, including a restriction on the FFT.

### Changes between NTL 3.9a and 3.9b

This is a minor revision of 3.9a.

- Improved time and space efficiency of the HNF routine (see `HNF.txt`). The old version was based on the description in Henri Cohen's book, which was not really properly optimized.

### Changes between NTL 3.8b and 3.9a

This is backward compatible with previous versions.

- Modified the installation script somewhat, adding a configuration wizard that sets the flags in `config.h` "automagically". This works for the Unix version only.
- Improved the `xdouble` input/output and ascii to `xdouble` conversion. The old version could be a bit flaky when reading/writing very large numbers. The new I/O routines also attain better accuracy.
- Improved conversion routines between `xdouble` and `ZZ`/`RR`.
- Improved the `RR` output routine. The new version should be more accurate and also completely platform independent.
- Added the following routines to the `RR` package:

         {Trunc,Floor,Ceil,Round}ToZZ, round
         RoundToPrecision, MakeRR
         random

  See `RR.txt` for details.
- Improved the accuracy of `quad_float` input/output, and the accuracy of conversion between `quad_float` and `RR`.
- Made the timing function somewhat more robust.
- Hacked the Unix installation script so that it works more smoothly with Cygnus tools under Windows.
- Fixed a few other, small problems.

### Changes between NTL 3.8a and 3.8b

This is a minor revision of 3.8a.

- Fixed a bug, a memory leak in routine `gauss` for `mat_ZZ_pE` and `mat_zz_pE`.
- Fixed a minor problem in `config.h`.
- Tightened up some size checks, so that now some nice "size invariants" are guaranteed, e.g., for a `ZZ` `n`,

  NumBits(NumBits(n)) <= NTL_BITS_PER_LONG-4

  Similarly for the type `GF2X`. Of course, on most platforms, one will run out of memory before these bounds are exceeded, but they are nevertheless convenient.

### Changes between NTL 3.7a and 3.8a

This is backward compatible with previous versions.

- Added conversion routines from `unsigned` `int` and `unsigned` `long` to `ZZ`, `RR`, `xdouble`, and `quad_float`.
- Added routines `GF2XFromBytes` and `BytesFromGF2X` for conversion between byte vectors and polynomials over `GF(2)`, along with routines `NumBits` and `NumBytes` for such polynomials. See `GF2X.txt` for details.
- Added a hack in the `ZZX` factorizer to exploit polynomials of the form `g(x^k)`. This can be disabled by setting the variable `ZZXFac_PowerHack` to zero. See `ZZXFactoring.txt` for details.
- Improved the hensel system solver `solve1`. See `mat_ZZ.txt` for details.
- Changed documentation for `RationalReconstruction` to reflect the Wang, Guy, Davenport bounds. See `ZZ.txt` for details.
- Improved the routine `GenPrime` a bit.
- Some other small tweaks here and there. No real bug fixes.
- Polished the documentation a bit, adding more examples.

### Changes between NTL 3.6b and 3.7a

This is backward compatible with previous versions.

- Added a "rational reconstruction" routine. See the routine `ReconstructRational` in ZZ.txt.
- Added another routine for solving linear systems over `ZZ` that is based on Hensel lifting, rather than Chinese Remaindering. It can be significantly faster in some cases. See the routine `solve1` in mat_ZZ.txt).
- Some performace tuning, especially CRT and polynomial interpolation code.
- Various documentation corrections.
- Added more "overflow checks" here and there to ensure programs crash gracefully when certain things get too big.
- Fixed a "benign" bug (i.e., it would never get triggered on any of today's machines).
- Removed references to `<malloc.h>`, which were unnecessary, non-standard, and caused problems on some platforms.

### Changes between NTL 3.6a and 3.6b

Bug fixes.

### Changes between NTL 3.5a and 3.6a

This version is backward compatible with 3.5a.

- A few small bug fixes and performance enhancements.
- Changed to the `ZZX` factoring routines that in some cases yield dramatic performance improvements (more details).

### Changes between NTL 3.1b and 3.5a

Please note. This version is NOT completely backward compatible.

Summary of changes:

- Improved performance of the "all integer" LLL routine.
- Put in a better pseudo-random number generator, and added ZZ/byte array conversions.
- Improved performance of primality test, and added a more convenient routine `GenPrime`.
- Overloaded NTL's vector placement "new" operator in a different way to avoid conflicts with standard `C++` library.
- Renamed many macros.
- Renamed header files.
- Made some changes to the packaging the installation procedure.

Renamed Macros. I renamed many macros defined in NTL header files.

The reason is that I want to minimize namespace pollution. Someday, NTL will be wrapped in a namespace, and when that happens the only remaining namespace pollution problems will be caused by macros. Eliminating all macros from NTL is not feasible. Instead, all NTL defined macros now begin with the prefix "NTL_", which reduces the namespace pollution to an ecceptable level. You will probably not be affected by this, unless you do some low level hacking using a macro like `ZZ_NBITS` (now called `NTL_NBITS`), or unless you create your own NTL vectors using a macro like `ntl_vector_decl` (now called `NTL_vector_decl`).

For a complete list of affected names, see names.txt.

Adapting to this name change should be painless, as there is a program to translate source files from the old naming convention to the new. The file "newnames.c", can be compiled as either a `C` or `C++` program. The program is a "filter" that copies its input to its output, replacing all the old macro names by the new macro names.

In the WinNTL distribibution, "newnames.c" is called "newnames.cpp" and is located in the directory "newnames".

Renamed header files. The names of header files themeselves pollute another (extra-linguitsic) namespace. To alleviate this problem, the header files have been renamed. Instead of

#include "foo.h"

one now should write

#include <NTL/foo.h>

The only exceptions are the old header files "ntl_vector.h", "ntl_matrix.h", and "ntl_pair.h", which are now called `<NTL/vector.h>`, `<NTL/matrix.h>`, and `<NTL/pair.h>`.

Installation procedure. Now all NTL flags like NTL_LONG_LONG, NTL_AVOID_FLOAT, etc., can now be set by editing the special file "include/NTL/config.h". See details in that file. The reason for this change is that this allows all of these settings to be made when NTL is configured and built. Clients of NTL will then automatically use consistent settings. One should not set these flags on the compiler command line as previously.

Pentium/Linux people should no longer have to worry about the NTL_X86_FIX flag. NTL now psychically deduces the "right thing to do", although if its psychic abilities fail, you can override it with flags in "include/NTL/config.h".

The "packaging" in the Unix distribution is slightly different, but hopefully nicer. Among other things, the tar file now unpacks into a sub-directory of the current directory. See the unix installation section for more details. The Windows zip file now also unpacks into sub-directory.

My apologies. Although these changes are minor, they will cause some NTL users some inconvenience. I apologize for this. I really, really hope there are no more changes like this (see my roadmap of NTL's future).

### Changes between NTL 3.1a and 3.1b

Defined functions `div(GF2X,GF2X,GF2)` and `div(GF2X,GF2X,long)`, which had not been defined in earlier versions. Affected file: `GF2X.c`. Most programs never use this, and most linkers do not complain if these are missing (but some do).

### Changes between NTL 3.0f and 3.1a

This version is backward compatible with previous versions.

- Added floating point LLL routines based on Givens rotations, instead of classical Gramm-Schmidt orthogonalization. This is a more stable, but somewhat slower, method. See LLL.txt for details.
- Added support for irreducible trinomials and pentanomials over GF(2). The `GF2XModulus` routines, and by extension, the `GF2E` routines, now exploit moduli of this special form. The new routine `BuildSparseIrred` in `GF2XFactoring` builds irreducibles of this form.
- Also implemented a faster modular inversion routine for `GF2X`, and improved the performance of `ZZ_pX` multiplication for small degree polynomials.

### Changes between NTL 3.0e and 3.0f

- Fixed a bug (another one) affecting routines

         RandomBits, RandomBits_ZZ

  in module `ZZ`. Affected source file: `lip.c`.
- Bug fix and performance tweak in `ZZX` factorizer. Affected source file: `ZZXFactoring.c`.

### Changes between NTL 3.0 and 3.0e

- Fixed a bug affecting routines

         RandomBits, RandomBits_ZZ, RandomBits_long

  in module `ZZ`. The only source files that are affected and require re-compilation are

         ZZ.c, lip.c

- Note about names: 3.0a-c were "pre-releases", which makes the "first release" 3.0d, and hence this bug fix 3.0e.

### Changes between NTL 2.0 and 3.0

- Added functionality:

  - Added classes vec_GF2 and mat_GF2 for fast linear algebra over GF(2).
  - Added classes ZZ_pE, ZZ_pEX, zz_pE, zz_pEX, supporting polynomial arithmetic over extension rings/fields over prime fields.
  - Added John Abbott's pruning heuristic to the ZZX factoring routine.
  - Speeded up multiplication in zz_pX for small p (this also helps the ZZX factoring routine).
  - Added some some transcendental functions (e.g., exp, log, pi) to RR.
  - Added verbose mode and pruning to the XD and RR variants of LLL.

- Improved programming interface: with this version, I've taken an the opportunity to give the programming interface a "professional facelift". In previous releases, I've tried to maintain backward compatability as much as possible, but to make the badly needed improvements to the interface that I've made with this release, this was not possible.

  NTL 3.0 is not backward compatable with NTL 2.0.

  I apologize to NTL users for this, but it is a bit of painful medicine that should only be necessary to take just this one time (but then as a `C++` programmer, you must already be used to suffering ;-). Just about all of the incompatabilities are detectable by the compiler. See below for a detailed list of the changes and some tips on making the transition.

  The new interface is much more enjoyable to work with, and I don't foresee any changes to the interace in the future. Here is a broad overview of the changes:

  - Added functional/operator notation consistently throughout NTL, making it possible to write much more concise and readable code.
  - Got rid of automatic type conversions: these cause just too many problems. But I've overloaded all of the basic arithmetic operators and procedures so as to emulate a natural kind of "type promotion" logic. With these promotions, along with a full compliment of conversion functions, one hardly misses the automatic conversions.
  - Got rid of the macros

           vector(T), matrix(T), pair(T),

    which were causing too many name space problems.
  - Made assignment operators have the "correct" return type.
  - Introduced a more powerful and flexible mechanism for modulus changing.
  - Cleaned up numerous other minor problems.

#### Compatibility

Here is a detailed list of the changes to the programming interface.

- The names of the classes

         BB, BB_p, BB_pX

  have been changed to

         GF2X, GF2E, GF2EX

- There is also a class `GF2` to represent GF(2). Many of the functions relating to `BB, BB_p, BB_pX` had argument and return-value types of type `long` that are now of the more appropriate type `GF2`. This change was needed so that the interface would be consistent with that of the new classes

         ZZ_pE, ZZ_pEX, zz_pE, zz_pEX.

- The explicit conversion operator from `GF2X` (the new `BB`) to `GF2EX` (the new `BB_pX`) has different semantics: it now performs a coefficient lift, instead of creating a constant polynomial.
- The conversion operator "`<<`" has been retired. Now instead of

  x << a;

  one writes

  conv(x, a);

  Operator "`<<`" is now used for shift operations.

- Every conversion routine now has a corresponding functional version which has the name `to_T`, where `T` is the result type. These new names replace old names that were less consistent. So instead of

  x = Long(a);

  one writes

  x = to_long(a);

- The names of the routines

         ZZ_pInit, zz_pInit, zz_pFFTInit, GF2EInit

  have been changed to

         zz_p::init, zz_p::init, zz_p::FFTInit, GF2E::init

- The names of the routines

         and, or, xor

  for class `ZZ` have changed to

         bit_and, bit_or, bit_xor,

  because the new `C++` standard defines these as reserved words.
- The function `LowBits` for `ZZ` is now called `trunc`.
- Polynomial inversion mod `X^n` has changed from `inv` to `InvTrunc`.
- Modular trace, norm, minimum polynomial and characteristic polynomial have changed from

         trace, norm, MinPoly, IrredPoly, CharPoly

  to

         TraceMod, NormMod, MinPolyMod, IrredPolyMod, CharPolyMod

- For the class `ZZX`, the functions

         DivRem, div, rem, /, %, /=, %=

  have new semantics when dividing by non-monic polynomials. The old semantics are provided by new routines

         PseudoDivRem, PseudoDiv, PseudoRem.

- The `UpdateMap` routines have slightly different semantics: in versions < 3.0, the output always had length n; now high-order zeroes are stripped.
- The classes `ZZ_pBak`, `zz_pBak,` etc., have just slightly different semantics; I can't imagine any reasonable program detecting a difference.
- The assignment operator and copy constructor for the class `RR` have different semantics: they now produce exact copies, instead of rounding to current precision.
- All of the NTL compiler flags now start with `NTL_` to avoid name space problems.
- All of the files "zz_p.h", vec_zz_p.h", etc., have been eliminated. Use instead the names "lzz_p.h", "vec_lzz_p.h", etc.

#### Tips on making the transition

- Apply this sed script to make most of the necessary syntactic changes.
- Re-compile old NTL programs with the flag

         -DNTL_TRANSITION

  See flags.txt for details on how this will help your compiler detect remaining incompatabilities. In particular, any uses of operator `<<` in its old role as a conversion operator will cause the compiler to raise an error. You can then convert all of these to the new notation.

### Changes between NTL 1.7 and 2.0

- Implementation of classes BB (polynomials over GF(2)) and BB_pX (polynomials over GF(2^n)).
- A more consistent and natural interface, including arithmetic operators and a disciplined use of automatic conversion. So now one can write

  x = a * b + c;

  instead of

  mul(x, a, b); add(x, x, c);

  as one must in older versions of NTL. The operator notation leads to somewhat less efficient code, and one can always use the old notation in situations where efficiency is critical. Despite the new programming interface, care has been taken to ensure backward compitability; pre-existing programs that use NTL should still work.

- Windows port.
- Added compile-time flag that allows one to exploit "long long" data type if it exists (this especially helps on Pentium/Linux platforms).
- Added compile-time flag to get better quad_float code on Pentium/Linux platforms.
- A few bug fixes and performance tuning.

### Changes between NTL 1.5 and NTL 1.7

- Incorporation of Keith Briggs' quadratic precision package.
- Much faster and more robust lattice basis reduction, including Schnorr-Horner "volume heuristic" for Block Korkin Zolotarev reductions, and a new quadratic precision LLL variant that is much more robust.
- A few bug fixes.

### Changes between NTL 1.0 and NTL 1.5

- Implementation of Schnorr-Euchner algorithms for lattice basis reduction, including deep insertions and block Korkin Zolotarev reduction. These are significantly faster than the LLL algorithm in NTL 1.0.
- Implementation of arbitrary-precision floating point.
- Implementation of double precision with extended exponent range, which is useful for lattice basis reduction when the coefficients are large.
- Faster polynomial multiplication over the integers, incorporating the Schoenhagge-Strassen method.
- Compilation flags that increase performance on machines with poor floating-point performance.
- Sundry performance tuning and a few bug fixes.