--- ray/src/util/rmtxop.c 2019/08/12 20:38:19 2.16 +++ ray/src/util/rmtxop.c 2022/03/23 00:58:35 2.20 @@ -1,11 +1,10 @@ #ifndef lint -static const char RCSid[] = "$Id: rmtxop.c,v 2.16 2019/08/12 20:38:19 greg Exp $"; +static const char RCSid[] = "$Id: rmtxop.c,v 2.20 2022/03/23 00:58:35 greg Exp $"; #endif /* * General component matrix operations. */ -#include #include #include #include "rtio.h" @@ -15,8 +14,6 @@ static const char RCSid[] = "$Id: rmtxop.c,v 2.16 2019 #define MAXCOMP 16 /* #components we support */ -static const char stdin_name[] = ""; - /* unary matrix operation(s) */ typedef struct { double sca[MAXCOMP]; /* scalar coefficients */ @@ -29,6 +26,7 @@ typedef struct { /* matrix input source and requested operation(s) */ typedef struct { const char *inspec; /* input specification */ + RMPref rmp; /* matrix preference */ RUNARYOP preop; /* unary operation(s) */ RMATRIX *mtx; /* original matrix if loaded */ int binop; /* binary op with next (or 0) */ @@ -40,11 +38,10 @@ int verbose = 0; /* verbose reporting? */ static int loadmatrix(ROPMAT *rop) { - if (rop->mtx != NULL) + if (rop->mtx != NULL) /* already loaded? */ return(0); - rop->mtx = rmx_load(rop->inspec == stdin_name ? - (const char *)NULL : rop->inspec); + rop->mtx = rmx_load(rop->inspec, rop->rmp); if (rop->mtx == NULL) { fputs(rop->inspec, stderr); fputs(": cannot load matrix\n", stderr); @@ -242,7 +239,7 @@ op_right2left(ROPMAT *mop) while (rpos-- > 0) { if (mright == NULL) break; - mright = binaryop(mop[rpos].inspec, + mright = binaryop(mop[rpos+1].inspec, loadop(mop+rpos), mop[rpos].binop, mright); } return(mright); @@ -383,6 +380,14 @@ main(int argc, char *argv[]) get_factors(mop[nmats].preop.cmat, n, argv+i+1); break; + case 'r': + if (argv[i][2] == 'f') + mop[nmats].rmp = RMPreflF; + else if (argv[i][2] == 'b') + mop[nmats].rmp = RMPreflB; + else + goto userr; + break; default: fprintf(stderr, "%s: unknown operation '%s'\n", argv[0], argv[i]); @@ -425,7 +430,7 @@ main(int argc, char *argv[]) return(0); userr: fprintf(stderr, - "Usage: %s [-v][-f[adfc][-t][-s sf .. | -c ce ..] m1 [.+*/] .. > mres\n", + "Usage: %s [-v][-f[adfc][-t][-s sf .. | -c ce ..][-rf|-rb] m1 [.+*/] .. > mres\n", argv[0]); return(1); }