--- ray/src/util/rmatrix.h 2015/05/04 20:53:21 2.7 +++ ray/src/util/rmatrix.h 2020/03/25 01:51:09 2.12 @@ -1,4 +1,4 @@ -/* RCSid $Id: rmatrix.h,v 2.7 2015/05/04 20:53:21 greg Exp $ */ +/* RCSid $Id: rmatrix.h,v 2.12 2020/03/25 01:51:09 greg Exp $ */ /* * Header file for general matrix routines. */ @@ -14,13 +14,15 @@ extern "C" { /* General plane-ordered component matrix */ typedef struct { - int nrows, ncols, ncomp; - int dtype; + int nrows, ncols; + short ncomp; + uby8 dtype; + uby8 swapin; char *info; - double mtx[1]; /* extends struct */ + double mtx[3]; /* extends struct */ } RMATRIX; -#define rmx_lval(rm,r,c,i) (rm)->mtx[(i)+(rm)->ncomp*((c)+(rm)->ncols*(r))] +#define rmx_lval(rm,r,c,i) (rm)->mtx[(i)+(rm)->ncomp*((c)+(size_t)(rm)->ncols*(r))] /* Allocate a nr x nc matrix with n components */ extern RMATRIX *rmx_alloc(int nr, int nc, int n); @@ -51,6 +53,9 @@ extern RMATRIX *rmx_transpose(const RMATRIX *rm); /* Multiply (concatenate) two matrices and allocate the result */ extern RMATRIX *rmx_multiply(const RMATRIX *m1, const RMATRIX *m2); + +/* Element-wise multiplication (or division) of m2 into m1 */ +extern int rmx_elemult(RMATRIX *m1, const RMATRIX *m2, int divide); /* Sum second matrix into first, applying scale factor beforehand */ extern int rmx_sum(RMATRIX *msum, const RMATRIX *madd, const double sf[]);