| 14 |  |  | 
| 15 |  | #define MAXCOMP         16              /* #components we support */ | 
| 16 |  |  | 
| 17 | – | static const char       stdin_name[] = "<stdin>"; | 
| 18 | – |  | 
| 17 |  | /* unary matrix operation(s) */ | 
| 18 |  | typedef struct { | 
| 19 |  | double          sca[MAXCOMP];           /* scalar coefficients */ | 
| 26 |  | /* matrix input source and requested operation(s) */ | 
| 27 |  | typedef struct { | 
| 28 |  | const char      *inspec;                /* input specification */ | 
| 29 | + | RMPref          rmp;                    /* matrix preference */ | 
| 30 |  | RUNARYOP        preop;                  /* unary operation(s) */ | 
| 31 |  | RMATRIX         *mtx;                   /* original matrix if loaded */ | 
| 32 |  | int             binop;                  /* binary op with next (or 0) */ | 
| 38 |  | static int | 
| 39 |  | loadmatrix(ROPMAT *rop) | 
| 40 |  | { | 
| 41 | < | if (rop->mtx != NULL) | 
| 41 | > | if (rop->mtx != NULL)           /* already loaded? */ | 
| 42 |  | return(0); | 
| 43 |  |  | 
| 44 | < | rop->mtx = rmx_load(rop->inspec == stdin_name ? | 
| 46 | < | (const char *)NULL : rop->inspec); | 
| 44 | > | rop->mtx = rmx_load(rop->inspec, rop->rmp); | 
| 45 |  | if (rop->mtx == NULL) { | 
| 46 |  | fputs(rop->inspec, stderr); | 
| 47 |  | fputs(": cannot load matrix\n", stderr); | 
| 239 |  | while (rpos-- > 0) { | 
| 240 |  | if (mright == NULL) | 
| 241 |  | break; | 
| 242 | < | mright = binaryop(mop[rpos].inspec, | 
| 242 | > | mright = binaryop(mop[rpos+1].inspec, | 
| 243 |  | loadop(mop+rpos), mop[rpos].binop, mright); | 
| 244 |  | } | 
| 245 |  | return(mright); | 
| 380 |  | get_factors(mop[nmats].preop.cmat, | 
| 381 |  | n, argv+i+1); | 
| 382 |  | break; | 
| 383 | + | case 'r': | 
| 384 | + | if (argv[i][2] == 'f') | 
| 385 | + | mop[nmats].rmp = RMPreflF; | 
| 386 | + | else if (argv[i][2] == 'b') | 
| 387 | + | mop[nmats].rmp = RMPreflB; | 
| 388 | + | else | 
| 389 | + | goto userr; | 
| 390 | + | break; | 
| 391 |  | default: | 
| 392 |  | fprintf(stderr, "%s: unknown operation '%s'\n", | 
| 393 |  | argv[0], argv[i]); | 
| 430 |  | return(0); | 
| 431 |  | userr: | 
| 432 |  | fprintf(stderr, | 
| 433 | < | "Usage: %s [-v][-f[adfc][-t][-s sf .. | -c ce ..] m1 [.+*/] .. > mres\n", | 
| 433 | > | "Usage: %s [-v][-f[adfc][-t][-s sf .. | -c ce ..][-rf|-rb] m1 [.+*/] .. > mres\n", | 
| 434 |  | argv[0]); | 
| 435 |  | return(1); | 
| 436 |  | } |