Skip to content

Commit

Permalink
fix: repaired out-of-order function output for irregular abscissa
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregungory committed Mar 18, 2021
1 parent 488ee66 commit 3218f0f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/cal/tabfunc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef lint
static const char RCSid[] = "$Id: tabfunc.c,v 1.9 2020/06/29 21:25:36 greg Exp $";
static const char RCSid[] = "$Id: tabfunc.c,v 1.10 2021/03/18 03:09:34 greg Exp $";
#endif
/*
* Put tabular data into functions suitable for cal programs.
Expand Down Expand Up @@ -156,20 +156,21 @@ absc_exp(void) /* produce expression for abscissa */
printf("X`%s(i):select(i,", locID);
putlist(abscissa, tabsize, 20);
puts(");");
if (increasing) {
if (increasing)
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("\ti+(x-X`%s(i))/(X`%s(i+1)-X`%s(i)),\n",
locID, locID, locID);
printf("\tfx2`%s(x,i-1));\n", locID);
if (increasing)
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);
} else {
printf("fx2`%s(x,i):if(X`%s(i)-x,\n", locID, locID);
else
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("\ti+(x-X`%s(i))/(X`%s(i+1)-X`%s(i)),\n",
locID, locID, locID);
printf("\tfx2`%s(x,i-1));\n", locID);
sprintf(ourexp, "fx`%s(x)", locID);
}
return(ourexp);
Expand Down

0 comments on commit 3218f0f

Please sign in to comment.