/* nag_complex_airy_ai (s17dgc) Example Program. * * Copyright 2002 Numerical Algorithms Group. * * Mark 7, 2002. */ #include #include #include #include int main(void) { Complex z, ai; Integer nz; Nag_ScaleResType scal_enum; Nag_FunType deriv_enum; char deriv, scal; Integer exit_status = EXIT_SUCCESS; NagError fail; INIT_FAIL(fail); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vprintf("nag_complex_airy_ai (s17dgc) Example Program Results\n"); Vprintf(" deriv z scal ai nz\n"); while (scanf(" '%c' (%lf,%lf) '%c'%*[^\n] ", &deriv, &z.re, &z.im, &scal) != EOF) { /* Convert scal character to enum */ if (scal == 's') { scal_enum = Nag_ScaleRes; } else if (scal == 'u') { scal_enum = Nag_UnscaleRes; } else { Vprintf("Unrecognised character for Nag_ScaleResType type\n"); exit_status = -1; goto END; } /* Convert deriv character to enum */ if (deriv == 'f') { deriv_enum = Nag_Function; } else if (deriv == 'd') { deriv_enum = Nag_Deriv; } else { Vprintf("Unrecognised character for Nag_FunType type\n"); exit_status = -1; goto END; } /* nag_complex_airy_ai (s17dgc). * Airy functions Ai~(z) and ci~(z), complex z */ nag_complex_airy_ai(deriv_enum, z, scal_enum, &ai, &nz, &fail); if (fail.code == NE_NOERROR) Vprintf(" '%c' (%7.3f,%7.3f) '%c' (%7.3f,%7.3f) %ld\n", deriv, z.re, z.im, scal, ai.re, ai.im, nz); else { Vprintf("Error from nag_complex_airy_ai (s17dgc).\n%s\n", fail.message); exit_status = 1; goto END; } } END: return exit_status; }