10 |
|
#include "rmatrix.h" |
11 |
|
#include "platform.h" |
12 |
|
|
13 |
– |
#define MAXCOMP MAXCSAMP /* #components we support */ |
14 |
– |
|
13 |
|
/* Unary matrix operation(s) */ |
14 |
|
typedef struct { |
15 |
|
double cmat[MAXCOMP*MAXCOMP]; /* component transformation */ |
32 |
|
int verbose = 0; /* verbose reporting? */ |
33 |
|
|
34 |
|
/* Load matrix */ |
35 |
< |
static int |
35 |
> |
int |
36 |
|
loadmatrix(ROPMAT *rop) |
37 |
|
{ |
38 |
|
if (rop->mtx != NULL) /* already loaded? */ |
43 |
|
return(!rop->mtx ? -1 : 1); |
44 |
|
} |
45 |
|
|
46 |
< |
static int checksymbolic(ROPMAT *rop); |
46 |
> |
extern int checksymbolic(ROPMAT *rop); |
47 |
|
|
48 |
|
/* Check/set transform based on a reference input file */ |
49 |
< |
static int |
49 |
> |
int |
50 |
|
checkreffile(ROPMAT *rop) |
51 |
|
{ |
52 |
|
static const char *curRF = NULL; |
105 |
|
} |
106 |
|
|
107 |
|
/* Compute conversion row from spectrum to one channel of RGB */ |
108 |
< |
static void |
108 |
> |
void |
109 |
|
rgbrow(ROPMAT *rop, int r, int p) |
110 |
|
{ |
111 |
|
const int nc = rop->mtx->ncomp; |
122 |
|
} |
123 |
|
|
124 |
|
/* Compute conversion row from spectrum to one channel of XYZ */ |
125 |
< |
static void |
125 |
> |
void |
126 |
|
xyzrow(ROPMAT *rop, int r, int p) |
127 |
|
{ |
128 |
|
const int nc = rop->mtx->ncomp; |
139 |
|
} |
140 |
|
|
141 |
|
/* Use the spectral sensitivity function to compute matrix coefficients */ |
142 |
< |
static void |
143 |
< |
sensrow(ROPMAT *rop, int r, double (*sf)(SCOLOR sc, int ncs, const float wlpt[4])) |
142 |
> |
void |
143 |
> |
sensrow(ROPMAT *rop, int r, double (*sf)(const SCOLOR sc, int ncs, const float wlpt[4])) |
144 |
|
{ |
145 |
|
const int nc = rop->mtx->ncomp; |
146 |
|
int i; |
154 |
|
} |
155 |
|
|
156 |
|
/* Check/set symbolic transform */ |
157 |
< |
static int |
157 |
> |
int |
158 |
|
checksymbolic(ROPMAT *rop) |
159 |
|
{ |
160 |
|
const int nc = rop->mtx->ncomp; |
265 |
|
} |
266 |
|
|
267 |
|
/* Get matrix and perform unary operations */ |
268 |
< |
static RMATRIX * |
268 |
> |
RMATRIX * |
269 |
|
loadop(ROPMAT *rop) |
270 |
|
{ |
271 |
|
int outtype = 0; |
341 |
|
} |
342 |
|
} |
343 |
|
if (rop->preop.transpose) { /* transpose matrix? */ |
344 |
< |
mres = rmx_transpose(rop->mtx); |
347 |
< |
if (mres == NULL) { |
344 |
> |
if (!rmx_transpose(rop->mtx)) { |
345 |
|
fputs(rop->inspec, stderr); |
346 |
|
fputs(": transpose failed\n", stderr); |
347 |
|
goto failure; |
350 |
|
fputs(rop->inspec, stderr); |
351 |
|
fputs(": transposed rows and columns\n", stderr); |
352 |
|
} |
356 |
– |
rmx_free(rop->mtx); |
357 |
– |
rop->mtx = mres; |
353 |
|
} |
354 |
|
mres = rop->mtx; |
355 |
|
rop->mtx = NULL; |
362 |
|
} |
363 |
|
|
364 |
|
/* Execute binary operation, free matrix arguments and return new result */ |
365 |
< |
static RMATRIX * |
365 |
> |
RMATRIX * |
366 |
|
binaryop(const char *inspec, RMATRIX *mleft, int op, RMATRIX *mright) |
367 |
|
{ |
368 |
|
RMATRIX *mres = NULL; |
439 |
|
} |
440 |
|
|
441 |
|
/* Perform matrix operations from left to right */ |
442 |
< |
static RMATRIX * |
442 |
> |
RMATRIX * |
443 |
|
op_left2right(ROPMAT *mop) |
444 |
|
{ |
445 |
|
RMATRIX *mleft = loadop(mop); |
455 |
|
} |
456 |
|
|
457 |
|
/* Perform matrix operations from right to left */ |
458 |
< |
static RMATRIX * |
458 |
> |
RMATRIX * |
459 |
|
op_right2left(ROPMAT *mop) |
460 |
|
{ |
461 |
|
RMATRIX *mright; |
484 |
|
: (mop)->mtx->ncols) |
485 |
|
|
486 |
|
/* Should we prefer concatenating from rightmost matrix towards left? */ |
487 |
< |
static int |
487 |
> |
int |
488 |
|
prefer_right2left(ROPMAT *mop) |
489 |
|
{ |
490 |
|
int mri = 0; |
511 |
|
return(t_ncols(mop+mri) < t_nrows(mop)); |
512 |
|
} |
513 |
|
|
514 |
< |
static int |
514 |
> |
int |
515 |
|
get_factors(double da[], int n, char *av[]) |
516 |
|
{ |
517 |
|
int ac; |
521 |
|
return(ac); |
522 |
|
} |
523 |
|
|
524 |
< |
static ROPMAT * |
524 |
> |
ROPMAT * |
525 |
|
resize_moparr(ROPMAT *mop, int n2alloc) |
526 |
|
{ |
527 |
|
int nmats = 0; |
529 |
|
|
530 |
|
while (mop[nmats++].binop) |
531 |
|
; |
532 |
< |
for (i = nmats; i > n2alloc; i--) |
532 |
> |
for (i = nmats; i >= n2alloc; i--) |
533 |
|
rmx_free(mop[i].mtx); |
534 |
|
mop = (ROPMAT *)realloc(mop, n2alloc*sizeof(ROPMAT)); |
535 |
|
if (mop == NULL) { |
684 |
|
else if (mres->dtype == DTxyze) |
685 |
|
outfmt = DTxyze; |
686 |
|
} |
687 |
+ |
#if DTrmx_native==DTfloat |
688 |
+ |
if (outfmt == DTdouble) |
689 |
+ |
fprintf(stderr, |
690 |
+ |
"%s: warning - writing float result as double\n", |
691 |
+ |
argv[0]); |
692 |
+ |
#endif |
693 |
|
newheader("RADIANCE", stdout); /* write result to stdout */ |
694 |
|
printargs(argc, argv, stdout); |
695 |
|
return(rmx_write(mres, outfmt, stdout) ? 0 : 1); |