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 >
Wrap
C/C++ Source or Header
|
1990-12-15
|
776b
|
50 lines
#include <stdio.h>
main(argc, argv)
char **argv;
{
int x, last = -1, m;
float y;
struct pt_list *pts = pt_init();
FILE *fp;
if (argc != 2)
exit(1);
fp = fopen(argv[1], "r");
if (fp == 0) {
perror(argv[1]);
exit(1);
}
while (fscanf(fp, "%d %f", &x, &y) == 2) {
printf("%d %f\n", x, y);
if (x <= last)
continue;
pt_insert(&pts, x, (float)y);
last = x;
}
fclose(fp);
if (pts == 0)
exit(0);
fp = fopen("f", "w");
if (fp == 0) {
perror("f");
exit(1);
}
for (x = 0; x < last + 10; x += 1) {
m = pt_integrate(pts, x);
fprintf(fp, "%d %d\n", x, m);
}
fclose(fp);
fp = fopen("b", "w");
if (fp == 0) {
perror("f");
exit(1);
}
for (x = 0; x < m + 10; x += 1)
fprintf(fp, "%d %d\n", x, pt_back_integrate(pts, x));
exit(0);
}