/* nag_inteq_abel_weak_weights (d05byc) Example Program.
*
* Copyright 2023 Numerical Algorithms Group.
*
* Mark 29.2, 2023.
*/
#include <math.h>
#include <nag.h>
int main(void) {
/* Scalars */
Integer exit_status = 0;
Integer i, iorder, iq, j, lomega, n, ncols, ncwt, nmax;
/* Arrays */
double *omega = 0, *sw = 0;
/* NAG types */
NagError fail;
INIT_FAIL(fail);
printf("nag_inteq_abel_weak_weights (d05byc) Example Program Results\n");
/* Skip heading in data file */
scanf("%*[^\n] ");
scanf("%" NAG_IFMT "%*[^\n] ", &iorder);
scanf("%" NAG_IFMT "%*[^\n] ", &iq);
ncwt = pow(2, iq + 1);
lomega = 2 * ncwt;
ncols = 2 * iorder - 1;
nmax = ncwt + ncols;
if (!(omega = NAG_ALLOC(lomega, double)) ||
!(sw = NAG_ALLOC(ncols * nmax, double))) {
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
/*
nag_inteq_abel_weak_weights (d05byc).
Generate weights for use in solving weakly singular Abel-type equations.
*/
nag_inteq_abel_weak_weights(iorder, iq, omega, sw, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_inteq_abel_weak_weights (d05byc).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
printf("\nFractional convolution weights\n\n");
for (i = 0; i < ncwt; i++)
printf("%5" NAG_IFMT " %9.4f\n", i, omega[i]);
printf("\nFractional starting weights W\n\n");
#define SW(I, J) sw[J * nmax + I - 1]
for (n = 1; n <= nmax; n++) {
printf("%5" NAG_IFMT " ", n);
for (j = 0; j < ncols; j++)
printf("%9.4f", SW(n, j));
printf("\n");
}
#undef SW
END:
NAG_FREE(sw);
NAG_FREE(omega);
return exit_status;
}