/* nag_complex_bessel_i (s18dec) Example Program. * * Copyright 2002 Numerical Algorithms Group. * * Mark 7, 2002. */ #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fpin, *fpout; Integer exit_status = 0; Complex z, cy[2]; double fnu; const Integer n = 2; Integer nz; char nag_enum_arg[40]; Nag_ScaleResType scal; NagError fail; INIT_FAIL(fail); /* Check for command-line IO options */ fpin = nag_example_file_io(argc, argv, "-data", NULL); fpout = nag_example_file_io(argc, argv, "-results", NULL); /* Skip heading in data file */ fscanf(fpin, "%*[^\n]"); fprintf(fpout, "nag_complex_bessel_i (s18dec) Example Program Results\n"); fprintf(fpout, "Calling with n = %ld\n", n); fprintf(fpout, " fnu z scal cy[0]" " cy[1] nz\n"); while (fscanf(fpin, " %lf (%lf,%lf) %s%*[^\n] ", &fnu, &z.re, &z.im, nag_enum_arg) != EOF) { /* nag_enum_name_to_value(x04nac). * Converts NAG enum member name to value */ scal = (Nag_ScaleResType) nag_enum_name_to_value(nag_enum_arg); /* nag_complex_bessel_i (s18dec). * Modified Bessel functions I_(nu~+~a)(z), real a~>=~0, * complex z, nu~=~0~,~1~,~2~,~... */ nag_complex_bessel_i(fnu, z, n, scal, cy, &nz, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_complex_bessel_i (s18dec).\n%s\n", fail.message); exit_status = 1; goto END; } fprintf(fpout, "%7.4f (%7.3f,%7.3f) %-14s (%7.3f,%7.3f) (%7.3f,%7.3f) " "%ld\n", fnu, z.re, z.im, nag_enum_arg, cy[0].re, cy[0].im, cy[1].re, cy[1].im, nz); } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }