| 12 |
|
extern "C" { |
| 13 |
|
#endif |
| 14 |
|
|
| 15 |
+ |
/* Preferred BSDF component: |
| 16 |
+ |
transmission, reflection front (normal side), reflection back */ |
| 17 |
+ |
typedef enum {RMPtrans=0, RMPreflF, RMPreflB} RMPref; |
| 18 |
+ |
|
| 19 |
|
/* General plane-ordered component matrix */ |
| 20 |
|
typedef struct { |
| 21 |
< |
int nrows, ncols, ncomp; |
| 22 |
< |
int dtype; |
| 21 |
> |
int nrows, ncols; |
| 22 |
> |
short ncomp; |
| 23 |
> |
uby8 dtype; |
| 24 |
> |
uby8 swapin; |
| 25 |
|
char *info; |
| 26 |
< |
double mtx[1]; /* extends struct */ |
| 26 |
> |
double mtx[3]; /* extends struct */ |
| 27 |
|
} RMATRIX; |
| 28 |
|
|
| 29 |
< |
#define rmx_lval(rm,r,c,i) (rm)->mtx[(i)+(rm)->ncomp*((c)+(rm)->ncols*(r))] |
| 29 |
> |
#define rmx_lval(rm,r,c,i) (rm)->mtx[(i)+(rm)->ncomp*((c)+(size_t)(rm)->ncols*(r))] |
| 30 |
|
|
| 31 |
|
/* Allocate a nr x nc matrix with n components */ |
| 32 |
|
extern RMATRIX *rmx_alloc(int nr, int nc, int n); |
| 37 |
|
/* Resolve data type based on two input types (returns 0 for mismatch) */ |
| 38 |
|
extern int rmx_newtype(int dtyp1, int dtyp2); |
| 39 |
|
|
| 40 |
< |
/* Load matrix from supported file type */ |
| 41 |
< |
extern RMATRIX *rmx_load(const char *fname); |
| 40 |
> |
/* Load matrix from supported file type (NULL for stdin, '!' with command) */ |
| 41 |
> |
extern RMATRIX *rmx_load(const char *inspec, RMPref rmp); |
| 42 |
|
|
| 43 |
|
/* Append header information associated with matrix data */ |
| 44 |
|
extern int rmx_addinfo(RMATRIX *rm, const char *info); |
| 57 |
|
|
| 58 |
|
/* Multiply (concatenate) two matrices and allocate the result */ |
| 59 |
|
extern RMATRIX *rmx_multiply(const RMATRIX *m1, const RMATRIX *m2); |
| 60 |
+ |
|
| 61 |
+ |
/* Element-wise multiplication (or division) of m2 into m1 */ |
| 62 |
+ |
extern int rmx_elemult(RMATRIX *m1, const RMATRIX *m2, int divide); |
| 63 |
|
|
| 64 |
|
/* Sum second matrix into first, applying scale factor beforehand */ |
| 65 |
|
extern int rmx_sum(RMATRIX *msum, const RMATRIX *madd, const double sf[]); |