/* nag_real_apply_q(f01qdc) Example Program * * Copyright 1990 Numerical Algorithms Group. * * Mark 1, 1990. */ #include #include #include #include #define MMAX 20 #define NMAX 10 #define NCBMAX 5 int main(void) { Integer tda = NMAX; Integer tdb = NCBMAX; double zeta[NMAX], a[MMAX][NMAX], b[MMAX][NCBMAX]; Integer i, j, m, n, ncolb; Vprintf("f01qdc 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]"); for (i = 0; i < m; ++i) for (j = 0; j < n; ++j) Vscanf("%lf", &a[i][j]); Vscanf(" %*[^\n]"); Vscanf("%ld", &ncolb); if (ncolb > NCBMAX) { Vprintf("ncolb is out of range.\n"); Vprintf("ncolb = %2ld\n", ncolb); } else { Vscanf(" %*[^\n]"); for (i = 0; i < m; ++i) for (j = 0; j < ncolb; ++j) Vscanf("%lf", &b[i][j]); /* Find the QR factorization of A */ f01qcc(m, n, &a[0][0], tda, zeta, NAGERR_DEFAULT); /* Form Q'*B */ f01qdc(Transpose, Nag_ElementsSeparate, m, n, &a[0][0], tda, zeta, ncolb, &b[0][0], tdb, NAGERR_DEFAULT); Vprintf("Matrix Q'*B\n"); for (i = 0; i < m; ++i) { for (j = 0; j < ncolb; ++j) Vprintf(" %8.4f", b[i][j]); Vprintf("\n"); } } } return EXIT_SUCCESS; }