Dedekind ETA function


#include
#include
#include
#include

#define PACKAGE "eta"
#define VERSION "0.0.1"
#define MAXLINE 1024

/* Defination : The Dedekind eta function, named after Richard Dedekind, is a function defined on the upper half-plane of complex numbers, where the imaginary part is positive. */
void print_help(int exval);
/* print program version and exit with exval */
void print_version(int exval);
/* `\056' `float' detection ? */
/* returns -1 on error, 1 on `no dot', 0 on `dot' */
int is_float(char *val);

int main(int argc, char *argv[]) {
char line[MAXLINE]; /* fgets buff */
int overview_flag = 0; /* print overview only */
int count = 0; /* nr of input elements */
float total = 0; /* eta */
float num = 0; /* the actual element */
int opt = 0; /* parsed opt nr */
float highest = 0; /* the lowest encounterd nr */
float lowest = 0; /* the highest encounterd nr */

/* option parser */
while((opt = getopt(argc, argv, "hve")) != -1) {
switch(opt) {
case 'h': /* print help and exit */
print_help(0);
case 'v': /* print version and exit */
print_version(0);
case 'e':
overview_flag = 1;
break;
case '?':
fprintf(stderr, "%s: Error - No such option: `%c'\n\n", PACKAGE, optopt);
print_help(1);
}
}

/* no remaining argumenst left ? read stdin() */
if((argc - optind) == 0) {
while((fgets(line, MAXLINE, stdin)) != NULL) {
/* strip newlines */
if(line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';

count++;
if(is_float(line) == 0)
num = atof(line);
else
num = atoi(line);

if(count == 1) highest = num, lowest = num;

if(num > highest) highest = num;
if(num < lowest =" num;" num =" atoi(argv[optind]);" num =" atof(argv[optind]);" count ="="" highest =" num," lowest =" num;"> highest) highest = num;
if(num < lowest =" num;" overview_flag ="="" retval =" -1;" retval =" 1;" retval =" 0;">

No comments:

Post a Comment