NAG Library algorithms are inherently flexible – they can be called from many languages, including C and C++, VBA, Python, Java, .NET and Fortran.
Follow the steps below to get started with the NAG Library including downloads for your chosen configuration, how to obtain a licence, product-specific documentation, and accessing technical support.
If you have any questions, contact us via the Technical Support Service.
To find and download your version of the NAG Library, select your programming language or environment, and operating system below.
The NAG Library provides ISO C standard API so can be used from C and C++. If you are using C++ you might be interested in the NAG CPP Interface which is a subset of C++ interfaces for the NAG Library. If you aim to interface the Library from any other language we highly recommend using the Fortran Interface which also provides ISO C standard API but its simpler interface is often easier to work with.
The NAG Library provides a standard set of interfaces that utilise only simple types, making them suitable for calling from a wide range of languages, including Fortran, C, C++, VBA, .NET and others. These interfaces include NAG's traditional Fortran Library interfaces.
The NAG CPP Interface is a set of C++ interfaces for the NAG Library supplied as a series of header files. Currently, only interfaces for a small subset of routines from the NAG Library are available in this form. These interfaces are automatically generated, and their primary purpose is to elicit feedback on their design before rolling the process out across the whole Library.
The licence-managed package is served from a NAG-hosted repository. Hence by using pip to install the software as documented below, the latest version of the appropriate package for the system you are running pip on is downloaded and installed in one combined operation.
Add further mathematical and statistical functionality to your applications with the NAG Toolbox for MATLAB.
The world's largest collection of robust, documented, tested and maintained numerical algorithms for users of the Java programming language.
The following system setup is expected
System: Windows 64-bit
Compilers: Intel C++ 64-bit v.2021.4.0 or compatible
or Microsoft 64-bit C/C++ v.19.10 or compatible
Using Visual Studio 2019 or compatible
System: Windows 64-bit
Compilers: Intel Fortran v.2021.4.0 or compatible
Using Visual Studio 2019 or compatible
For details of other system setups for the Win64 version, see Supplementary Information.
or
System: Windows 32-bit
Compilers: Intel C 32-bit v.2021.4.0 or compatible
or Microsoft 32-bit C/C++ v.19.27 or compatible
Using Visual Studio 2019 or compatible
or
System: Windows 32-bit
Compilers: Intel Fortran v.2021.4.0 or compatible
Using Visual Studio 2019 or compatible
For details of other system setups for the Win32 version, see Supplementary Information.
System: Windows 64-bit
MATLAB: version 8.5 (R2015a) or later
System: Windows 64-bit
Java: version 7 or later
The following system setup is expected
System: glibc 2.17 or compatible (implemented on Fedora 24)
Compilers: Intel C++ v.2021.4.0 or compatible
or GNU C (gcc) v.7.3 or compatible
ABI: C++11
System: glibc 2.17 or compatible (implemented on Fedora 24)
Compilers: Intel Fortran v.2021.4.0 or compatible
For details of other system setups for Linux C++11 ABI version, see Supplementary Information.
or
System: glibc 2.17 or compatible (implemented on Centos 7)
Compilers: Intel C++ v.2021.4.0 or compatible
or GNU C (gcc) v.7.3 or compatible
ABI: C++98
or
System: glibc 2.17 or compatible (implemented on Centos 7)
Compilers: Intel Fortran v.2021.4.0 or compatible
For details of other system setups for Linux C++98 ABI version, see Supplementary Information.
System: Linux 64-bit
MATLAB: version 8.5.1 (R2015a SP1) or later
System: glibc 2.17 or compatible (implemented on Fedora 24)
Java: version 7 or later
The following system setup is expected
System: macOS 10.13 or compatible
Compilers: Intel C++ 64-bit v.19.0.3 or compatible
or Apple LLVM (clang) v9.0 (GCC equivalent) or compatible
System: macOS 10.13 or compatible
Compilers: Intel Fortran v.19.0.3 or compatible
For details of other system setups for the Intel compiler version, see Supplementary Information.
or
System: macOS 10.14 or compatible
Compilers: GNU gcc v.8.3 or compatible
or
System: macOS 10.14 or compatible
Compilers: GNU gfortran v.8.3 or compatible
For details of other system setups for the GNU compiler version, see Supplementary Information.
System: Apple Intel Mac 64-bit
MATLAB: version 8.5 (R2015a) or later
Dependencies
A valid licence for this product
64-bit Python, 3.7 or later
NumPy 1.15 or newer (NumPy 2.0 compatibility was introduced with Mark 30.1.0.1)
The full range of NAG Library implementations can be viewed here.
Download the Software
Install the Software
After download, run the self-extracting executable (e.g. nlw6i302el_setup.exe) (nlw6i302el_setup.exe) to start the NAG Library installation.
A typical installation will be straightforward (follow the prompts on the Windows setup Wizard and press Next) or see the Installer's Note Installer's Note which explains all aspects of setting up the product.
The NAG Library materials are downloaded from our website as a tar gzip file (nll6i302bl.tgz) (nll6i302bl.tgz); cd to the directory where the file is located and extract the installation materials using the following command:
tar xvzf nll6i302bl.tgz
tar xvzf nll6i302bl.tgz
This will extract the files install.sh, nl30.tgz, nag_tsandcs.txt, in.html and un.html and the directory styles. Then run
./install.sh
By default, the materials will be installed under $HOME/NAG/, or if the directory $HOME does not exist, under /opt/NAG/. However, you may choose a different location.
The NAG Library materials are downloaded from our website as a Disk Image file (nlmi627dbl.dmg); double click on the file to mount the disk image.
Double click on INSTALL.command in Finder and follow the instructions. By default, the materials will be installed under $HOME/NAG/, or if the directory $HOME does not exist, under /opt/NAG/. However, you may choose a different location.
MATLAB must be installed first.
After download, run the self-extracting executable (e.g. mbw6i25ddl_setup.exe) to start the NAG Toolbox installation.
A typical installation will be straightforward (follow the prompts on the Windows setup Wizard and press Next) or see the Installer's Note which explains all aspects of setting up the product.
The NAG Toolbox for MATLAB materials are downloaded from our website as a tar gzip file (mbl6i25dnl.tgz); cd to the directory where the file is located and extract the installation materials and run the installer using the following commands:
mkdir nagtmp cd nagtmp tar -xzf ../mbl6i25dnl.tgz sh INSTALL
By default, the materials will be installed under /opt/NAG/ or, if the directory /opt does not exist, under /usr/local/NAG. However, you may choose a different location.
A typical installation will be straightforward (follow the prompts from the installer) or see the Installer's Note which explains all aspects of setting up the product.
The NAG Library materials are downloaded from our website as a Disk Image file (mbmi625dcl.dmg); double click on the file to mount the disk image.
Double click on INSTALL.command in Finder and follow the instructions. By default, the materials will be installed under $HOME/NAG/, or if the directory $HOME does not exist, under /opt/NAG/. However, you may choose a different location.
Download and Install the Software
If you would like to use the NAG Library within Visual Studio Code, we recommend using the NAG Library for Python extension to install and test the NAG Library. Otherwise, installation instructions using the command line interface are also available below.
Downloading and installing the NAG Library is done using the pip package manager.
Using NAG's VS Code extension
From VS Code, open the Extensions panel and search for NAG Library for Python within the Extensions Marketplace.
Install the NAG Library for Python extension.
Open a folder within VS Code (File > Open Folder...). Using the Command Palette Ctrl/Cmd + Shift + P, execute the NAG: Quick Install command. This creates a Python virtual environment and installs the NAG Library for Python within the opened folder using pip.
After the installation has completed, follow the prompts to request a trial licence or add your existing licence.
See NAG Library for Python extension for further instructions on using the Library within VS Code and learn more about the other extension features.
Using the Command Line Interface
Open a Command Prompt window and create a Python virtual environment in which to install and test the NAG Library
python -m venv nag3 .\nag3\Scripts\activate
Open a terminal with Bash and create a Python 3 virtual environment in which to install and test the NAG Library
python3 -m venv nag3 . nag3/bin/activate
Now use pip to install the NAG Library for Python
python -m pip install --extra-index-url https://support.nag.com/downloads/py/naginterfaces_nag naginterfaces
or if you prefer the version of the package that relies on Intel MKL for optimized linear algebra routines, then use
python -m pip install --extra-index-url https://support.nag.com/downloads/py/naginterfaces_mkl naginterfaces
or if you prefer a multi-threaded version of the package that utilizes multiple cores and relies on Intel MKL for optimized linear algebra routines, then use
python -m pip install --extra-index-url https://support.nag.com/downloads/py/naginterfaces_mkl_smp naginterfaces
Obtain a Licence
The use of this product is controlled by the Kusari licence management system. A licence key may be requested and installed via the Kusari Licence Installer, accessible at the end of the software installation procedure. Click 'Request New Licence'. Complete the form and select 'Generate Licence Request'. Paste the generated information into your email client and send it to the NAG address given at the top of the generated information.
The use of this product is controlled by the Kusari licence management system. To request a licence key, run the program khostid located in the license/bin/linux_x64 subdirectory of the software distribution. This utility must be run from a command prompt. Return the information that it displays, together with the product code, by email to NAG. Alternatively, direct the output from this utility to a file and send both the file and the product code to NAG.
The use of this product is controlled by the Kusari licence management system. To request a licence key, run the program khostid located in the license/bin/macx64 subdirectory of the software distribution. This utility must be run from a command prompt. Return the information that it displays, together with the product code, by email to NAG. Alternatively, direct the output from this utility to a file and send both the file and the product code to NAG.
The use of this product is controlled by the Kusari licence management system. A licence key may be requested and installed via the Kusari Licence Installer, accessible at the end of the software installation procedure. Click 'Request New Licence'. Complete the form and select 'Generate Licence Request'. Paste the generated information into your email client and send it to the NAG address given at the top of the generated information.
The use of this product is controlled by the Kusari licence management system. The recommended way to request a license key is to use the GUI program provided. This will help you to build a standard message requesting a key which can be pasted into an email to the NAG Technical Support Service.
The use of this product is controlled by the Kusari licence management system. To request a licence key, run the program khostid located in the license/bin/linux_x64 subdirectory of the software distribution. This utility must be run from a command prompt. Return the information that it displays, together with the product code, by email to NAG. Alternatively, direct the output from this utility to a file and send both the file and the product code to NAG.
The use of this product is controlled by the Kusari licence management system. To request a licence key, run the program khostid located in the license/bin/macx64 subdirectory of the software distribution. This utility must be run from a command prompt. Return the information that it displays, together with the product code, by email to NAG. Alternatively, direct the output from this utility to a file and send both the file and the product code to NAG.
Install the Licence
You will receive your requested licence key by email containing one or more lines like the following:
<PRODUCT_CODE> NODE <EXPIRY_DATE> "EMnxidA3oeoj0F1Yvi5ibxPjB7"
Once you have obtained the above licence key, the Kusari Licence Installer can be used to install the key in the Windows Registry. Open the installer via the Start Menu or All apps shortcut NAG NLW6I302EL Licence, Request or Install. Paste the key into the edit box on the main dialogue and click 'Install Licence Key'.
Once you have obtained the above licence key, the key_gui can be used to install the key in the Windows Registry.
python -m naginterfaces.kusari
Paste the key into the edit box on the main dialogue and then click on the Install Licence Key button to install it.
Once you have obtained the above licence key, the easiest way to install it is to store the text in a file,
$HOME/nag.key
or
/opt/NAG/nag.key
It is possible to store the licence file in a different location, see the Installer's Note Installer's Note Installer's Note for details.
It is possible to store the licence file in a different location, see the Installer's Note Installer's Note for details.
As a basic verification that the package is ready to use, the 'quick check' function, callable via
python -c "from naginterfaces import quick_check; quick_check()"
will confirm availability of a licence and go on to perform a small check that the underlying compiled libraries load correctly.
Install the NAG CPP Interfaces
The NAG CPP Interfaces file will be emailed to you together with your licence.
Unzip the NAG CPP Interfaces file (nagcpp_latest.zip) into the directory of your choice, referred to here as '[NAGCPP_INSTALL_DIR]'.
Install the Java Interfaces
A link to the Java Interfaces file will be emailed to you together with your licence. If you already hold a licence for the NAG Library and have not requested a licence, you can download the Java Interfaces from here.
Unzip the Java Interfaces file (nagjava_302.zip) into the directory of your choice, referred to here as '[my_nagjava_dir]'.
Solve your First Problem
The example programs are most easily accessed using the batch files nag_example_DLL.bat, nag_example_static_MT.bat and nag_example_static_MD.bat, which can be found in the C:\Program Files\NAG\NL30\nlw6i302el\batch\ folder.
These batch files require that the environment variables for your C/C++ Fortran compiler and the NAG Library are set. In particular, the environment variable NAG_NLW6I302EL needs to be set to the location of the NAG Library.
The shortcut:
NAG NLW6I302EL Command Prompt
should be used to start a Command Prompt window with the correct settings for the INCLUDE, LIB and PATH environment variables for the NAG Library and the supplied MKL. The environment variable NAG_NLW6I302EL, which is needed by the nag_example_*.bat batch files, is also set.
If the shortcut is not used, set the environment variables by running the batch file envvars.bat for this implementation. The default location for this file is:
C:\Program Files\NAG\NL30\nlw6i302el\batch\envvars.bat
If this file is not in the default location, you can locate it by searching for the file envvars.bat containing 'nlw6i302el'.
An example program is specified by an argument to the command, e.g.
nag_example_DLL a00adc
nag_example_DLL a00adf
This will copy the example program and any data and/or options files (a00adce.c (a00adfe.f90 in this case) into the current folder, compile and link the program and run it to produce the example program results in the file a00adce.ra00adfe.r.
The example programs are most easily accessed by using the script nag_example, which is located in the directory [INSTALL_DIR]/scripts.
By default, nag_example selects to use 32-bit integers and static linking to the self-contained libnag_nag.a Library.
The nag_example script demonstrates use of the nagvars script, which can be used to set NAG-specific environment variables to assist with compiling and linking applications that call any of the NAG routines. They also amend the standard environment variables PATH and LD_LIBRARY_PATH DYLD_LIBRARY_PATH so that NAG executable programs and libraries can be found at compile, link and run time.
See the Users' Note for the macOS version for use with either the Linux C++11 ABI version Intel C++ compiler or the Linux C++98 ABI version GNU gcc compiler for a full description of these scripts.
An example program is specified by an argument to the command, e.g.
nag_example a00adc
nag_example a00adf
This will copy the example program and any data and/or options files (a00adce.c (a00adfe.f90 in this case) into the current directory, compile and link the program and run it to produce the example program results in the file a00adce.ra00adfe.r.
Assuming that you have the NAG Library installed at C:\Program Files\NAG\NL30\nlw6i302el and are using the Intel C++ Compiler, v.19 or above, here’s how to obtain the C++ wrappers and compile one of the examples
REM Set up the environment for the NAG Library "C:\Program Files\NAG\NL30\nlw6i302el\batch\envvars.bat" REM Navigate to examples and compile cd [NAGCPP_INSTALL_DIR] icl.exe -I include examples\ex_a00ad.cpp /EHs /MD /Qstd=c++17 nag_nag_MD.lib user32.lib -o ex_a00ad.exe REM Run compiled example ex_a00ad.exe
Assuming that you have NAG Library installed at /opt/NAG/nll6i302bl/ and are using the Bash shell and gcc, v.6.3.1 or above, here’s how to obtain the C++ wrappers and compile one of the examples
# Set up the environment for the NAG Library # 64 bit Integers using vendor provided (MKL) BLAS, dynamic linking source /opt/NAG/nll6i302bl/scripts/nagvars.sh int64 vendor dynamic # Navigate to examples and compile cd [NAGCPP_INSTALL_DIR]/examples/ g++ ex_a00ad.cpp -I../include ${NAGLIB_INCLUDE} ${NAGLIB_LINK} -o ex_a00ad #Run compiled example ./ex_a00ad
In the above, -I../include is the relative path to the NAG C++ include directory from the examples directory. You will need to include the full path to this directory if you compile from anywhere else. ${NAGLIB_INCLUDE} and ${NAGLIB_LINK} are include and link flags set by the nagvars.sh script for the main Library.
If the installation was performed using the VS Code extension, the following also applies to VS Code's integrated terminal (see Using VS Code's Integrated Terminal). Each example file for the package can be run as a Python module, invocable via for instance
python -m naginterfaces.library.examples.info.impl_details_ex
Running
python -m pydoc naginterfaces.library.examples.info.impl_details_ex
will confirm the installation location of the associated file. All examples can be run as standard Python ‘main’ scripts from the Command Prompt, by executing for instance
python path/to/naginterfaces/library/examples/info/impl_details_ex.py
A quick test that the software has been correctly installed is to type a00aa at the MATLAB prompt, which should print some implementation details. If this does not work correctly and you see messages such as "The referenced assembly is not installed on your system." then it may be necessary to reboot your computer so that MATLAB picks up the correct support libraries.
To test that a valid license is available, type a00ac at the MATLAB prompt. This will return 1 if a valid license is found, or 0 otherwise.
You should access the NAG Toolbox documentation as follows. On starting the MATLAB documentation browser you should see a heading labelled Supplemental Software. This should have a NAG Toolbox link; clicking on that will give access to the NAG Toolbox demos and documentation (which includes runnable examples for each routine). From here, you can open the example text in the MATLAB editor and then run it via the MATLAB Run button.
For example, select the "D01 - quadrature" link from the Contents list, then select "d01ah" from the main panel. This will open the documentation for the d01ah routine. From within this document, click on Example from the Contents list, then click on the d01ah_example link next to "Open in the MATLAB editor". Then, from the Editor tab in the main MATLAB window, click on the Run button to run the example and display the results in the MATLAB Command Window.
Make sure that the folder containing the file nag_jni300.dll is on your PATH, as well as the bin and rtl\bin folders of the underlying Library NLW6I302EL. For example, your PATH environment variable should include
C:\path\to\my_nagjava_dir\NAGJava\win64;C:\Program Files\NAG\NL30\nlw6i302el\bin;C:\Program Files\NAG\NL30\nlw6i302el\rtl\bin
where C:\path\to\my_nagjava_dir is the folder in which you unzipped the Java materials and the NAG Library is assumed to have been installed in the default location.
We also recommend that you add NAGJava.jar to your CLASSPATH, e.g. your CLASSPATH environment variable would contain
.;C:\path\to\my_nagjava_dir\NAGJava\jar\NAGJava.jar
From a Command Prompt window go to the NAGJava\diagnostic folder and run the commands
javac NAGJavaDiagnostic.java java NAGJavaDiagnostic
Make sure that the directory containing the file nag_jni300.so is on your PATH, as well as the lp64/lib and rtl/lib/intel64 directories of the underlying Library NLL6I302BL. For example, your PATH environment variable should include
/path/to/my_nagjava_dir/NAGJava/linux_x64:$HOME/NAG/nll6i302b/lp64/lib:$HOME/NAG/nll6i302b/rtl/lib/intel64
where /path/to/my_nagjava_dir is the directory in which you unzipped the Java materials and the NAG Library is assumed to have been installed in the default location.
We also recommend that you add NAGJava.jar to your CLASSPATH, e.g. your CLASSPATH environment variable would contain
.:/path/to/my_nagjava_dir/NAGJava/jar/NAGJava.jar
From a Command Prompt window go to the NAGJava/diagnostic directory and run the commands
javac NAGJavaDiagnostic.java java NAGJavaDiagnostic
Further Reading
The following documentation is recommended to guide your next steps:
The Users' Note for either the Win64 version or the Win32 version - details how to access different variants of the NAG Library with different compilers.
The Users' Note for the Win64 version - details how to access different variants of the NAG Library with different compilers.
The Users' Note for either the Linux C++11 ABI version or the Linux C++98 ABI version - details how to access different variants of the NAG Library with different compilers.
The Users' Note for the Linux C++11 ABI version - details how to access different variants of the NAG Library with different compilers.
The Users' Note for the macOS version for use with either the Intel C++ compiler or the GNU gcc compiler - details how to access different variants of the NAG Library with different compilers.
The Users' Note - further details of how to call the NAG Library for Java.
The Users' Note - further details of how to call the NAG Library for Java.
The NAG Library Manual - the principal documentation for the NAG Library with all the information to support this interface.
NAG CL Interface Introduction.
Following a successful deployment of the naginterfaces materials, it is recommended that you review the full documentation for the Python package before use.
To access the documentation from a Command Prompt execute
python -m pydoc naginterfaces
The NAG Toolbox Manual - the principal documentation for the NAG Toolbox for MATLAB.
This is also available from within MATLAB under Documentation [Supplemental Software] NAG Toolbox.
The NAG Library Manual - the principal documentation for the NAG Library.
Technical Support Service
If you experience any difficulty, we are ready to help you. Contact us via the Technical Support Service.