--- ray/src/cal/tabfunc.c 2003/07/14 20:02:29 1.4 +++ ray/src/cal/tabfunc.c 2020/06/29 21:25:36 1.9 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: tabfunc.c,v 1.4 2003/07/14 20:02:29 schorsch Exp $"; +static const char RCSid[] = "$Id: tabfunc.c,v 1.9 2020/06/29 21:25:36 greg Exp $"; #endif /* * Put tabular data into functions suitable for cal programs. @@ -7,12 +7,9 @@ static const char RCSid[] = "$Id: tabfunc.c,v 1.4 2003 * 2/2/95 Greg Ward */ -#include #include -#include #include #include -#include #include "rtprocess.h" /* getpid() */ #include "rtmath.h" @@ -20,8 +17,8 @@ static const char RCSid[] = "$Id: tabfunc.c,v 1.4 2003 #define isdelim(c) (isspace(c) || (c)==',') -#define MAXTAB 1024 /* maximum number of data rows */ -#define MAXLINE 4096 /* maximum line width (characters) */ +#define MAXTAB 8192 /* maximum number of data rows */ +#define MAXLINE 16384 /* maximum line width (characters) */ #define OUTFMT "%.7g" /* output format conversion string */ int interpolate = 0; @@ -151,22 +148,24 @@ absc_exp(void) /* produce expression for abscissa */ strcpy(ourexp, "x"); else sprintf(ourexp, "x-%g", abscissa[0]-1); - } else + } else if (fabs(abscissa[0]) < eps) + sprintf(ourexp, "x/%g+1", step); + else sprintf(ourexp, "(x-%g)/%g+1", abscissa[0], step); } else { printf("X`%s(i):select(i,", locID); putlist(abscissa, tabsize, 20); puts(");"); if (increasing) { + printf("fx2`%s(x,i):if(x-X`%s(i),\n", locID, locID); printf("fx`%s(x):if(x-%g,if(%g-x,fx2`%s(x,%d),%d),1);\n", locID, abscissa[0], abscissa[tabsize-1], locID, tabsize, tabsize); - printf("fx2`%s(x,i):if(x-X`%s(i),\n", locID, locID); } else { + printf("fx2`%s(x,i):if(X`%s(i)-x,\n", locID, locID); printf("fx`%s(x):if(%g-x,if(x-%g,fx2`%s(x,%d),%d),1);\n", locID, abscissa[0], abscissa[tabsize-1], locID, tabsize, tabsize); - printf("fx2`%s(x,i):if(X`%s(i)-x,\n", locID, locID); } printf("\ti+(x-X`%s(i))/(X`%s(i+1)-X`%s(i)),\n", locID, locID, locID); @@ -187,7 +186,7 @@ char *xe xelen = strlen(xe); for (i = 0; i < nfuncs; i++) { - if (func[i][0] == '\0' | func[i][0] == '0') + if ((func[i][0] == '\0') | (func[i][0] == '0')) continue; if (interpolate) { printf("%s`%s(i):select(i,", func[i], locID);