home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / misc / integra1_0a.lha / Integra / examples / 0test.c next >
Encoding:
C/C++ Source or Header  |  1994-10-22  |  820 b   |  36 lines

  1. /*
  2.     Test per Int_function() e Int_string()
  3.  
  4. */
  5.  
  6. #include "integrate.h"
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <math.h>
  11.  
  12. int count=0;
  13.  
  14. double myfun(double x) { ++count; return exp(-x*x); }
  15.  
  16. int main(int argc, char *argv[])
  17. {
  18. if (argc==3 || argc==4) {
  19.     double a=atof(argv[1]), b=atof(argv[2]);
  20.     int c=(argc==4)?atoi(argv[3]):0;
  21.  
  22.     printf("Test di Int_function() per e^(-x^2) tra %g e %g - %d\n",a,b,c);
  23.     printf("Valore: %.15g\n", Int_function(&myfun,a,b,&c) );
  24.     printf("Valutazioni: %d\n",count);
  25. } else if (argc==5) {
  26.     double a=atof(argv[2]), b=atof(argv[3]);
  27.     int c=atoi(argv[4]);
  28.  
  29.     printf("Test di Int_string() per %s tra %g e %g - %d\n",argv[1],a,b,c);
  30.     printf("Valore: %.15g\n", Int_string(argv[1],a,b,&c) );
  31. } else
  32.     printf("Uso: %s from to [cifre]\noppure %s string from to cifre\n",
  33.         argv[0],argv[0]);
  34.  
  35. }
  36.