12 |
|
extern "C" { |
13 |
|
#endif |
14 |
|
|
15 |
< |
/* General plane-ordered component matrix */ |
15 |
> |
/* Preferred BSDF component: |
16 |
> |
transmission, reflection front (normal side), reflection back */ |
17 |
> |
typedef enum {RMPtrans=0, RMPreflF, RMPreflB} RMPref; |
18 |
> |
|
19 |
> |
/* General [row][col][cmp] component matrix */ |
20 |
|
typedef struct { |
17 |
– |
int nrows, ncols, ncomp; |
18 |
– |
int dtype; |
21 |
|
char *info; |
22 |
< |
double mtx[1]; /* extends struct */ |
22 |
> |
void *mapped; |
23 |
> |
double *mtx; |
24 |
> |
COLOR cexp; |
25 |
> |
float wlpart[4]; |
26 |
> |
int nrows, ncols; |
27 |
> |
short ncomp; |
28 |
> |
uby8 dtype; |
29 |
> |
uby8 swapin; |
30 |
|
} RMATRIX; |
31 |
|
|
32 |
< |
#define rmx_lval(rm,r,c,i) (rm)->mtx[((i)*(rm)->nrows+(r))*(rm)->ncols+(c)] |
32 |
> |
#define rmx_lval(rm,r,c) ((rm)->mtx + (rm)->ncomp*((c)+(size_t)(rm)->ncols*(r))) |
33 |
|
|
34 |
< |
/* Allocate a nr x nc matrix with n components */ |
34 |
> |
/* Initialize a RMATRIX struct but don't allocate array space */ |
35 |
> |
extern RMATRIX *rmx_new(int nr, int nc, int n); |
36 |
> |
|
37 |
> |
/* Prepare a RMATRIX for writing (allocate array if needed) */ |
38 |
> |
extern int rmx_prepare(RMATRIX *rm); |
39 |
> |
|
40 |
> |
/* Call rmx_new() and rmx_prepare() */ |
41 |
|
extern RMATRIX *rmx_alloc(int nr, int nc, int n); |
42 |
|
|
43 |
|
/* Free a RMATRIX array */ |
46 |
|
/* Resolve data type based on two input types (returns 0 for mismatch) */ |
47 |
|
extern int rmx_newtype(int dtyp1, int dtyp2); |
48 |
|
|
49 |
< |
/* Load matrix from supported file type */ |
50 |
< |
extern RMATRIX *rmx_load(const char *fname); |
49 |
> |
/* Load matrix from supported file type (NULL for stdin, '!' with command) */ |
50 |
> |
extern RMATRIX *rmx_load(const char *inspec, RMPref rmp); |
51 |
|
|
52 |
|
/* Append header information associated with matrix data */ |
53 |
|
extern int rmx_addinfo(RMATRIX *rm, const char *info); |
54 |
|
|
55 |
|
/* Write matrix to file type indicated by dtype */ |
56 |
< |
extern long rmx_write(const RMATRIX *rm, int dtype, FILE *fp); |
56 |
> |
extern int rmx_write(const RMATRIX *rm, int dtype, FILE *fp); |
57 |
|
|
58 |
|
/* Allocate and assign square identity matrix with n components */ |
59 |
|
extern RMATRIX *rmx_identity(int dim, int n); |
66 |
|
|
67 |
|
/* Multiply (concatenate) two matrices and allocate the result */ |
68 |
|
extern RMATRIX *rmx_multiply(const RMATRIX *m1, const RMATRIX *m2); |
69 |
+ |
|
70 |
+ |
/* Element-wise multiplication (or division) of m2 into m1 */ |
71 |
+ |
extern int rmx_elemult(RMATRIX *m1, const RMATRIX *m2, int divide); |
72 |
|
|
73 |
|
/* Sum second matrix into first, applying scale factor beforehand */ |
74 |
|
extern int rmx_sum(RMATRIX *msum, const RMATRIX *madd, const double sf[]); |