/* nag_legendre_p (s22aac) Example Program. * * Copyright 2000 Numerical Algorithms Group. * * NAG C Library * * Mark 6, 2000. */ #include #include #include int main(void) { const char fmt_99998[] = "%2ld %12.4e\n"; const char fmt_99999[] = "%3ld %5.1f%6ld%6ld\n\n"; char str[80]; double p[101]; double x; Integer exit_status=0; NagError fail; Integer m, mode, n, nl; INIT_FAIL(fail); Vprintf("s22aac Example Program Results\n\n"); /* Skip heading in data file */ Vscanf("%*[^\n] "); Vscanf("%ld %lf %ld %ld", &mode, &x, &m, &nl); if (mode == 1) { if (m == 0) { Vstrcpy(str, "Unnormalized Legendre function values\n"); } else { Vstrcpy(str, "Unnormalized associated Legendre function values\n"); } } else if (mode == 2) { if (m == 0) { Vstrcpy(str, "Normalized Legendre function values\n"); } else { Vstrcpy(str, "Normalized associated Legendre function values\n"); } } s22aac (mode, x, m, nl, p, &fail); Vprintf("mode x m nl\n\n"); Vprintf(fmt_99999, mode, x, m, nl); if (fail.code == NE_NOERROR) { Vprintf(str); Vprintf("\n"); Vprintf(" n P(n)\n"); for (n = 0; n <= nl; ++n) { Vprintf(fmt_99998,n,p[n]); } } else { Vprintf("Error from s22aac.\n%s\n", fail.message); exit_status = 1; goto END; } END: return exit_status; }