/* nag_blast_zload (f16hbc) Example Program.
*
* Copyright 2021 Numerical Algorithms Group.
*
* Mark 27.2, 2021.
*/
#include <nag.h>
#include <stdio.h>
int main(void) {
/* Scalars */
Complex alpha;
Integer exit_status, i, incx, n, xlen;
/* Arrays */
Complex *x = 0;
/* Nag Types */
NagError fail;
exit_status = 0;
INIT_FAIL(fail);
printf("nag_blast_zload (f16hbc) Example Program Results\n\n");
/* Skip heading in data file */
scanf("%*[^\n] ");
/* Read length of vector and increment. */
scanf("%" NAG_IFMT "%" NAG_IFMT "%*[^\n] ", &n, &incx);
/* Read scalar parameter */
scanf(" ( %lf , %lf ) %*[^\n] ", &alpha.re, &alpha.im);
xlen = MAX(1, 1 + (n - 1) * ABS(incx));
if (n > 0) {
/* Allocate memory */
if (!(x = NAG_ALLOC(xlen, Complex))) {
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
} else {
printf("Invalid n\n");
exit_status = 1;
return exit_status;
}
/* nag_blast_zload (f16hbc).
* Broadcast a complex scalar to a complex vector.
*
*/
nag_blast_zload(n, alpha, x, incx, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_blast_zload.\n%s\n", fail.message);
exit_status = 1;
goto END;
}
/* Print x. */
printf("Loaded vector x:\n\n");
for (i = 0; i < xlen; i = i + incx)
printf(" x[%1" NAG_IFMT "] = (%5.2f, %5.2f)\n", i, x[i].re, x[i].im);
END:
NAG_FREE(x);
return exit_status;
}