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.1 by greg, Sat May 31 05:02:37 2014 UTC vs.
Revision 2.2 by greg, Sat May 31 19:21:21 2014 UTC

# Line 18 | Line 18 | typedef struct {
18          int             nsf;                    /* number of scalars */
19          double          cmat[MAXCOMP*MAXCOMP];  /* component transformation */
20          int             clen;                   /* number of coefficients */
21 <        int             transpose;              /* do transpose? (<0 first) */
21 >        int             transpose;              /* do transpose? */
22          int             op;                     /* '*' or '+' */
23   } ROPERAT;                              /* matrix operation */
24  
# Line 36 | Line 36 | static RMATRIX *
36   operate(RMATRIX *mleft, ROPERAT *op, const char *fname)
37   {
38          RMATRIX *mright = rmx_load(fname);
39 +        RMATRIX *mtmp;
40          int     i;
41  
42          if (fname == NULL)
# Line 45 | Line 46 | operate(RMATRIX *mleft, ROPERAT *op, const char *fname
46                  fputs(": cannot load matrix\n", stderr);
47                  return(NULL);
48          }
49 <        if (op->transpose < 0) {        /* transpose first? */
50 <                if (!rmx_transpose(mright)) {
49 >        if (op->transpose) {            /* transpose matrix? */
50 >                mtmp = rmx_transpose(mright);
51 >                if (mtmp == NULL) {
52                          fputs(fname, stderr);
53                          fputs(": transpose failed\n", stderr);
54                          rmx_free(mright);
# Line 56 | Line 58 | operate(RMATRIX *mleft, ROPERAT *op, const char *fname
58                          fputs(fname, stderr);
59                          fputs(": transposed rows and columns\n", stderr);
60                  }
61 +                rmx_free(mright);
62 +                mright = mtmp;
63          }
64          if (op->nsf > 0) {              /* apply scalar(s) */
65                  if (op->clen > 0) {
# Line 88 | Line 92 | operate(RMATRIX *mleft, ROPERAT *op, const char *fname
92                  }
93          }
94          if (op->clen > 0) {             /* apply transform */
91                RMATRIX *mtmp;
95                  if (op->clen % mright->ncomp) {
96                          fprintf(stderr, "%s: -c must have N x %d coefficients\n",
97                                          fname, mright->ncomp);
# Line 107 | Line 110 | operate(RMATRIX *mleft, ROPERAT *op, const char *fname
110                  rmx_free(mright);
111                  mright = mtmp;
112          }
110        if (op->transpose > 0) {        /* transpose after? */
111                if (!rmx_transpose(mright)) {
112                        fputs(fname, stderr);
113                        fputs(": transpose failed\n", stderr);
114                        rmx_free(mright);
115                        return(NULL);
116                }
117                if (verbose) {
118                        fputs(fname, stderr);
119                        fputs(": transposed rows and columns\n", stderr);
120                }
121        }
113          if (mleft == NULL)              /* just one matrix */
114                  return(mright);
115          if (op->op == '*') {            /* concatenate */
# Line 220 | Line 211 | main(int argc, char *argv[])
211                                  }
212                                  break;
213                          case 't':
214 <                                if (!op.nsf & !op.clen)
224 <                                        op.transpose = -1;
225 <                                else
226 <                                        op.transpose = 1;
214 >                                op.transpose = 1;
215                                  break;
216                          case 's':
217                                  if (n > MAXCOMP) n = MAXCOMP;
# Line 257 | Line 245 | main(int argc, char *argv[])
245          return(0);
246   userr:
247          fprintf(stderr,
248 <        "Usage: %s [-v][-f[adfc][-t][-s sf ..][-c ce ..] m1 [+] .. > mres\n",
248 >        "Usage: %s [-v][-f[adfc][-t][-s sf .. | -c ce ..] m1 [+] .. > mres\n",
249                          argv[0]);
250          return(1);
251   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines