```/* F07CA_T1W_F C++ Header Example Program.
*
* Copyright 2019 Numerical Algorithms Group.
* Mark 27, 2019.
*/

#include <dco_light.hpp>
#include <nag.h>
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main(void)
{
int       exit_status = 0;
Integer   nrhs = 1, ifail = 0;
NagError  fail;
INIT_FAIL(fail);

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

// Read number of x values and algorithmic mode
Integer n;
cin >> n;

// Allocate arrays containing A and its factorized form, B
// and the solution X.
double            *sol=0, *dxdu=0, *dxdd=0, *dxdl=0, *dxdb=0;
Integer           *ipiv = 0;
Integer           n1 = n-1;
ipiv = new Integer           [n];
sol  = new double            [n*n];
dxdu = new double            [n*n1];
dxdd = new double            [n*n];
dxdl = new double            [n*n1];
dxdb = new double            [n*n];

// Read the tridiagonal matrix A and right hand side B, register and copy
double dd;
for (int i = 0; i<n1; i++) {
cin >> dd;
du[i] = dd;
}
for (int i = 0; i<n; i++) {
cin >> dd;
d[i] = dd;
}
for (int i = 0; i<n1; i++) {
cin >> dd;
dl[i] = dd;
}
for (int i = 0; i<n; i++) {
cin >> dd;
b[i] = dd;
}

// Create AD configuration data object
ifail = 0;

double inc = 1.0, zero = 0.0;
for (int i=0; i<4*n-2; ++i) {
int k = i;
if (i<n1) {
} else if (i<n+n1) {
k = i - n1;
} else if (i<n+n1+n1) {
k = i - n - n1;
} else {
k = i - n - n1 - n1;
}
for (int j=0; j<n1; ++j) {
dlf[j] = dl[j];
df[j]  = d[j];
duf[j] = du[j];
x[j]   = b[j];
}
df[n1] = d[n1]; x[n1] = b[n1];

// Solve the equations Ax = b for x
ifail = 0;

if (i==0) {
// Print primal solution
for (int j=0; j<n*nrhs; ++j) {
}
cout << "\n\n";
x04cac(Nag_ColMajor,Nag_GeneralMatrix,Nag_NonUnitDiag,n,nrhs,sol,n,
"  Solution",0,&fail);
}
if (i<n1) {
for (int j=0; j<n; ++j) {
}
} else if (i<n+n1) {
for (int j=0; j<n; ++j) {
}
} else if (i<n+n1+n1) {
for (int j=0; j<n; ++j) {
}
} else {
for (int j=0; j<n; ++j) {
}
}
}

cout << "\n\n Derivatives calculated: First order tangents\n";
cout << " Computational mode    : symbolic\n";

cout << "\n";
x04cac(Nag_ColMajor,Nag_GeneralMatrix,Nag_NonUnitDiag,n,n1,dxdu,n,
"  d(du(i))/dx(j)",0,&fail);
cout << "\n";
x04cac(Nag_ColMajor,Nag_GeneralMatrix,Nag_NonUnitDiag,n,n,dxdd,n,
"  d(d(i))/dx(j)",0,&fail);
cout << "\n";
x04cac(Nag_ColMajor,Nag_GeneralMatrix,Nag_NonUnitDiag,n,n1,dxdl,n,
"  d(dl(i))/dx(j)",0,&fail);
cout << "\n";
x04cac(Nag_ColMajor,Nag_GeneralMatrix,Nag_NonUnitDiag,n,n,dxdb,n,
"  d(b(i))/dx(j)",0,&fail);

// Remove computational data object
ifail = 0;

delete [] dl;
delete [] d;
delete [] du;
delete [] dlf;
delete [] df;
delete [] duf;
delete [] b;
delete [] ipiv;
delete [] x;
delete [] sol;
delete [] dxdu;
delete [] dxdd;
delete [] dxdl;
delete [] dxdb;
return exit_status;
}
```