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.14 by greg, Mon Aug 12 02:26:46 2019 UTC vs.
Revision 2.16 by greg, Mon Aug 12 20:38:19 2019 UTC

# Line 140 | Line 140 | binaryop(const char *inspec, RMATRIX *mleft, int op, R
140  
141          if ((mleft == NULL) | (mright == NULL))
142                  return(NULL);
143
143          switch (op) {
144          case '.':                       /* concatenate */
145 <                mres = rmx_multiply(mleft, mright);
145 >                if (mleft->ncomp != mright->ncomp) {
146 >                        fputs(inspec, stderr);
147 >                        fputs(": # components do not match\n", stderr);
148 >                } else if (mleft->ncols != mright->nrows) {
149 >                        fputs(inspec, stderr);
150 >                        fputs(": mismatched dimensions\n",
151 >                                        stderr);
152 >                } else
153 >                        mres = rmx_multiply(mleft, mright);
154                  rmx_free(mleft);
155                  rmx_free(mright);
156                  if (mres == NULL) {
157                          fputs(inspec, stderr);
158 <                        if (mleft->ncols != mright->nrows)
152 <                                fputs(": mismatched dimensions for multiply\n",
153 <                                                stderr);
154 <                        else
155 <                                fputs(": concatenation failed\n", stderr);
158 >                        fputs(": concatenation failed\n", stderr);
159                          return(NULL);
160                  }
161                  if (verbose) {
# Line 320 | Line 323 | main(int argc, char *argv[])
323          for (i = 1; i < argc; i++) {
324                  if (argv[i][0] && !argv[i][1] &&
325                                  strchr(".+*/", argv[i][0]) != NULL) {
326 <                        if (mop[nmats].inspec == NULL || mop[nmats].binop) {
326 >                        if (!nmats || mop[nmats-1].binop) {
327                                  fprintf(stderr,
328 <                        "%s: missing matrix argument for '%c' operation\n",
328 >                        "%s: missing matrix argument before '%c' operation\n",
329                                                  argv[0], argv[i][0]);
330                                  return(1);
331                          }
332 <                        mop[nmats++].binop = argv[i][0];
332 >                        mop[nmats-1].binop = argv[i][0];
333                  } else if (argv[i][0] != '-' || !argv[i][1]) {
334                          if (argv[i][0] == '-') {
335                                  if (stdin_used++) {
# Line 391 | Line 394 | main(int argc, char *argv[])
394          }
395          if (mop[0].inspec == NULL)      /* nothing to do? */
396                  goto userr;
397 +        if (mop[nmats-1].binop) {
398 +                fprintf(stderr,
399 +                        "%s: missing matrix argument after '%c' operation\n",
400 +                                argv[0], mop[nmats-1].binop);
401 +                return(1);
402 +        }
403                                          /* favor quicker concatenation */
404          mop[nmats].mtx = prefer_right2left(mop) ? op_right2left(mop)
405                                                  : op_left2right(mop);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines