ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/tabfunc.c
(Generate patch)

Comparing ray/src/cal/tabfunc.c (file contents):
Revision 1.2 by schorsch, Sun Jun 8 12:03:09 2003 UTC vs.
Revision 1.9 by greg, Mon Jun 29 21:25:36 2020 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
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;
# Line 34 | Line 26 | char   *progname;
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  
# Line 43 | Line 35 | char   locID[16];                      /* local identifier (for uniqueness)
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
# Line 68 | Line 60 | char   **argv
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);
# Line 156 | Line 148 | absc_exp(void)                 /* produce expression for abscissa */
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);
157                  putlist(abscissa, tabsize, 20);
158                  puts(");");
159                  if (increasing) {
160 +                        printf("fx2`%s(x,i):if(x-X`%s(i),\n", locID, locID);
161                          printf("fx`%s(x):if(x-%g,if(%g-x,fx2`%s(x,%d),%d),1);\n",
162                                          locID, abscissa[0], abscissa[tabsize-1],
163                                          locID, tabsize, tabsize);
169                        printf("fx2`%s(x,i):if(x-X`%s(i),\n", locID, locID);
164                  } else {
165 +                        printf("fx2`%s(x,i):if(X`%s(i)-x,\n", locID, locID);
166                          printf("fx`%s(x):if(%g-x,if(x-%g,fx2`%s(x,%d),%d),1);\n",
167                                          locID, abscissa[0], abscissa[tabsize-1],
168                                          locID, tabsize, tabsize);
174                        printf("fx2`%s(x,i):if(X`%s(i)-x,\n", locID, locID);
169                  }
170                  printf("\ti+(x-X`%s(i))/(X`%s(i+1)-X`%s(i)),\n",
171                                  locID, locID, locID);
# Line 192 | Line 186 | char   *xe
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);
# Line 212 | Line 206 | char   *xe
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   )

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines