--- ray/src/util/rmtxop.c 2023/12/02 00:42:21 2.27 +++ ray/src/util/rmtxop.c 2023/12/08 00:12:31 2.30 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rmtxop.c,v 2.27 2023/12/02 00:42:21 greg Exp $"; +static const char RCSid[] = "$Id: rmtxop.c,v 2.30 2023/12/08 00:12:31 greg Exp $"; #endif /* * General component matrix operations. @@ -69,7 +69,7 @@ checkreffile(ROPMAT *rop) fclose(fp); curRF = rop->preop.csym; } - if ((refm.ncomp == 3) & (refm.dtype != DTspec)) { + if (refm.ncomp == 3) { rop->preop.csym = (refm.dtype == DTxyze) ? "XYZ" : "RGB"; return(checksymbolic(rop)); } @@ -103,6 +103,7 @@ checkreffile(ROPMAT *rop) for (j = refm.ncomp; j-- > 0; ) rop->preop.cmat[j*nc + i] = scresp[j]; } + memcpy(rop->mtx->wlpart, refm.wlpart, sizeof(rop->mtx->wlpart)); return(0); } @@ -244,8 +245,7 @@ checksymbolic(ROPMAT *rop) } else if (!strcmp(rop->preop.csym, "RGB")) { if (dt <= DTspec) return(DTrgbe); - } - if ((nc > 3) & (dt <= DTspec)) + } else if (dt == DTspec) return(DTfloat); /* probably not actual spectrum */ return(0); } @@ -274,15 +274,16 @@ loadop(ROPMAT *rop) if (rop->preop.nsf == 1) { for (i = rop->preop.clen; i--; ) rop->preop.cmat[i] *= rop->preop.sca[0]; - } else if (rop->preop.nsf != rop->mtx->ncomp) { + } else if (rop->preop.nsf*rop->mtx->ncomp != rop->preop.clen) { fprintf(stderr, "%s: -s must have one or %d factors\n", - rop->inspec, rop->mtx->ncomp); + rop->inspec, + rop->preop.clen/rop->mtx->ncomp); goto failure; } else { - for (j = rop->preop.clen/rop->preop.nsf; j--; ) - for (i = rop->preop.nsf; i--; ) - rop->preop.cmat[j*rop->preop.nsf+i] *= - rop->preop.sca[i]; + for (i = rop->preop.nsf; i--; ) + for (j = rop->mtx->ncomp; j--; ) + rop->preop.cmat[i*rop->mtx->ncomp+j] + *= rop->preop.sca[i]; } } mres = rmx_transform(rop->mtx, rop->preop.clen/rop->mtx->ncomp,