NAG Library for C++

This page describes the NAG CPP Interface, a set of C++11 interfaces for the NAG Library. 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 prior to rolling the process out across the whole library.

In order to make use of this product you will need a copy of the NAG Library, Mark 27, installed on your system.

Quickstart using NLW6I27DEL for Windows

NLW6I27DEL is Mark 27 of the NAG Library for Windows.
Assuming that you have this installed at C:\Program Files\NAG\NL27\nlw6i27del 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\NL27\nlw6i27del\batch\envvars.bat"

REM Download the C++ wrappers
git clone https://github.com/numericalalgorithmsgroup/nagcpp

REM Navigate to examples and compile
cd nagcpp
icl.exe -I include examples\ex_c05ay.cpp /EHsc /MD /Qstd=c++11 nag_nag_MD.lib user32.lib -o ex_c05ay.exe

REM Run compiled example
ex_c05ay.exe

Quickstart using NLL6I27DBL for Linux

NLL6I27DBL is Mark 27 of the NAG Library for Linux.
Assuming that you have this installed at /opt/NAG/nll6i27dbl/ 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/nll6i27dbl/scripts/nagvars.sh int64 vendor dynamic

# Download the C++ wrappers
git clone https://github.com/numericalalgorithmsgroup/nagcpp

# Navigate to examples and compile
cd nagcpp/examples/
g++ ex_e04pt.cpp -I../include ${NAGLIB_INCLUDE} ${NAGLIB_LINK} -o ex_e04pt

#Run compiled example
./ex_e04pt

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.

Examples using the NAG C++11 interface

  • contfn_brent (GitHub, Doc) - locates a simple zero of a continuous function in a given interval using Brent’s method.
  • md_gauss (GitHub, Doc) - computes an estimate of a multidimensional integral (1 to 20), given the analytic form of the integrand and suitable Gaussian weights and abscissae.
  • dim1_spline (GitHub, Doc) - determines a cubic spline interpolant to a given set of data.
  • dim1_spline_eval (GitHub, Doc) - evaluates a cubic spline from its B-spline representation.
  • handle_solve_dfls_rcomm (GitHub, Doc) - a reverse communication Derivative-free Optimization (DFO) solver for small to medium-scale nonlinear least squares problems with bound constraints.
  • handle_solve_bounds_foas (GitHub, Doc) - solver for bound-constrained large-scale nonlinear programming (NLP) problems.
  • handle_solve_lp_ipm (GitHub, Doc) - solver for large-scale linear programming (LP) problems
  • handle_solve_socp_ipm (GitHub, Doc) - solver for large-scale second-order cone programming (SOCP) problems
  • handle_solve_ipopt (GitHub, Doc) -  solver for large scale nonlinear programming (NLP) problems.
  • nlp1_solve (GitHub, Doc) - minimize an arbitrary smooth function subject to constraints (which may include simple bounds on the variables, linear constraints and smooth nonlinear constraints) using a sequential quadratic programming (SQP) method.
  • real_nmf_rcomm (GitHub, Doc) - computes a non-negative matrix factorization for a real non-negative m by n matrix A. It uses reverse communication for evaluating matrix products, so that the matrix A is not accessed explicitly
  • quantiles (GitHub, Doc) - finds specified quantiles from a vector of unsorted data.
  • prob_students_t_noncentral (GitHub, Doc) - returns the lower tail probability for the noncentral Student’s t-distribution.
  • corrmat_nearest_rank (GitHub, Doc) - computes the nearest correlation matrix of maximum prescribed rank, in the Frobenius norm, to a given square, input matrix.
  • lars (GitHub, Doc) - performs Least Angle Regression (LARS), forward stagewise linear regression or Least Absolute Shrinkage and Selection Operator (LASSO).

Design of the C++ interface

We have written two blog posts that discuss the design principles behind the C++11 interfaces