/* nag_complex_bessel_j_seq (s18gkc) 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, b[20]; double a, alpha; Integer i, nl; 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_j_seq (s18gkc) Example Program Results\n"); while (fscanf(fpin, " (%lf,%lf) %lf %ld%*[^\n] ", &z.re, &z.im, &a, &nl) != EOF) { /* nag_complex_bessel_j_seq (s18gkc). * Bessel function of the 1st kind J_(alpha~+/-~n)(z) */ nag_complex_bessel_j_seq(z, a, nl, b, &fail); if (fail.code == NE_NOERROR) { fprintf(fpout, " z a nl\n"); fprintf(fpout, " (%7.3f,%7.3f) %lf %ld\n\n", z.re, z.im, a, nl); fprintf(fpout, "Requested values of J_alpha(Z)\n\n"); alpha = a; fprintf(fpout, " alpha J_alpha(z)\n"); for (i = 0; i < ABS(nl) + 1; i++) { fprintf(fpout, "%13.4e (%13.4e,%13.4e)\n", alpha, b[i].re, b[i].im); if (nl > 0) alpha += 1.0; else alpha -= 1.0; } } else { fprintf(fpout, "Error from nag_complex_bessel_j_seq (s18gkc).\n%s\n", fail.message); exit_status = 1; goto END; } } END: if (fpin != stdin) fclose(fpin); if (fpout != stdout) fclose(fpout); return exit_status; }