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.17 by greg, Sat Dec 28 18:05:14 2019 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines