home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.lbl.gov / 2014.05.ftp.ee.lbl.gov.tar / ftp.ee.lbl.gov / bmd-1.0beta.tar.Z / bmd-1.0beta.tar / bmd-1.0beta / app / omtd / pt-test.c < prev    next >
C/C++ Source or Header  |  1990-12-15  |  776b  |  50 lines

  1. #include <stdio.h>
  2.  
  3. main(argc, argv)
  4.     char **argv;
  5. {
  6.     int x, last = -1, m;
  7.     float y;
  8.     struct pt_list *pts = pt_init();
  9.     FILE *fp;
  10.     
  11.     if (argc != 2)
  12.         exit(1);
  13.     fp = fopen(argv[1], "r");
  14.     if (fp == 0) {
  15.         perror(argv[1]);
  16.         exit(1);
  17.     }
  18.     while (fscanf(fp, "%d %f", &x, &y) == 2) {
  19.         printf("%d %f\n", x, y);
  20.         if (x <= last)
  21.             continue;
  22.         pt_insert(&pts, x, (float)y);
  23.         last = x;
  24.     }
  25.     fclose(fp);
  26.     if (pts == 0)
  27.         exit(0);
  28.  
  29.     fp = fopen("f", "w");
  30.     if (fp == 0) {
  31.         perror("f");
  32.         exit(1);
  33.     }
  34.     for (x = 0; x < last + 10; x += 1) {
  35.         m = pt_integrate(pts, x);
  36.         fprintf(fp, "%d %d\n", x, m);
  37.     }
  38.     fclose(fp);
  39.     fp = fopen("b", "w");
  40.     if (fp == 0) {
  41.         perror("f");
  42.         exit(1);
  43.     }
  44.     for (x = 0; x < m + 10; x += 1)
  45.         fprintf(fp, "%d %d\n", x, pt_back_integrate(pts, x));
  46.  
  47.     exit(0);
  48. }
  49.  
  50.