/* nag_bessel_k_alpha_scaled (s18ehc) Example Program.
*
* Copyright 2014 Numerical Algorithms Group.
*
* NAG C Library
*
* Mark 6, 2000.
* Mark 8 revised, 2004.
*/
#include <math.h>
#include <stdio.h>
#include <nag.h>
#include <nag_stdlib.h>
#include <nags.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_scaled (s18ehc) Example Program Results\n");
if (!(b = NAG_ALLOC(101, double)))
{
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
while (scanf("%lf %ld %ld %ld%*[^\n]", &x, &ia, &ja,
&nl) != EOF)
{
printf(" x ia ja nl\n");
printf("%4.1f%6ld%6ld%6ld\n\n", x, ia, ja, nl);
/* nag_bessel_k_alpha_scaled (s18ehc).
* Scaled 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_scaled(x, ia, ja, nl, b, &fail);
if (fail.code != NE_NOERROR)
{
printf(
"Error from nag_bessel_k_alpha_scaled (s18ehc).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
printf(" Requested values of exp(x)*K_alpha(x)\n\n");
alpha = (double) ia / (double) ja;
printf(" alpha exp(x)*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;
}