Downloads - The NAG CPP Interface

 

The NAG CPP Interface is a set of C++ 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 30, installed on your system.

Quickstart using NLW6I30DEL for Windows

NLW6I30DEL is Mark 30 of the NAG Library for Windows.
Assuming that you have this installed at C:\Program Files\NAG\NL30\nlw6i30del 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\nlw6i30del\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 /EHs /MD /Qstd=c++17 nag_nag_MD.lib user32.lib -o ex_c05ay.exe

REM Run compiled example
ex_c05ay.exe

Quickstart using NLL6I30DBL for Linux

NLL6I30DBL is Mark 30 of the NAG Library for Linux.
Assuming that you have this installed at /opt/NAG/nll6i30dbl/ and are using the Bash shell and gcc, v.10.3 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/nll6i30dbl/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++ interface

The following examples are also available on the GitHub at https://github.com/numericalalgorithmsgroup/nagcpp/tree/master/examples.

  • contfn_brent - locates a simple zero of a continuous function in a given interval using Brent's method.
  • md_gauss - 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 - determines a cubic spline interpolant to a given set of data.
  • dim1_spline_eval - evaluates a cubic spline from its B-spline representation.
  • handle_solve_dfls_rcomm - a reverse communication Derivative-free Optimization (DFO) solver for small to medium-scale nonlinear least squares problems with bound constraints.
  • handle_solve_bounds_foas - solver for bound-constrained large-scale nonlinear programming (NLP) problems.
  • handle_solve_lp_ipm - solver for large-scale linear programming (LP) problems
  • handle_solve_socp_ipm - solver for large-scale second-order cone programming (SOCP) problems
  • handle_solve_ipopt - solver for large scale nonlinear programming (NLP) problems.
  • nlp1_solve - 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 - 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 - finds specified quantiles from a vector of unsorted data.
  • prob_students_t_noncentral - returns the lower tail probability for the noncentral Student's t-distribution.
  • corrmat_nearest_rank - computes the nearest correlation matrix of maximum prescribed rank, in the Frobenius norm, to a given square, input matrix.
  • lars - 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++ interfaces