/*
	Test per Int_function() e Int_string()

*/

#include "integrate.h"

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int count=0;

double myfun(double x) { ++count; return exp(-x*x); }

int main(int argc, char *argv[])
{
if (argc==3 || argc==4) {
	double a=atof(argv[1]), b=atof(argv[2]);
	int c=(argc==4)?atoi(argv[3]):0;

	printf("Test di Int_function() per e^(-x^2) tra %g e %g - %d\n",a,b,c);
	printf("Valore: %.15g\n", Int_function(&myfun,a,b,&c) );
	printf("Valutazioni: %d\n",count);
} else if (argc==5) {
	double a=atof(argv[2]), b=atof(argv[3]);
	int c=atoi(argv[4]);

	printf("Test di Int_string() per %s tra %g e %g - %d\n",argv[1],a,b,c);
	printf("Valore: %.15g\n", Int_string(argv[1],a,b,&c) );
} else
	printf("Uso: %s from to [cifre]\noppure %s string from to cifre\n",
		argv[0],argv[0]);

}
