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

Comparing ray/src/cal/total.c (file contents):
Revision 1.6 by greg, Fri Apr 18 16:32:27 2008 UTC vs.
Revision 1.9 by greg, Sun Mar 9 20:07:27 2014 UTC

# Line 13 | Line 13 | static const char      RCSid[] = "$Id$";
13   #include  <math.h>
14   #include  "platform.h"
15  
16 < #define  MAXCOL         2048            /* maximum number of columns */
16 > #define  MAXCOL         8192            /* maximum number of columns */
17  
18   #define  ADD            0               /* add numbers */
19   #define  MULT           1               /* multiply numbers */
# Line 226 | Line 226 | char  *fname
226   {
227          double  inpval[MAXCOL];
228          double  tally[MAXCOL];
229 +        short   rsign[MAXCOL];
230          double  result[MAXCOL];
231 <        register int  n;
231 >        int  n;
232          int  nread, ncol;
233          long  nlin, ltotal;
234          FILE  *fp;
# Line 240 | Line 241 | char  *fname
241          }
242          if (nbicols)
243                  SET_FILE_BINARY(fp);
244 + #ifdef getc_unlocked                            /* avoid lock/unlock overhead */
245 +        flockfile(fp);
246 + #endif
247 +
248          ltotal = 0;
249          while (!feof(fp)) {
250                  if (ltotal == 0) {                      /* initialize */
251                          if (func == MULT)       /* special case */
252 <                                for (n = 0; n < MAXCOL; n++)
252 >                                for (n = 0; n < MAXCOL; n++) {
253                                          tally[n] = 0.0;
254 +                                        rsign[n] = 1;
255 +                                }
256                          else
257                                  for (n = 0; n < MAXCOL; n++)
258                                          tally[n] = init_val[func];
# Line 267 | Line 274 | char  *fname
274                                          break;
275                                  case MULT:
276                                          if (inpval[n] == 0.0)
277 <                                                break;
278 <                                        tally[n] += log(fabs(inpval[n]));
277 >                                                rsign[n] = 0;
278 >                                        else if (inpval[n] < 0.0) {
279 >                                                rsign[n] = -rsign[n];
280 >                                                inpval[n] = -inpval[n];
281 >                                        }
282 >                                        if (rsign[n])
283 >                                                tally[n] += log(inpval[n]);
284                                          break;
285                                  case MAX:
286                                          if (inpval[n] > tally[n])
# Line 294 | Line 306 | char  *fname
306                                          result[n] = pow(result[n], 1.0/power);
307                          }
308                          if (func == MULT)
309 <                                result[n] = exp(result[n]);
309 >                                result[n] = rsign[n] * exp(result[n]);
310                  }
311                  putrecord(result, ncol, stdout);
312                  if (!subtotal)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines