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

Comparing ray/src/util/rmtxop.c (file contents):
Revision 2.23 by greg, Tue Nov 28 16:36:50 2023 UTC vs.
Revision 2.26 by greg, Fri Dec 1 02:05:00 2023 UTC

# Line 5 | Line 5 | static const char RCSid[] = "$Id$";
5   * General component matrix operations.
6   */
7  
8 #include <stdlib.h>
8   #include <errno.h>
9   #include <ctype.h>
10   #include "rtio.h"
# Line 92 | Line 91 | sensrow(ROPMAT *rop, int r, double (*sf)(SCOLOR sc, in
91          for (i = nc; i--; ) {
92                  SCOLOR  sclr;
93                  scolorblack(sclr);
94 <                sclr[i] = 1;
94 >                sclr[i] = 1.f;
95                  rop->preop.cmat[r*nc+i] = (*sf)(sclr, nc, rop->mtx->wlpart);
96          }
97   }
# Line 156 | Line 155 | checksymbolic(ROPMAT *rop)
155                          for (i = nc*(dt != DTxyze); i--; )
156                                  rop->preop.cmat[j*nc+i] *= WHTEFFICACY;
157                          break;
158 <                case 'S':
158 >                case 'S':               /* scotopic (il)luminance */
159                          sensrow(rop, j, scolor2scotopic);
160                          for (i = nc; i--; )
161                                  rop->preop.cmat[j*nc+i] *= WHTSCOTOPIC;
162                          break;
163 <                case 'M':
163 >                case 'M':               /* melanopic (il)luminance */
164                          sensrow(rop, j, scolor2melanopic);
165                          for (i = nc; i--; )
166                                  rop->preop.cmat[j*nc+i] *= WHTMELANOPIC;
167                          break;
168 +                case 'A':               /* average component */
169 +                        for (i = nc; i--; )
170 +                                rop->preop.cmat[j*nc+i] = 1./(double)nc;
171 +                        break;
172                  default:
173                          fprintf(stderr, "%s: -c '%c' unsupported\n",
174                                  rop->inspec, rop->preop.csym[j]);
# Line 232 | Line 235 | loadop(ROPMAT *rop)
235                                          rop->inspec, mres->ncomp,
236                                          rop->mtx->ncomp,
237                                          rop->preop.nsf ? " (* scalar)" : "");
238 <                rop->preop.nsf = 0;
238 >                rop->preop.nsf = 0;             /* now folded in */
239                  if ((mres->ncomp > 3) & (mres->dtype <= DTspec))
240                          outtype = DTfloat;      /* probably not actual spectrum */
241                  rmx_free(rop->mtx);
# Line 445 | Line 448 | get_factors(double da[], int n, char *av[])
448   }
449  
450   static ROPMAT *
451 < grow_moparray(ROPMAT *mop, int n2alloc)
451 > resize_moparr(ROPMAT *mop, int n2alloc)
452   {
453          int     nmats = 0;
454 +        int     i;
455  
456          while (mop[nmats++].binop)
457                  ;
458 +        for (i = nmats; i > n2alloc; i--)
459 +                rmx_free(mop[i].mtx);
460          mop = (ROPMAT *)realloc(mop, n2alloc*sizeof(ROPMAT));
461          if (mop == NULL) {
462 <                fputs("Out of memory in grow_moparray()\n", stderr);
462 >                fputs("Out of memory in resize_moparr()\n", stderr);
463                  exit(1);
464          }
465          if (n2alloc > nmats)
# Line 569 | Line 575 | main(int argc, char *argv[])
575                          }
576                  }
577                  if (nmats >= nall)
578 <                        mop = grow_moparray(mop, nall += 2);
578 >                        mop = resize_moparr(mop, nall += 2);
579          }
580          if (mop[0].inspec == NULL)      /* nothing to do? */
581                  goto userr;
# Line 597 | Line 603 | main(int argc, char *argv[])
603                  else if (mres->dtype == DTxyze)
604                          outfmt = DTxyze;
605          }
606 <        if (outfmt != DTascii)          /* write result to stdout */
601 <                SET_FILE_BINARY(stdout);
602 <        newheader("RADIANCE", stdout);
606 >        newheader("RADIANCE", stdout);  /* write result to stdout */
607          printargs(argc, argv, stdout);
604
608          return(rmx_write(mres, outfmt, stdout) ? 0 : 1);
609   userr:
610          fprintf(stderr,
611 <        "Usage: %s [-v][-f[adfc][-t][-s sf .. | -c ce ..][-rf|-rb] m1 [.+*/] .. > mres\n",
611 >        "Usage: %s [-v][-f{adfc}][-t][-s sf .. | -c ce ..][-rf|-rb] m1 [.+*/] .. > mres\n",
612                          argv[0]);
613          return(1);
614   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines