/* nag_real_qr(f01qcc) Example Program * * Copyright 1990 Numerical Algorithms Group. * * Mark 1, 1990. */ #include #include #include #include #define MMAX 20 #define NMAX 10 int main(void) { Integer tda = NMAX; double zeta[NMAX], a[MMAX][NMAX]; Integer i, j, m, n; Vprintf("f01qcc Example Program Results\n"); Vscanf(" %*[^\n]"); /* skip headings in data file */ Vscanf(" %*[^\n]"); Vscanf("%ld%ld", &m, &n); if (m > MMAX || n > NMAX) { Vprintf("m or n is out of range.\n"); Vprintf("m = %2ld, n = %2ld\n", m, n); } else { Vscanf(" %*[^\n]"); /* skip next heading */ for (i = 0; i < m; ++i) /* Read matrix A */ for (j = 0; j < n; ++j) Vscanf("%lf", &a[i][j]); /* Find the QR factorization of A */ f01qcc(m, n, &a[0][0], tda, zeta, NAGERR_DEFAULT); Vprintf("QR factorization of A\n\n"); Vprintf("Vector zeta\n"); for (i = 0; i < n; ++i) Vprintf(" %8.4f", zeta[i]); Vprintf("\n\n"); Vprintf("Matrix A after factorization (upper triangular part is R)\n"); for (i = 0; i < m; ++i) { for (j = 0; j < n; ++j) Vprintf(" %8.4f", a[i][j]); Vprintf("\n"); } } return EXIT_SUCCESS; }