/* nag_complex_apply_q (f01rdc) Example Program. * * Copyright 1990 Numerical Algorithms Group. * * Mark 1, 1990. * Mark 8 revised, 2004. */ #include #include #include #include #define COMPLEX(A) A.re, A.im #define A(I,J) a[(I)*tda + J] #define B(I,J) b[(I)*tdb + J] int main(void) { Complex *a=0, *b=0, *theta=0; Integer exit_status=0, i, j, m, n, ncolb, tda, tdb; NagError fail; INIT_FAIL(fail); Vprintf("nag_complex_apply_q (f01rdc) Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vscanf("%ld%ld", &m, &n); if (n>=0 && m>=n) { if ( !( a = NAG_ALLOC(m*n, Complex)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } tda = n; } else { Vprintf("Invalid n or m.\n"); exit_status = 1; return exit_status; } for (i=0; i=0) { if ( !( b = NAG_ALLOC(m*ncolb, Complex)) || !( theta = NAG_ALLOC(n, Complex)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } tdb = ncolb; } else { Vprintf("Invalid ncolb.\n"); exit_status = 1; return exit_status; } for (i=0; i=~n) */ nag_complex_qr(m, n, a, tda, theta, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from nag_complex_qr (f01rcc).\n%s\n", fail.message); exit_status = 1; goto END; } /* Form conjg( Q' )*B. */ /* nag_complex_apply_q (f01rdc). * Compute QB or Q^HB after factorization by nag_complex_qr * (f01rcc) */ nag_complex_apply_q(ConjugateTranspose, Nag_ElementsSeparate, m, n, a, tda, theta, ncolb, b, tdb, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from nag_complex_apply_q (f01rdc).\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("\nMatrix conjg( Q' )*B\n"); for (i=0; i