| 5 |
|
* General component matrix operations. |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
– |
#include <stdlib.h> |
| 8 |
|
#include <errno.h> |
| 9 |
|
#include <ctype.h> |
| 10 |
|
#include "rtio.h" |
| 235 |
|
rop->inspec, mres->ncomp, |
| 236 |
|
rop->mtx->ncomp, |
| 237 |
|
rop->preop.nsf ? " (* scalar)" : ""); |
| 238 |
< |
rop->preop.nsf = 0; |
| 238 |
> |
rop->preop.nsf = 0; /* now folded in */ |
| 239 |
|
if ((mres->ncomp > 3) & (mres->dtype <= DTspec)) |
| 240 |
|
outtype = DTfloat; /* probably not actual spectrum */ |
| 241 |
|
rmx_free(rop->mtx); |
| 448 |
|
} |
| 449 |
|
|
| 450 |
|
static ROPMAT * |
| 451 |
< |
grow_moparray(ROPMAT *mop, int n2alloc) |
| 451 |
> |
resize_moparr(ROPMAT *mop, int n2alloc) |
| 452 |
|
{ |
| 453 |
|
int nmats = 0; |
| 454 |
+ |
int i; |
| 455 |
|
|
| 456 |
|
while (mop[nmats++].binop) |
| 457 |
|
; |
| 458 |
+ |
for (i = nmats; i > n2alloc; i--) |
| 459 |
+ |
rmx_free(mop[i].mtx); |
| 460 |
|
mop = (ROPMAT *)realloc(mop, n2alloc*sizeof(ROPMAT)); |
| 461 |
|
if (mop == NULL) { |
| 462 |
< |
fputs("Out of memory in grow_moparray()\n", stderr); |
| 462 |
> |
fputs("Out of memory in resize_moparr()\n", stderr); |
| 463 |
|
exit(1); |
| 464 |
|
} |
| 465 |
|
if (n2alloc > nmats) |
| 575 |
|
} |
| 576 |
|
} |
| 577 |
|
if (nmats >= nall) |
| 578 |
< |
mop = grow_moparray(mop, nall += 2); |
| 578 |
> |
mop = resize_moparr(mop, nall += 2); |
| 579 |
|
} |
| 580 |
|
if (mop[0].inspec == NULL) /* nothing to do? */ |
| 581 |
|
goto userr; |
| 603 |
|
else if (mres->dtype == DTxyze) |
| 604 |
|
outfmt = DTxyze; |
| 605 |
|
} |
| 606 |
< |
if (outfmt != DTascii) /* write result to stdout */ |
| 605 |
< |
SET_FILE_BINARY(stdout); |
| 606 |
< |
newheader("RADIANCE", stdout); |
| 606 |
> |
newheader("RADIANCE", stdout); /* write result to stdout */ |
| 607 |
|
printargs(argc, argv, stdout); |
| 608 |
– |
|
| 608 |
|
return(rmx_write(mres, outfmt, stdout) ? 0 : 1); |
| 609 |
|
userr: |
| 610 |
|
fprintf(stderr, |
| 611 |
< |
"Usage: %s [-v][-f[adfc][-t][-s sf .. | -c ce ..][-rf|-rb] m1 [.+*/] .. > mres\n", |
| 611 |
> |
"Usage: %s [-v][-f{adfc}][-t][-s sf .. | -c ce ..][-rf|-rb] m1 [.+*/] .. > mres\n", |
| 612 |
|
argv[0]); |
| 613 |
|
return(1); |
| 614 |
|
} |