/* F08AE_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;
#ifdef NAG_LOAD_FP
/* The following line is needed to force the Microsoft linker
to load floating point support */
float force_loading_of_ms_float_support = 0;
#endif /* NAG_LOAD_FP */
cout << "F08AE_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];
tau = new double [tau_len];
work = new double [lwork];
// Read A from data file
double tmp;
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j){
cin >> tmp;
a[i+j*m] = tmp;
}
}
ifail = 0;
f08ae_p0w_f_(ad_handle, m, n, a, pda, tau, work, lwork, ifail);
NagError fail;
INIT_FAIL(fail);
x04cac(Nag_ColMajor,Nag_UpperMatrix,Nag_NonUnitDiag,n,n,a,pda,
"R from Q factorization of A",0,&fail);
delete [] a;
delete [] work;
delete [] tau;
return exit_status;
}