NTL (Number Theory Library)

repository·main·Indexed 43 days ago

https://github.com/libntl/ntl

A C++ library for high-performance number theory computations that relies on the GMP library for multi-precision arithmetic.

Tokens
731
Snippets
3
Records
5
Agent score
6%

What's inside NTL

  1. Install NTL on UNIX systems

    main

    To install NTL on a UNIX-like system, navigate to the src directory and use the following build pattern. Note that the ./configure script uses a variable=value syntax rather than standard autotools flags.

    Build Steps

    1. Configure the build with desired options.
    2. Compile the source.
    3. Install the headers and libraries.

    Common Configuration Options

    • GMP_PREFIX=/path/to/gmp/installation: Specifies the location of the GMP (GNU Multi-Precision) library. The script expects gmp.h in $(GMP_PREFIX)/include and libgmp.{a,so} in $(GMP_PREFIX)/lib. For optimal performance, it is recommended to build GMP from source rather than using a generic system installation.
    • PREFIX=/path/to/ntl/installation: The destination directory for NTL. make install will place headers in $(PREFIX)/include/NTL, libraries in $(PREFIX)/lib, documentation in $(PREFIX)/doc/NTL, and the pkg-config file in $(PREFIX)/lib/pkgconfig.
    • DEF_PREFIX=/default/installation/path: A shortcut that sets both GMP_PREFIX and PREFIX to the same value.
    • SHARED=on: Enables building NTL as a shared (dynamic) library in addition to a static library (defaults to off).
    cd src
    ./configure GMP_PREFIX=/path/to/gmp PREFIX=/path/to/ntl SHARED=on
    make
    make install
  2. Compile a C++ program using NTL

    main

    After installing NTL, the easiest way to compile your own code is to use the provided template makefile. This ensures all compiler flags, dependencies, and paths are correctly configured for your specific NTL build.

    1. Copy the template makefile from the NTL installation directory to your project directory: cp $(PREFIX)/include/NTL/USER_MAKEFILE.txt makefile
    2. Ensure your source file (e.g., foo.cpp) is in the same directory.
    3. Run make followed by your filename to compile: make foo

    This template is also a useful reference for understanding which compiler flags and options are required for your system.

    cp /path/to/ntl/include/NTL/USER_MAKEFILE.txt makefile
    make foo
  3. Verify NTL installation

    main

    Before finalizing your installation, you can verify that the build is correct and functional by running the test suite from the src directory.

    make check

    This process may take several minutes.

    make check
  4. Integrate NTL into build systems

    main

    NTL provides a pkg-config file to facilitate integration with modern build systems like CMake or Meson.

    After installation, the file is located at: $(PREFIX)/lib/pkgconfig/ntl.pc

  5. Access NTL documentation and configuration logs

    main

    Once NTL is installed, you can access the following resources in your installation prefix ($(PREFIX)):

    • Main Documentation: Open $(PREFIX)/doc/tour.html in a web browser for the comprehensive guide.
    • Configuration Summary: Check $(PREFIX)/include/NTL/CONFIG_LOG.txt to see the exact configuration options used during the build process.