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

Comparing ray/src/util/cmatrix.c (file contents):
Revision 2.3 by greg, Tue Apr 8 23:45:33 2014 UTC vs.
Revision 2.4 by greg, Thu May 29 17:28:09 2014 UTC

# Line 31 | Line 31 | cm_alloc(int nrows, int ncols)
31          if ((nrows <= 0) | (ncols <= 0))
32                  error(USER, "attempt to create empty matrix");
33          cm = (CMATRIX *)malloc(sizeof(CMATRIX) +
34 <                                3*sizeof(COLORV)*(nrows*ncols - 1));
34 >                                sizeof(COLOR)*(nrows*ncols - 1));
35          if (cm == NULL)
36                  error(SYSTEM, "out of memory in cm_alloc()");
37          cm->nrows = nrows;
# Line 50 | Line 50 | cm_resize(CMATRIX *cm, int nrows)
50                  return(NULL);
51          }
52          cm = (CMATRIX *)realloc(cm, sizeof(CMATRIX) +
53 <                        3*sizeof(COLORV)*(nrows*cm->ncols - 1));
53 >                        sizeof(COLOR)*(nrows*cm->ncols - 1));
54          if (cm == NULL)
55                  error(SYSTEM, "out of memory in cm_resize()");
56          cm->nrows = nrows;
# Line 173 | Line 173 | cm_load(const char *fname, int nrows, int ncols, int d
173                          int     nread = 0;
174                          do {                            /* read all we can */
175                                  nread += fread(cm->cmem + 3*nread,
176 <                                                3*sizeof(COLORV),
176 >                                                sizeof(COLOR),
177                                                  cm->nrows*cm->ncols - nread,
178                                                  fp);
179                                  if (nrows <= 0) {       /* unknown length */
# Line 315 | Line 315 | cm_multiply(const CMATRIX *cm1, const CMATRIX *cm2)
315          for (dr = 0; dr < cmr->nrows; dr++)
316              for (dc = 0; dc < cmr->ncols; dc++) {
317                  COLORV  *dp = cm_lval(cmr,dr,dc);
318 +                double  res[3];
319                  dp[0] = dp[1] = dp[2] = 0;
320                  if (rowcheck != NULL && !rowcheck[dr])
321                          continue;
322                  if (colcheck != NULL && !colcheck[dc])
323                          continue;
324 +                res[0] = res[1] = res[2] = 0;
325                  for (i = 0; i < cm1->ncols; i++) {
326                      const COLORV        *cp1 = cm_lval(cm1,dr,i);
327                      const COLORV        *cp2 = cm_lval(cm2,i,dc);
328 <                    dp[0] += cp1[0] * cp2[0];
329 <                    dp[1] += cp1[1] * cp2[1];
330 <                    dp[2] += cp1[2] * cp2[2];
328 >                    res[0] += cp1[0] * cp2[0];
329 >                    res[1] += cp1[1] * cp2[1];
330 >                    res[2] += cp1[2] * cp2[2];
331                  }
332 +                copycolor(dp, res);
333              }
334          if (rowcheck != NULL) free(rowcheck);
335          if (colcheck != NULL) free(colcheck);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines