/* nag_lambertW (c05bac) Example Program.
*
* Copyright 2014 Numerical Algorithms Group.
*
* Mark 9, 2009.
*/
#include <stdio.h>
#include <math.h>
#include <nag.h>
#include <nag_stdlib.h>
#include <nagc05.h>
int main(void)
{
/* Scalars */
double w, x;
Integer branch;
Integer exit_status = 0;
char offset[10];
Nag_Boolean offsetenum;
NagError fail;
INIT_FAIL(fail);
printf("nag_lambertW (c05bac) Example Program Results\n");
/* Skip heading in data file*/
scanf("%*[^\n] ");
scanf("%ld%*[^\n] ", &branch);
scanf("%9s%*[^\n] ", offset);
/*
* nag_enum_name_to_value (x04nac).
* Converts NAG enum member name to value
*/
offsetenum = (Nag_Boolean) nag_enum_name_to_value(offset);
printf("\n");
printf("branch = %ld\n", branch);
printf("offset = %s\n", offset);
printf("\n x w(x)\n\n");
while (scanf("%lf%*[^\n] ", &x) != EOF)
{
/*
* nag_lambertW (c05bac)
* Real values of Lambert's W function, W(x)
*/
w = nag_lambertW(x, branch, offsetenum, &fail);
if (fail.code == NE_NOERROR)
{
printf("%14.5e%14.5e\n", x, w);
}
else
{
printf("Error from nag_lambertW (c05bac).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
}
END:
return exit_status;
}