#

A Tour of NTL: Summary of Changes

### 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.

- Changed 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. [more details]

- 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. Go here for more details.

### 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.
- Changes 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.