ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rmatrix.h
(Generate patch)

Comparing ray/src/util/rmatrix.h (file contents):
Revision 2.20 by greg, Wed Dec 6 17:57:34 2023 UTC vs.
Revision 2.26 by greg, Fri Apr 4 18:06:48 2025 UTC

# Line 16 | Line 16 | extern "C" {
16          none, transmission, reflection front (normal side), reflection back */
17   typedef enum {RMPnone=-1, RMPtrans=0, RMPreflF, RMPreflB} RMPref;
18  
19 + /* RMATRIX flags (usually private):
20 +        need to swap input, we should free memory */
21 + #define RMF_SWAPIN      1
22 + #define RMF_FREEMEM     2
23 +
24 + #ifndef MAXCOMP
25 + #define MAXCOMP         MAXCSAMP        /* #components we support */
26 + #endif
27 +                                        /* Set in-core data type */
28 + #if !defined(DTrmx_native) || DTrmx_native==DTfloat
29 + #define DTrmx_native    DTfloat
30 + #define rmx_dtype       float
31 + #define rmx_scanfmt     "%f"
32 + #elif DTrmx_native==DTdouble
33 + #define rmx_dtype       double
34 + #define rmx_scanfmt     "%lf"
35 + #endif
36 +
37   /* General [row][col][cmp] component matrix */
38   typedef struct {
39 <        char    *info;
40 <        void    *mapped;
41 <        double  *mtx;
42 <        COLOR   cexp;
43 <        float   wlpart[4];
44 <        int     nrows, ncols;
45 <        short   ncomp;
46 <        uby8    dtype;
47 <        uby8    swapin;
39 >        char            *info;
40 >        void            *mapped;
41 >        rmx_dtype       *mtx;
42 >        COLOR           cexp;
43 >        float           wlpart[4];
44 >        int             nrows, ncols;
45 >        short           ncomp;
46 >        uby8            dtype;
47 >        uby8            pflags;
48   } RMATRIX;
49  
50   #define rmx_lval(rm,r,c)        ((rm)->mtx + (rm)->ncomp*((c)+(size_t)(rm)->ncols*(r)))
51   #define rmx_val                 rmx_lval
52  
53 + #define rmx_array_size(rm)      (sizeof(rmx_dtype)*(rm)->nrows*(rm)->ncols*(rm)->ncomp)
54 + #define rmx_mapped_size(rm)     ((char *)(rm)->mtx + rmx_array_size(rm) - (char *)(rm)->mapped)
55 +
56   /* Initialize a RMATRIX struct but don't allocate array space */
57   extern RMATRIX  *rmx_new(int nr, int nc, int n);
58  
# Line 53 | Line 74 | extern int     rmx_newtype(int dtyp1, int dtyp2);
74   /* Read matrix header from input stream (cannot be XML) */
75   extern int      rmx_load_header(RMATRIX *rm, FILE *fp);
76  
77 < /* Load next row as double (cannot be XML) */
78 < extern int      rmx_load_row(double *drp, const RMATRIX *rm, FILE *fp);
77 > /* Load next row as rmx_dtype (cannot be XML) */
78 > extern int      rmx_load_row(rmx_dtype *drp, const RMATRIX *rm, FILE *fp);
79  
80   /* Allocate & load post-header data from stream given type set in rm->dtype */
81   extern int      rmx_load_data(RMATRIX *rm, FILE *fp);
# Line 69 | Line 90 | extern int     rmx_addinfo(RMATRIX *rm, const char *info);
90   extern int      rmx_write_header(const RMATRIX *rm, int dtype, FILE *fp);
91  
92   /* Write out matrix data (usually by row) */
93 < extern int      rmx_write_data(const double *dp, int nc, int len,
93 > extern int      rmx_write_data(const rmx_dtype *dp, int nc, int len,
94                                  int dtype, FILE *fp);
95  
96   /* Write matrix using file format indicated by dtype */
# Line 84 | Line 105 | extern RMATRIX *rmx_copy(const RMATRIX *rm);
105   /* Replace data in first matrix with data from second */
106   extern int      rmx_transfer_data(RMATRIX *rdst, RMATRIX *rsrc, int dometa);
107  
108 < /* Allocate and assign transposed matrix */
109 < extern RMATRIX  *rmx_transpose(const RMATRIX *rm);
108 > /* Transpose the given matrix */
109 > extern int      rmx_transpose(RMATRIX *rm);
110  
111   /* Multiply (concatenate) two matrices and allocate the result */
112   extern RMATRIX  *rmx_multiply(const RMATRIX *m1, const RMATRIX *m2);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines