/* nag_bessel_k_alpha (s18egc) Example Program.
*
* Copyright 2024 Numerical Algorithms Group.
*
* NAG C Library
*
* Mark 30.2, 2024.
*/
#include <nag.h>
#include <stdio.h>
int main(void) {
Integer exit_status = 0, i, ia, ja, nl;
NagError fail;
double alpha, *b = 0, x;
INIT_FAIL(fail);
/* Skip heading in data file */
scanf("%*[^\n]");
printf("nag_bessel_k_alpha (s18egc) Example Program Results\n");
if (!(b = NAG_ALLOC(101, double))) {
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
while (scanf("%lf %" NAG_IFMT " %" NAG_IFMT " %" NAG_IFMT "%*[^\n]", &x, &ia,
&ja, &nl) != EOF) {
printf(" x ia ja nl\n");
printf("%4.1f %6" NAG_IFMT " %6" NAG_IFMT " %6" NAG_IFMT "\n\n", x, ia, ja,
nl);
/* nag_bessel_k_alpha (s18egc).
* Modified Bessel functions K_(alpha+n)(x) for real
* x > 0, selected values of alpha >= 0 and
* n = 0,1,...,N
*/
nag_bessel_k_alpha(x, ia, ja, nl, b, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_bessel_k_alpha (s18egc).\n%s\n", fail.message);
exit_status = 1;
goto END;
}
printf(" Requested values of K_alpha(x)\n\n");
alpha = (double)ia / (double)ja;
printf(" alpha K_alpha(x)\n");
for (i = 0; i <= nl; ++i) {
printf(" %13.4e %13.4e\n", alpha, b[i]);
alpha += 1.0;
}
}
END:
NAG_FREE(b);
return exit_status;
}