/* nag_complex_lin_eqn_mult_rhs (f04adc) Example Program. * * Copyright 1990 Numerical Algorithms Group. * * Mark 1A revised, (Oct 1990). * Mark 8 revised, 2004. */ #include #include #include #include #define A(I,J) a[(I)*tda + J] #define B(I,J) b[(I)*tdb + J] #define X(I,J) x[(I)*tdx + J] int main(void) { Complex *a=0, *b=0, *x=0; Integer exit_status=0, i, j, n, nrhs=1, tda, tdb, tdx; NagError fail; INIT_FAIL(fail); Vprintf("nag_complex_lin_eqn_mult_rhs (f04adc) Example Program Results\n"); Vscanf("%*[^\n]"); /* Skip heading in data file */ Vscanf("%ld", &n); if (n >=1) { if ( !( a = NAG_ALLOC(n*n, Complex)) || !( b = NAG_ALLOC(n*1, Complex)) || !( x = NAG_ALLOC(n*1, Complex)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } tda = n; tdb = 1; tdx = 1; } else { Vprintf("Invalid n.\n"); exit_status = 1; return exit_status; } for (i = 0; i < n; i++) for (j = 0; j < n; j++) Vscanf(" ( %lf, %lf ) ", &A(i,j).re, &A(i,j).im); for (i = 0; i < n; i++) for (j = 0; j < tdx; j++) Vscanf(" ( %lf, %lf ) ", &B(i,j).re, &B(i,j).im); /* nag_complex_lin_eqn_mult_rhs (f04adc). * Approximate solution of complex simultaneous linear * equations with multiple right-hand sides */ nag_complex_lin_eqn_mult_rhs(n, nrhs, a, tda, b, tdb, x, tdx, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from nag_complex_lin_eqn_mult_rhs (f04adc).\n%s\n", fail.message); exit_status = 1; goto END; } else { Vprintf("Solution\n"); for (i=0; i