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

#include <nag.h>
#include <nagad.h>
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
using namespace std;

int main(void)
{
  /* Scalars */
  Integer exit_status = 0;

  cout << "F08AH_P0W_F C++ Header Example Program Results\n\n";

  void    *ad_handle = 0;
  Integer ifail = 0;

  // Skip heading in data file
  string mystr;
  getline (cin, mystr);
  
  Integer m, n;
  cin >> m; cin >> n;

  Integer pda = m;
  Integer lwork = 64 * n;

  Integer tau_len;
  if (m<n) {
    tau_len = m;
  } else {
    tau_len = n;
  }

  // Allocate arrays
  double   *a = 0, *tau = 0, *work = 0;
  a    = new double [m * n];
  work = new double [lwork];
  tau  = new double[tau_len];

  // Read A from data file
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j){
      cin >> a[i+j*m];
    }
  }

  ifail = 0;
  f08ah_p0w_f_(ad_handle, m, n, a, pda, tau, work, lwork, ifail);

  NagError  fail;
  INIT_FAIL(fail);
  x04cac(Nag_ColMajor,Nag_LowerMatrix,Nag_NonUnitDiag,m,m,a,m,
         "L from Q factorization of A",0,&fail);

  delete [] a;
  delete [] tau;
  delete [] work;

  return exit_status;
}