7 |
|
* 2/2/95 Greg Ward |
8 |
|
*/ |
9 |
|
|
10 |
– |
#include <stdio.h> |
10 |
|
#include <stdlib.h> |
12 |
– |
#include <string.h> |
11 |
|
#include <math.h> |
12 |
|
#include <ctype.h> |
15 |
– |
#ifdef _WIN32 |
16 |
– |
#include <process.h> /* getpid() */ |
17 |
– |
#else |
18 |
– |
#include <sys/types.h> |
19 |
– |
#include <unistd.h> |
20 |
– |
#endif |
13 |
|
|
14 |
< |
#include "standard.h" |
15 |
< |
#include "platform.h" |
14 |
> |
#include "rtprocess.h" /* getpid() */ |
15 |
> |
#include "rtmath.h" |
16 |
> |
#include "rtio.h" |
17 |
|
|
18 |
|
#define isdelim(c) (isspace(c) || (c)==',') |
19 |
|
|
20 |
< |
#define MAXTAB 1024 /* maximum number of data rows */ |
21 |
< |
#define MAXLINE 4096 /* maximum line width (characters) */ |
29 |
< |
/*#define FLOAT float */ /* real type (precision) */ |
20 |
> |
#define MAXTAB 8192 /* maximum number of data rows */ |
21 |
> |
#define MAXLINE 16384 /* maximum line width (characters) */ |
22 |
|
#define OUTFMT "%.7g" /* output format conversion string */ |
23 |
|
|
24 |
|
int interpolate = 0; |
26 |
|
char **func; |
27 |
|
int nfuncs; |
28 |
|
|
29 |
< |
FLOAT abscissa[MAXTAB]; /* independent values (first column) */ |
30 |
< |
FLOAT (*ordinate)[MAXTAB]; /* dependent values (other columns) */ |
29 |
> |
RREAL abscissa[MAXTAB]; /* independent values (first column) */ |
30 |
> |
RREAL (*ordinate)[MAXTAB]; /* dependent values (other columns) */ |
31 |
|
int tabsize = 0; /* final table size (number of rows) */ |
32 |
|
char locID[16]; /* local identifier (for uniqueness) */ |
33 |
|
|
35 |
|
|
36 |
|
static void load_data(FILE *fp); |
37 |
|
static void print_funcs(char *xe); |
38 |
< |
static void putlist(register FLOAT *av, int al, register int pos); |
38 |
> |
static void putlist(register RREAL *av, int al, register int pos); |
39 |
|
static char * absc_exp(void); |
40 |
|
|
41 |
|
int |
60 |
|
} |
61 |
|
func = argv; |
62 |
|
nfuncs = argc; |
63 |
< |
ordinate = (FLOAT (*)[MAXTAB])malloc(nfuncs*MAXTAB*sizeof(FLOAT)); |
63 |
> |
ordinate = (RREAL (*)[MAXTAB])malloc(nfuncs*MAXTAB*sizeof(RREAL)); |
64 |
|
if (ordinate == NULL) { |
65 |
|
fprintf(stderr, "%s: not enough memory\n", progname); |
66 |
|
exit(1); |
148 |
|
strcpy(ourexp, "x"); |
149 |
|
else |
150 |
|
sprintf(ourexp, "x-%g", abscissa[0]-1); |
151 |
< |
} else |
151 |
> |
} else if (fabs(abscissa[0]) < eps) |
152 |
> |
sprintf(ourexp, "x/%g+1", step); |
153 |
> |
else |
154 |
|
sprintf(ourexp, "(x-%g)/%g+1", abscissa[0], step); |
155 |
|
} else { |
156 |
|
printf("X`%s(i):select(i,", locID); |
186 |
|
|
187 |
|
xelen = strlen(xe); |
188 |
|
for (i = 0; i < nfuncs; i++) { |
189 |
< |
if (func[i][0] == '\0' | func[i][0] == '0') |
189 |
> |
if ((func[i][0] == '\0') | (func[i][0] == '0')) |
190 |
|
continue; |
191 |
|
if (interpolate) { |
192 |
|
printf("%s`%s(i):select(i,", func[i], locID); |
206 |
|
|
207 |
|
static void |
208 |
|
putlist( /* put out array of values */ |
209 |
< |
register FLOAT *av, |
209 |
> |
register RREAL *av, |
210 |
|
int al, |
211 |
|
register int pos |
212 |
|
) |