NAG Library Manual, Mark 28.4
```/* F11XE_A1W_F C++ Header Example Program.
*
* Copyright 2022 Numerical Algorithms Group.
* Mark 28.4, 2022.
*/
#include <dco.hpp>
#include <iostream>
#include <nag.h>
#include <nagx04.h>
#include <stdio.h>
using namespace std;

int main()
{
int               exit_status = 0;
Integer           ifail = 0;

cout << "F11XE_A1W_F C++ Header Example Program Results\n\n";
// Skip heading in data file
string mystr;
getline(cin, mystr);

// Read order of matrix and number of nonzero entries
Integer n, nnz;
cin >> n;
cin >> nnz;

nagad_a1w_w_rtype *a = 0, *x = 0, *y = 0;
double *           ar = 0, *yr = 0, *dydx = 0;
Integer *          icol = 0, *irow = 0;

icol = new Integer[nnz];
irow = new Integer[nnz];
ar   = new double[nnz];
yr   = new double[n];
dydx = new double[n * n];

for (int i = 0; i < nnz; i++)
{
cin >> ar[i] >> irow[i] >> icol[i];
a[i] = ar[i];
}

dco::ga1s<double>::global_tape = dco::ga1s<double>::tape_t::create();

for (int i = 0; i < n; i++)
{
cin >> yr[i];
x[i] = yr[i];
dco::ga1s<double>::global_tape->register_variable(x[i]);
}

// Create AD configuration data object
ifail = 0;

// Calculate matrix-vector product
ifail = 0;

// Output results
cout.setf(ios::scientific, ios::floatfield);
cout.precision(4);
cout << "  Matrix-vector product" << endl;
for (int i = 0; i < n; ++i)
{
cout.width(12);
cout << dco::value(y[i]) << endl;
}

cout << "\n Derivatives calculated: First order adjoints\n";
cout << " Computational mode    : algorithmic\n";
cout << "\n Derivatives of Y w.r.t X (A):\n";

// Setup evaluation of derivatives via adjoints
for (int i = 0; i < n; i++)
{
double inc = 1.0;
dco::derivative(y[i]) += inc;
ifail                                              = 0;
dco::ga1s<double>::global_tape->sparse_interpret() = true;

for (int j = 0; j < n; j++)
{
Integer k = i + j * n;
dydx[k]   = dco::derivative(x[j]);
}
}
// Print derivatives
cout << endl;
NagError fail;
INIT_FAIL(fail);
x04cac(Nag_ColMajor, Nag_GeneralMatrix, Nag_NonUnitDiag, n, n, dydx, n,
"       dy_i/dx_j", 0, &fail);

ifail = 0;

dco::ga1s<double>::tape_t::remove(dco::ga1s<double>::global_tape);

delete[] a;
delete[] x;
delete[] y;
delete[] icol;
delete[] irow;
delete[] ar;
delete[] yr;
delete[] dydx;

return exit_status;
}
```